Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth committed Apr 22, 2024
1 parent d2266e1 commit e347906
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tools/isolib/isolib.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ main <- function() {

args <- commandArgs(trailingOnly = TRUE)
compound_table <- read.delim(args[1], stringsAsFactors = FALSE)
adducts_to_use <- c(unlist(strsplit(args[2], ',', fixed = TRUE)))
adducts_to_use <- c(unlist(strsplit(args[2], ",", fixed = TRUE)))

chemforms <- compound_table$formula
chemforms <- check_chemform(isotopes, chemforms)[, 2]

spectra <- data.frame()

for (current in adducts_to_use) {
adduct <- adducts[adducts$Name == current,]
adduct <- adducts[adducts$Name == current, ]
multiplied_chemforms <- multiform(chemforms, adduct$Mult)

if(adduct$Ion_mode == "negative") {
if (adduct$Ion_mode == "negative") {
merged_chemforms <- subform(multiplied_chemforms, adduct$Formula_ded)
} else {
merged_chemforms <- mergeform(multiplied_chemforms, adduct$Formula_add)
}

charge_string <- paste0(if(adduct$Charge > 0) "+" else "-", if(abs(adduct$Charge) > 1) abs(adduct$Charge) else "")
charge_string <- paste0(if (adduct$Charge > 0) "+" else "-", if (abs(adduct$Charge) > 1) abs(adduct$Charge) else "")
adduct_string <- paste0("[", adduct$Name, "]", charge_string)
precursor_mz <- calculateMass(multiplied_chemforms) + adduct$Mass

if (args[4] == TRUE) {
names <- paste(compound_table$name, paste0("(", adduct$Name, ")"), sep=" ")
names <- paste(compound_table$name, paste0("(", adduct$Name, ")"), sep = " ")
} else {
names <- compound_table$name
}
Expand Down Expand Up @@ -64,12 +64,12 @@ main <- function() {
mzs <- append(mzs, list(patterns[[i]][, 1]))
intensities <- append(intensities, list(patterns[[i]][, 2]))
}

spectra_df$mz <- mzs
spectra_df$intensity <- intensities
spectra <- rbind(spectra, spectra_df)
}

sps <- Spectra(spectra)
export(sps, MsBackendMsp(), file = args[5])
}
Expand Down

0 comments on commit e347906

Please sign in to comment.