changeset 0:8a1893635ac0 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/isolib commit 019a1087adb6bd570eada9ce1d7d6fcd6d55bff8
author recetox
date Tue, 23 Apr 2024 06:39:20 +0000
parents
children 7a4540275084
files isolib.R isolib.xml test-data/lc_markers_neg.tsv test-data/test0.msp
diffstat 4 files changed, 528 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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()
--- /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
--- /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
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test0.msp	Tue Apr 23 06:39:20 2024 +0000
@@ -0,0 +1,352 @@
+NAME: 2,4-Dichlorophenoxyacetic acid ou 2,4-D (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C8H6Cl2O3
+charge: -1
+ionization_mode: negative
+precursor_mz: 218.962123412
+retention_time: 484.2
+Num Peaks: 5
+218.962123019909 100
+219.965477859909 8.65258263418579
+220.959172909909 63.9915522703273
+221.962527749909 5.53692193908827
+222.956222799909 10.2372969049151
+
+NAME: 2-diethylamino-6-methyl pyrimidin-4-ol/one (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C9H15N3O1
+charge: -1
+ionization_mode: negative
+precursor_mz: 180.1142361
+retention_time: 451.8
+Num Peaks: 3
+180.114235677909 100
+181.111270637909 1.09598940142117
+181.117590517909 9.73415546345901
+
+NAME: 3,5,6-Trichloro-2-pyridinol (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C5H2Cl3N1O1
+charge: -1
+ionization_mode: negative
+precursor_mz: 195.912920724
+retention_time: 499.2
+Num Peaks: 7
+195.912920371909 100
+196.916275211909 5.40786414636612
+197.909970261909 95.987328405491
+198.913325101909 5.19086431789525
+199.907020151909 30.7118907147453
+200.910374991909 1.66085732663385
+201.904070041909 3.27550259998867
+
+NAME: 3-phenoxybenzoic acid (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C13H10O3
+charge: -1
+ionization_mode: negative
+precursor_mz: 213.05571818
+retention_time: 517.8
+Num Peaks: 2
+213.055717727909 100
+214.059072567909 14.0604467805519
+
+NAME: 4-Fluoro-3-phenoxybenzoic acid (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C13H9F1O3
+charge: -1
+ionization_mode: negative
+precursor_mz: 231.046296368
+retention_time: 532.2
+Num Peaks: 2
+231.046295895909 100
+232.049650735909 14.0604467805519
+
+NAME: 4-nitrophenol (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C6H5N1O3
+charge: -1
+ionization_mode: negative
+precursor_mz: 138.01966702
+retention_time: 165
+Num Peaks: 2
+138.019666577909 100
+139.023021417909 6.48943697563934
+
+NAME: 6-Chloronicotinic acid (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C6H4Cl1N1O2
+charge: -1
+ionization_mode: negative
+precursor_mz: 155.985780048
+retention_time: 172.2
+Num Peaks: 4
+155.985779635909 100
+156.989134475909 6.48943697563934
+157.982829525909 31.9957761351637
+158.986184365909 2.0763457271581
+
+NAME: Acetochlor mercapturate (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C19H28N2O5S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 395.164616996
+retention_time: 607.2
+Num Peaks: 5
+395.164616293909 100
+396.167971133909 20.5498837561912
+397.160412433909 4.47415517422887
+397.168862073909 1.02749681726596
+397.171325973909 2.00035763238777
+
+NAME: Alachlor mercapturate (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C19H28N2O5S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 395.164616996
+retention_time: 607.2
+Num Peaks: 5
+395.164616293909 100
+396.167971133909 20.5498837561912
+397.160412433909 4.47415517422887
+397.168862073909 1.02749681726596
+397.171325973909 2.00035763238777
+
+NAME: Bentazone (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C10H12N2O3S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 239.049587244
+retention_time: 747.6
+Num Peaks: 3
+239.049586541909 100
+240.052941381909 10.8157282927322
+241.045382681909 4.47415517422887
+
+NAME: Diethylthiophosphate (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C4H11O3P1S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 169.009375842
+retention_time: 177
+Num Peaks: 3
+169.009374979909 100
+170.012729819909 4.32629131709289
+171.005171119909 4.47415517422887
+
+NAME: Fenhexamid (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C14H17Cl2N1O2
+charge: -1
+ionization_mode: negative
+precursor_mz: 300.056358144
+retention_time: 689.4
+Num Peaks: 7
+300.056357761909 100
+301.059712601909 15.1420196098251
+302.053407651909 63.9915522703273
+302.063067441909 1.0645178043701
+303.056762491909 9.68961339340446
+304.050457541909 10.2372969049151
+305.053812381909 1.55013350485826
+
+NAME: Fenvalerate free acid (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C11H13Cl1O2
+charge: -1
+ionization_mode: negative
+precursor_mz: 211.053131336
+retention_time: 585
+Num Peaks: 4
+211.053130913909 100
+212.056485753909 11.8973011220055
+213.050180803909 31.9957761351637
+214.053535643909 3.80663383312318
+
+NAME: Fipronil (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C12H4Cl2F6N4O1S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 434.931430428
+retention_time: 750
+Num Peaks: 9
+434.931429685909 100
+435.928464645909 1.4613192018949
+435.934784525909 12.9788739512787
+436.927225825909 4.47415517422887
+436.928479575909 63.9915522703273
+437.931834415909 8.3053829086324
+438.924275715909 2.86308134697222
+438.925529465909 10.2372969049151
+439.928884305909 1.32868586130708
+
+NAME: Fipronil sulfone (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C12H4Cl2F6N4O2S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 450.926345048
+retention_time: 771
+Num Peaks: 9
+450.926344305909 100
+451.923379265909 1.4613192018949
+451.929699145909 12.9788739512787
+452.922140445909 4.47415517422887
+452.923394195909 63.9915522703273
+453.926749035909 8.3053829086324
+454.919190335909 2.86308134697222
+454.920444085909 10.2372969049151
+455.923798925909 1.32868586130708
+
+NAME: Hydroxy-tebuconazole (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C16H22Cl1N3O2
+charge: -1
+ionization_mode: negative
+precursor_mz: 322.132778624
+retention_time: 696.6
+Num Peaks: 6
+322.132778231909 100
+323.129813191909 1.09598940142117
+323.136133071909 17.3051652683716
+324.129828121909 31.9957761351637
+324.139487911909 1.4037597420265
+325.133182961909 5.53692193908827
+
+NAME: Fluopyram (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C16H11Cl1F6N2O1
+charge: -1
+ionization_mode: negative
+precursor_mz: 395.039133972
+retention_time: 725.4
+Num Peaks: 5
+395.039133449909 100
+396.042488289909 17.3051652683716
+397.036183339909 31.9957761351637
+397.045843129909 1.4037597420265
+398.039538179909 5.53692193908827
+
+NAME: Mecoprop (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C10H11Cl1O3
+charge: -1
+ionization_mode: negative
+precursor_mz: 213.032395892
+retention_time: 544.8
+Num Peaks: 4
+213.032395469909 100
+214.035750309909 10.8157282927322
+215.029445359909 31.9957761351637
+216.032800199909 3.46057621193017
+
+NAME: p-Toluenesulfonamide (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C7H9N1O2S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 170.028123528
+retention_time: 362.4
+Num Peaks: 3
+170.028122815909 100
+171.031477655909 7.57100980491256
+172.023918955909 4.47415517422887
+
+NAME: Triclosan (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C12H7Cl3O2
+charge: -1
+ionization_mode: negative
+precursor_mz: 286.943886504
+retention_time: 811.8
+Num Peaks: 7
+286.943886141909 100
+287.947240981909 12.9788739512787
+288.940936031909 95.987328405491
+289.944290871909 12.4580743629486
+290.937985921909 30.7118907147453
+291.941340761909 3.98605758392125
+292.935035811909 3.27550259998867
+
+NAME: Triclosan glucuronide (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C18H15Cl3O8
+charge: -1
+ionization_mode: negative
+precursor_mz: 462.97597448
+retention_time: 665.4
+Num Peaks: 11
+462.975974117909 100
+463.979328957909 19.468310926918
+464.973024007909 95.987328405491
+464.980219897909 1.64399490762553
+464.982683797909 1.78979367108379
+465.976378847909 18.6871115444229
+466.970073897909 30.7118907147453
+466.977269787909 1.57802679095207
+466.979733687909 1.71797512884389
+467.973428737909 5.97908637588188
+468.967123787909 3.27550259998867
+
+NAME: Triclosan sulfate (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C12H7Cl3O5S1
+charge: -1
+ionization_mode: negative
+precursor_mz: 366.900701364
+retention_time: 695.4
+Num Peaks: 11
+366.900700731909 100
+367.904055571909 12.9788739512787
+368.896496871909 4.47415517422887
+368.897750621909 95.987328405491
+368.904946511909 1.02749681726596
+369.901105461909 12.4580743629486
+370.893546761909 4.29462202045833
+370.894800511909 30.7118907147453
+371.898155351909 3.98605758392125
+372.890596651909 1.37409764751729
+372.891850401909 3.27550259998867
+
+NAME: acetamiprid-N-desmethyl (M-H)
+msLevel: MS1
+PRECURSORTYPE: [M-H]-
+FORMULA: C9H9N4Cl1
+charge: -1
+ionization_mode: negative
+precursor_mz: 207.044297968
+retention_time: 402.6
+Num Peaks: 5
+207.044297585909 100
+208.041332545909 1.4613192018949
+208.047652425909 9.73415546345901
+209.041347475909 31.9957761351637
+210.044702315909 3.11451859073715
+