Repository 'isolib'
hg clone https://toolshed.g2.bx.psu.edu/repos/recetox/isolib

Changeset 0:8a1893635ac0 (2024-04-23)
Next changeset 1:7a4540275084 (2024-04-23)
Commit message:
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/isolib commit 019a1087adb6bd570eada9ce1d7d6fcd6d55bff8
added:
isolib.R
isolib.xml
test-data/lc_markers_neg.tsv
test-data/test0.msp
b
diff -r 000000000000 -r 8a1893635ac0 isolib.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolib.R Tue Apr 23 06:39:20 2024 +0000
[
@@ -0,0 +1,80 @@
+library(enviPat)
+library(Spectra)
+library(MsBackendMsp)
+library(MetaboCoreUtils)
+
+#' @param args A list of command line arguments.
+main <- function() {
+  data(isotopes)
+  data(adducts)
+
+  args <- commandArgs(trailingOnly = TRUE)
+  compound_table <- read.delim(args[1], stringsAsFactors = FALSE)
+  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, ]
+    multiplied_chemforms <- multiform(chemforms, adduct$Mult)
+
+    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 "")
+    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 = " ")
+    } else {
+      names <- compound_table$name
+    }
+
+    spectra_df <- data.frame(
+      name = names,
+      adduct = adduct_string,
+      formula = chemforms,
+      charge = adduct$Charge,
+      ionization_mode = adduct$Ion_mode,
+      precursor_mz = precursor_mz,
+      msLevel = as.integer(1)
+    )
+
+    if ("rt" %in% colnames(compound_table)) {
+      spectra_df$retention_time <- compound_table$rt
+    }
+
+    patterns <- enviPat::isopattern(
+      isotopes = isotopes,
+      chemforms = merged_chemforms,
+      charge = adduct$Charge,
+      threshold = as.numeric(args[3]),
+    )
+
+    mzs <- list()
+    intensities <- list()
+    for (i in seq_along(patterns)) {
+      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])
+}
+
+# Get the command line arguments
+args <- commandArgs(trailingOnly = TRUE)
+# Call the main function
+main()
b
diff -r 000000000000 -r 8a1893635ac0 isolib.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/isolib.xml Tue Apr 23 06:39:20 2024 +0000
[
@@ -0,0 +1,72 @@
+<tool id="isolib" name="isolib" version="1.0.0+galaxy0" profile="21.09">
+    <description>create an isotopic pattern library for given compounds and adducts</description>
+    <creator>
+        <person
+            givenName="Helge"
+            familyName="Hecht"
+            url="https://github.com/hechth"
+            identifier="0000-0001-6744-996X" />
+        <organization
+            url="https://www.recetox.muni.cz/"
+            email="GalaxyToolsDevelopmentandDeployment@space.muni.cz"
+            name="RECETOX MUNI" />
+    </creator>
+    <edam_operations>
+        <edam_operation>operation_3632</edam_operation>
+    </edam_operations>
+    <requirements>
+        <requirement type="package" version="1.10.0">bioconductor-metabocoreutils</requirement>
+        <requirement type="package" version="1.12.0">bioconductor-spectra</requirement>
+        <requirement type="package" version="1.6.0">bioconductor-msbackendmsp</requirement>
+        <requirement type="package" version="2.6">r-envipat</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        Rscript ${__tool_directory__}/isolib.R '${input_file}' '${adducts}' '${threshold}' '${append_adduct}' '${isotope_library}'
+    ]]></command>
+    <inputs>
+        <param name="input_file" type="data" format="tabular" label="Table with input compounds"/>
+        <conditional name="ionization">
+            <param name="ionization" type="select" label="Ionization mode" help="Ionization mode used in the experiment">
+                <option value="negative" selected="true">negative</option>
+                <option value="positive">positive</option>
+            </param>
+            <when value="positive">
+                <param name="adducts" type="select" label="Adducts" multiple="true" help="Adducts to use">
+                    <option value="M+H" selected="true">M+H</option>
+                </param>
+            </when>
+            <when value="negative">
+                <param name="adducts" type="select" label="Adducts" multiple="true" help="Adducts to use">
+                    <option value="M-H" selected="true">M-H</option>
+                    <option value="M-2H">M-2H</option>
+                    <option value="2M-H">2M-H</option>
+                </param>
+            </when>
+        </conditional>
+        <param name="threshold" type="float" min="0" max="100" value="1" label="Threshold" help="Probability threshold to use as cutoff for isotopic pattern distribution - this can be used to remove low abundant peaks and improve computation performance." />
+        <param name="append_adduct" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="true" label="Append adduct to compound name" help="Append the adduct string to the compound name for easy identification." />
+    </inputs>
+    <outputs>
+        <data format="msp" name="isotope_library"/>
+    </outputs>
+
+    <tests>
+        <test>
+            <param name="input_file" value="lc_markers_neg.tsv"/>
+            <output name="isotope_library" file="test0.msp"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+        This tool computes isotopic patterns for given compounds and adduct forms.
+        The compound table input file should contain the following columns:
+        - name: compound name
+        - formula: compound formula
+        - rt (optional): retention time
+
+        The output is a spectral library in the MSP format.
+    ]]></help>
+    <citations>
+        <citation type="doi">10.1021/acs.analchem.5b00941</citation>
+        <citation type="doi">10.3390/metabo12020173</citation>
+    </citations>
+</tool>
\ No newline at end of file
b
diff -r 000000000000 -r 8a1893635ac0 test-data/lc_markers_neg.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/lc_markers_neg.tsv Tue Apr 23 06:39:20 2024 +0000
b
@@ -0,0 +1,24 @@
+formula name rt
+C8H6Cl2O3 2,4-Dichlorophenoxyacetic acid ou 2,4-D 484.2
+C9H15N3O1 2-diethylamino-6-methyl pyrimidin-4-ol/one 451.8
+C5H2Cl3N1O1 3,5,6-Trichloro-2-pyridinol 499.2
+C13H10O3 3-phenoxybenzoic acid 517.8
+C13H9FO3 4-Fluoro-3-phenoxybenzoic acid 532.2
+C6H5NO3 4-nitrophenol 165
+C6H4Cl1N1O2 6-Chloronicotinic acid 172.2
+C19H28N2O5S Acetochlor mercapturate 607.2
+C19H28N2O5S1 Alachlor mercapturate 607.2
+C10H12N2O3S1 Bentazone 747.6
+C4H11O3P1S1 Diethylthiophosphate 177
+C14H17Cl2NO2 Fenhexamid 689.4
+C11H13ClO2 Fenvalerate free acid 585
+C12H4Cl2F6N4OS Fipronil 750
+C12H4Cl2F6N4O2S Fipronil sulfone 771
+C16H22ClN3O2 Hydroxy-tebuconazole 696.6
+C16H11ClF6N2O Fluopyram 725.4
+C10H11Cl1O3 Mecoprop 544.8
+C7H9NO2S p-Toluenesulfonamide 362.4
+C12H7Cl3O2 Triclosan 811.8
+C18H15Cl3O8 Triclosan glucuronide 665.4
+C12H7Cl3O5S Triclosan sulfate 695.4
+C9H9N4Cl acetamiprid-N-desmethyl 402.6
b
diff -r 000000000000 -r 8a1893635ac0 test-data/test0.msp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test0.msp Tue Apr 23 06:39:20 2024 +0000
[
b'@@ -0,0 +1,352 @@\n+NAME: 2,4-Dichlorophenoxyacetic acid ou 2,4-D (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C8H6Cl2O3\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 218.962123412\n+retention_time: 484.2\n+Num Peaks: 5\n+218.962123019909 100\n+219.965477859909 8.65258263418579\n+220.959172909909 63.9915522703273\n+221.962527749909 5.53692193908827\n+222.956222799909 10.2372969049151\n+\n+NAME: 2-diethylamino-6-methyl pyrimidin-4-ol/one (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C9H15N3O1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 180.1142361\n+retention_time: 451.8\n+Num Peaks: 3\n+180.114235677909 100\n+181.111270637909 1.09598940142117\n+181.117590517909 9.73415546345901\n+\n+NAME: 3,5,6-Trichloro-2-pyridinol (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C5H2Cl3N1O1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 195.912920724\n+retention_time: 499.2\n+Num Peaks: 7\n+195.912920371909 100\n+196.916275211909 5.40786414636612\n+197.909970261909 95.987328405491\n+198.913325101909 5.19086431789525\n+199.907020151909 30.7118907147453\n+200.910374991909 1.66085732663385\n+201.904070041909 3.27550259998867\n+\n+NAME: 3-phenoxybenzoic acid (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C13H10O3\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 213.05571818\n+retention_time: 517.8\n+Num Peaks: 2\n+213.055717727909 100\n+214.059072567909 14.0604467805519\n+\n+NAME: 4-Fluoro-3-phenoxybenzoic acid (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C13H9F1O3\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 231.046296368\n+retention_time: 532.2\n+Num Peaks: 2\n+231.046295895909 100\n+232.049650735909 14.0604467805519\n+\n+NAME: 4-nitrophenol (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C6H5N1O3\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 138.01966702\n+retention_time: 165\n+Num Peaks: 2\n+138.019666577909 100\n+139.023021417909 6.48943697563934\n+\n+NAME: 6-Chloronicotinic acid (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C6H4Cl1N1O2\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 155.985780048\n+retention_time: 172.2\n+Num Peaks: 4\n+155.985779635909 100\n+156.989134475909 6.48943697563934\n+157.982829525909 31.9957761351637\n+158.986184365909 2.0763457271581\n+\n+NAME: Acetochlor mercapturate (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C19H28N2O5S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 395.164616996\n+retention_time: 607.2\n+Num Peaks: 5\n+395.164616293909 100\n+396.167971133909 20.5498837561912\n+397.160412433909 4.47415517422887\n+397.168862073909 1.02749681726596\n+397.171325973909 2.00035763238777\n+\n+NAME: Alachlor mercapturate (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C19H28N2O5S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 395.164616996\n+retention_time: 607.2\n+Num Peaks: 5\n+395.164616293909 100\n+396.167971133909 20.5498837561912\n+397.160412433909 4.47415517422887\n+397.168862073909 1.02749681726596\n+397.171325973909 2.00035763238777\n+\n+NAME: Bentazone (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C10H12N2O3S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 239.049587244\n+retention_time: 747.6\n+Num Peaks: 3\n+239.049586541909 100\n+240.052941381909 10.8157282927322\n+241.045382681909 4.47415517422887\n+\n+NAME: Diethylthiophosphate (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C4H11O3P1S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 169.009375842\n+retention_time: 177\n+Num Peaks: 3\n+169.009374979909 100\n+170.012729819909 4.32629131709289\n+171.005171119909 4.47415517422887\n+\n+NAME: Fenhexamid (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C14H17Cl2N1O2\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 300.056358144\n+retention_time: 689.4\n+Num Peaks: 7\n+300.056357761909 100\n+301.059712601909 15.1420196098251\n+302.053407651909 63.9915522703273\n+302.063067441909 1.0645178043701\n+303.056762491909 9.68961339340446\n+304.050457541909 10.2372969049151\n+305.053812381909 1.55013350485826\n+\n+NAME: Fenvalerate free acid (M-H)\n+ms'..b'39512787\n+436.927225825909 4.47415517422887\n+436.928479575909 63.9915522703273\n+437.931834415909 8.3053829086324\n+438.924275715909 2.86308134697222\n+438.925529465909 10.2372969049151\n+439.928884305909 1.32868586130708\n+\n+NAME: Fipronil sulfone (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C12H4Cl2F6N4O2S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 450.926345048\n+retention_time: 771\n+Num Peaks: 9\n+450.926344305909 100\n+451.923379265909 1.4613192018949\n+451.929699145909 12.9788739512787\n+452.922140445909 4.47415517422887\n+452.923394195909 63.9915522703273\n+453.926749035909 8.3053829086324\n+454.919190335909 2.86308134697222\n+454.920444085909 10.2372969049151\n+455.923798925909 1.32868586130708\n+\n+NAME: Hydroxy-tebuconazole (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C16H22Cl1N3O2\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 322.132778624\n+retention_time: 696.6\n+Num Peaks: 6\n+322.132778231909 100\n+323.129813191909 1.09598940142117\n+323.136133071909 17.3051652683716\n+324.129828121909 31.9957761351637\n+324.139487911909 1.4037597420265\n+325.133182961909 5.53692193908827\n+\n+NAME: Fluopyram (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C16H11Cl1F6N2O1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 395.039133972\n+retention_time: 725.4\n+Num Peaks: 5\n+395.039133449909 100\n+396.042488289909 17.3051652683716\n+397.036183339909 31.9957761351637\n+397.045843129909 1.4037597420265\n+398.039538179909 5.53692193908827\n+\n+NAME: Mecoprop (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C10H11Cl1O3\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 213.032395892\n+retention_time: 544.8\n+Num Peaks: 4\n+213.032395469909 100\n+214.035750309909 10.8157282927322\n+215.029445359909 31.9957761351637\n+216.032800199909 3.46057621193017\n+\n+NAME: p-Toluenesulfonamide (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C7H9N1O2S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 170.028123528\n+retention_time: 362.4\n+Num Peaks: 3\n+170.028122815909 100\n+171.031477655909 7.57100980491256\n+172.023918955909 4.47415517422887\n+\n+NAME: Triclosan (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C12H7Cl3O2\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 286.943886504\n+retention_time: 811.8\n+Num Peaks: 7\n+286.943886141909 100\n+287.947240981909 12.9788739512787\n+288.940936031909 95.987328405491\n+289.944290871909 12.4580743629486\n+290.937985921909 30.7118907147453\n+291.941340761909 3.98605758392125\n+292.935035811909 3.27550259998867\n+\n+NAME: Triclosan glucuronide (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C18H15Cl3O8\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 462.97597448\n+retention_time: 665.4\n+Num Peaks: 11\n+462.975974117909 100\n+463.979328957909 19.468310926918\n+464.973024007909 95.987328405491\n+464.980219897909 1.64399490762553\n+464.982683797909 1.78979367108379\n+465.976378847909 18.6871115444229\n+466.970073897909 30.7118907147453\n+466.977269787909 1.57802679095207\n+466.979733687909 1.71797512884389\n+467.973428737909 5.97908637588188\n+468.967123787909 3.27550259998867\n+\n+NAME: Triclosan sulfate (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C12H7Cl3O5S1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 366.900701364\n+retention_time: 695.4\n+Num Peaks: 11\n+366.900700731909 100\n+367.904055571909 12.9788739512787\n+368.896496871909 4.47415517422887\n+368.897750621909 95.987328405491\n+368.904946511909 1.02749681726596\n+369.901105461909 12.4580743629486\n+370.893546761909 4.29462202045833\n+370.894800511909 30.7118907147453\n+371.898155351909 3.98605758392125\n+372.890596651909 1.37409764751729\n+372.891850401909 3.27550259998867\n+\n+NAME: acetamiprid-N-desmethyl (M-H)\n+msLevel: MS1\n+PRECURSORTYPE: [M-H]-\n+FORMULA: C9H9N4Cl1\n+charge: -1\n+ionization_mode: negative\n+precursor_mz: 207.044297968\n+retention_time: 402.6\n+Num Peaks: 5\n+207.044297585909 100\n+208.041332545909 1.4613192018949\n+208.047652425909 9.73415546345901\n+209.041347475909 31.9957761351637\n+210.044702315909 3.11451859073715\n+\n'