Skip to content

Commit

Permalink
1.2.8.2
Browse files Browse the repository at this point in the history
Minor bug fixes and updates with precursor mass calibrations.
  • Loading branch information
qzhang503 committed Jun 27, 2023
1 parent b487e01 commit 10651ee
Show file tree
Hide file tree
Showing 35 changed files with 1,004 additions and 392 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mzion
Type: Package
Title: Database Searches of Proteomic Mass-spectrometrirc Data
Version: 1.2.8.1
Title: Proteomics Database Searches of Mass-spectrometrirc Data
Version: 1.2.8.2
Authors@R:
person(given = "Qiang",
family = "Zhang",
Expand Down
40 changes: 38 additions & 2 deletions R/mgfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -1598,13 +1598,49 @@ prepBrukerMGF <- function (file = NULL, begin_offset = 5L, charge_offset = 5L)
message("Processing: ", file)

lines <- readLines(file)
hd <- lines[1:100]

### Some MGFs may have additional "SCANS=" lines
pat_sc <- "SCANS"
sc <- .Internal(which(stringi::stri_startswith_fixed(hd, pat_sc)))

if (length(sc)) {
lscs <- .Internal(which(stringi::stri_startswith_fixed(lines, pat_sc)))
lines <- lines[-lscs]
rm(list = "lscs")
}
rm(list = c("pat_sc", "sc"))

###PrecursorID:
pat_pr <- "###PrecursorID"
pr <- .Internal(which(stringi::stri_startswith_fixed(hd, pat_pr)))

if (length(pr)) {
lprs <- .Internal(which(stringi::stri_startswith_fixed(lines, pat_pr)))
lines <- lines[-lprs]
rm(list = "lprs")
}
rm(list = c("pat_pr", "pr"))

###CCS:
pat_ccs <- "###CCS"
ccs <- .Internal(which(stringi::stri_startswith_fixed(hd, pat_ccs)))

if (length(ccs)) {
ccs <- .Internal(which(stringi::stri_startswith_fixed(lines, pat_ccs)))
lines <- lines[-ccs]
rm(list = "ccs")
}
rm(list = c("pat_ccs", "ccs"))

## Processing
begins <- .Internal(which(stringi::stri_startswith_fixed(lines, "BEGIN IONS")))
ends <- .Internal(which(stringi::stri_endswith_fixed(lines, "END IONS")))
hdrs <- 1:(begins[1]-begin_offset-1L)

zls <- lines[begins+5L]
oks <- grepl("^CHARGE", zls) & (zls != "CHARGE=1+")
# oks <- grepl("^CHARGE", zls) & (zls != "CHARGE=1+")
oks <- grepl("^CHARGE", zls) & (zls != "CHARGE=1+") & grepl("^###Mobility", lines[begins-1L])
rm(list = "zls")

b_oks <- begins[oks] - begin_offset
Expand All @@ -1623,7 +1659,7 @@ prepBrukerMGF <- function (file = NULL, begin_offset = 5L, charge_offset = 5L)
#' @param filepath A file path to MGF.
#' @param n_cores The number of CPU cores.
#' @export
mprepBrukerMGF <- function (filepath, n_cores = 48L)
mprepBrukerMGF <- function (filepath, n_cores = 32L)
{
message("Preparing Bruker's MGFs.")

Expand Down
18 changes: 6 additions & 12 deletions R/ms2_gen.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ gen_ms2ions_base <- function (aa_seq = NULL, ms1_mass = NULL,
mod_indexes = NULL,
type_ms2ions = "by", maxn_vmods_per_pep = 5L,
maxn_sites_per_vmod = 3L,

# dummy
maxn_fnl_per_seq = 3L, maxn_vnl_per_seq = 3L,
maxn_vmods_sitescombi_per_pep = 64L)
{
Expand Down Expand Up @@ -182,11 +180,13 @@ gen_ms2ions_a0_vnl0_fnl1 <- function (aa_seq, ms1_mass = NULL,
maxn_vmods_per_pep = 5L,
maxn_sites_per_vmod = 3L,
maxn_fnl_per_seq = 3L,

# dummy
maxn_vnl_per_seq = 3L,
maxn_vmods_sitescombi_per_pep = 64L)
{
# cannot distinguish a neutral loss is in-source or in-MS2:
# "+ms1_offset and +ms2_nl" versus "-ms1_offset and -ms2_nl"
# if (ms1_offset != 0) maxn_vnl_per_seq = 1L

if (maxn_fnl_per_seq < 2L)
return(
gen_ms2ions_base(aa_seq = aa_seq, ms1_mass = ms1_mass,
Expand Down Expand Up @@ -478,10 +478,8 @@ gen_ms2ions_a1_vnl0_fnl0 <- function (aa_seq, ms1_mass = NULL, aa_masses = NULL,
mod_indexes = NULL, type_ms2ions = "by",
maxn_vmods_per_pep = 5L,
maxn_sites_per_vmod = 3L,

# dummy
maxn_fnl_per_seq = 3L, maxn_vnl_per_seq = 3L,

maxn_fnl_per_seq = 3L,
maxn_vnl_per_seq = 3L,
maxn_vmods_sitescombi_per_pep = 64L)
{
aas <- .Internal(strsplit(aa_seq, "", fixed = TRUE, perl = FALSE, useBytes = FALSE))
Expand Down Expand Up @@ -770,8 +768,6 @@ gen_ms2ions_a1_vnl0_fnl1 <- function (aa_seq = NULL, ms1_mass = NULL,
maxn_sites_per_vmod = 3L,
maxn_vmods_sitescombi_per_pep = 64L,
maxn_fnl_per_seq = 3L,

# dummy
maxn_vnl_per_seq = 3L)
{
if (maxn_fnl_per_seq < 2L)
Expand Down Expand Up @@ -1146,8 +1142,6 @@ gen_ms2ions_a1_vnl1_fnl0 <- function (aa_seq = NULL, ms1_mass = NULL,
maxn_vmods_per_pep = 5L,
maxn_sites_per_vmod = 3L,
maxn_vmods_sitescombi_per_pep = 64L,

# dummy
maxn_fnl_per_seq = 3L,
maxn_vnl_per_seq = 3L)
{
Expand Down
Loading

0 comments on commit 10651ee

Please sign in to comment.