changeset 9:8dac4cef0a22 draft default tip

"planemo upload for repository https://github.com/computational-metabolomics/sirius_csifingerid_galaxy commit c2fc3de462ef4bd1a225c41624b094c3b5874736"
author computational-metabolomics
date Wed, 16 Feb 2022 16:11:55 +0000
parents 7b9c17738db8
children
files sirius_csifingerid.py sirius_csifingerid.xml
diffstat 2 files changed, 42 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/sirius_csifingerid.py	Fri Feb 11 10:05:21 2022 +0000
+++ b/sirius_csifingerid.py	Wed Feb 16 16:11:55 2022 +0000
@@ -14,6 +14,7 @@
 parser.add_argument('--input_pth')
 parser.add_argument('--canopus_result_pth')
 parser.add_argument('--annotations_result_pth')
+parser.add_argument('--all_structures_result_pth')
 parser.add_argument('--database')
 parser.add_argument('--profile')
 parser.add_argument('--candidates')
@@ -25,10 +26,9 @@
 parser.add_argument('--temp_dir')
 parser.add_argument('--meta_select_col', default='all')
 parser.add_argument('--cores_top_level', default=1)
+parser.add_argument('--cores_sirius', default=4)
 parser.add_argument('--chunks', default=1)
 parser.add_argument('--min_MSMS_peaks', default=1)
-parser.add_argument('--rank_filter', default=0)
-parser.add_argument('--confidence_filter', default=0)
 parser.add_argument('--schema', default='msp')
 parser.add_argument('-a', '--adducts', action='append', nargs=1,
                     required=False, default=[], help='Adducts used')
@@ -137,6 +137,7 @@
 def init_paramd(args):
     paramd = defaultdict()
     paramd["cli"] = {}
+    paramd["cli"]["--cores"] = args.cores_sirius
     paramd["cli"]["--database"] = args.database
     paramd["cli"]["--profile"] = args.profile
     paramd["cli"]["--candidates"] = args.candidates
@@ -216,9 +217,11 @@
         paramd['additional_details']['adduct'] = adduct
 
     # ============== Create CLI cmd for metfrag ===============================
-    cmd = "sirius --no-citations --ms2 {} --adduct {} --precursor {} -o {} " \
+    cmd = "sirius --cores {} --no-citations --ms2 {} --adduct {} " \
+          "--precursor {} -o {} " \
           "formula -c {} --ppm-max {} --profile {} " \
           "structure --database {} canopus".format(
+                       paramd["cli"]["--cores"],
                        paramd["cli"]["--ms2"],
                        adduct,
                        paramd["cli"]["--precursor"],
@@ -347,16 +350,18 @@
 # outputs might have different headers. Need to get a list of all the headers
 # before we start merging the files outfiles = [os.path.join(wd, f) for f in
 # glob.glob(os.path.join(wd, "*_metfrag_result.csv"))]
-def concat_output(filename, result_pth,
-                  rank_filter, confidence_filter):
-    outfiles = glob.glob(os.path.join(wd, '*', '*{}'.format(filename)))
+def concat_output(wd, filename, result_pth, level=2):
 
-    # sort files nicely
-    outfiles.sort(key=lambda s: int(re.match(r'^.*/('
-                                             r'\d+).*{}'.format(filename),
-                                             s).group(1)))
+    if level == 2:
+        outfiles = glob.glob(os.path.join(wd, '*', filename))
+    else:
+        outfiles = glob.glob(os.path.join(wd, '*', '*', filename))
+
+    outfiles.sort(
+        key=lambda s: int(
+            re.match(r'.*/([0-9]+).*/{}$'.format(filename),
+                     s).group(1)))
     print(outfiles)
-
     if len(outfiles) == 0:
         print('No results')
         sys.exit()
@@ -385,36 +390,24 @@
             with open(fn) as infile:
                 reader = csv.DictReader(infile, delimiter='\t')
 
-                ad = paramds[fn.split(os.sep)[-2]]['additional_details']
+                ad = paramds[fn.split(os.sep)[-level]]['additional_details']
 
                 for line in reader:
-                    if 'rank' in line \
-                            and 0 < int(rank_filter) < int(line['rank']):
-                        # filter out those annotations greater than rank filter
-                        # If rank_filter is zero then skip
-                        continue
 
-                    if 'ConfidenceScore' in line:
-                        if isinstance(line['ConfidenceScore'], str):
-                            # Value is NA or N/A
-                            continue
-
-                        if (0 < float(confidence_filter)
-                            and float(line['ConfidenceScore'])
-                                < float(confidence_filter)):
-                            # filter out those annotations that are less than
-                            # the confidence filter value
-                            continue
                     line.update(ad)
 
                     dwriter.writerow(line)
 
 
-concat_output('compound_identifications.tsv',
-              args.annotations_result_pth,
-              args.rank_filter,
-              args.confidence_filter)
-concat_output('canopus_summary.tsv',
-              args.canopus_result_pth,
-              0,
-              0)
+concat_output(wd,
+              'compound_identifications.tsv',
+              args.annotations_result_pth)
+
+concat_output(wd,
+              'canopus_summary.tsv',
+              args.canopus_result_pth)
+
+concat_output(wd,
+              'structure_candidates.tsv',
+              args.all_structures_result_pth,
+              level=3)
--- a/sirius_csifingerid.xml	Fri Feb 11 10:05:21 2022 +0000
+++ b/sirius_csifingerid.xml	Wed Feb 16 16:11:55 2022 +0000
@@ -1,5 +1,5 @@
 <tool id="sirius_csifingerid" name="SIRIUS-CSI:FingerID"
-      version="4.9.8+galaxy3" profile="19.05">
+      version="4.9.8+galaxy4" profile="19.05">
     <description>is used to identify metabolites using single and
         tandem mass spectrometry</description>
     <requirements>
@@ -8,7 +8,7 @@
     </requirements>
     <command detect_errors="exit_code">
     <![CDATA[
-
+        export _JAVA_OPTIONS=-Duser.home=$__new_file_path__ &&
         python '$__tool_directory__/sirius_csifingerid.py'
             --input_pth '$input'
             --database $database
@@ -19,7 +19,9 @@
             --out_dir $__new_file_path__
             --canopus_result_pth canopus_all_summary.tsv
             --annotations_result_pth annotations_all_summary.tsv
+            --all_structures_result_pth structures_all_summary.tsv
             --cores_top_level 1
+            --cores_sirius \${GALAXY_SLOTS:-4}
             --meta_select_col $meta_select_col
             --min_MSMS_peaks $min_MSMS_peaks
             --schema $schema
@@ -47,9 +49,6 @@
                  #end if
             #end if
 
-            --rank_filter $rank_filter
-
-            --confidence_filter $confidence_filter
 
 
     ]]></command>
@@ -136,13 +135,13 @@
             </when>
         </conditional>
 
-        <param argument="--rank_filter" type="integer" value="0"
-               label="Only show the top ranked annotations less than or equal
-                      to this value (default to show all annotations)"/>
+<!--        <param argument="&#45;&#45;rank_filter" type="integer" value="0"-->
+<!--               label="Only show the top ranked annotations less than or equal-->
+<!--                      to this value (default to show all annotations)"/>-->
 
-        <param argument="--confidence_filter" type="float" value="0"
-               label="Only show annotations greater than or or equal
-                      to this value (default to show all annotations)"/>
+<!--        <param argument="&#45;&#45;confidence_filter" type="float" value="0"-->
+<!--               label="Only show annotations greater than or or equal-->
+<!--                      to this value (default to show all annotations)"/>-->
 
     </inputs>
     <outputs>
@@ -150,6 +149,8 @@
               from_work_dir="canopus_all_summary.tsv"/>
         <data name="annotation_results" format="tsv" label="${tool.name} on ${on_string}: Annotations"
               from_work_dir="annotations_all_summary.tsv"/>
+        <data name="structure_results" format="tsv" label="${tool.name} on ${on_string}: All structures"
+              from_work_dir="structures_all_summary.tsv"/>
     </outputs>
     <tests>
         <test>
@@ -195,13 +196,7 @@
             <output name="annotation_results" file="annotation_RP022611_result_all_adducts.tsv"/>
             <output name="canopus_results" file="canopus_RP022611_result_all_adducts.tsv"/>
         </test>
-        <test>
-            <!-- Test confidence filter  -->
-            <param name="input" value="generic.msp" ftype="msp"/>
-            <param name="confidence_filter" value="0.7"/>
-            <output name="annotation_results" file="cf_annotation_generic_msp_result.tsv"/>
-            <output name="canopus_results" file="cf_canopus_generic_msp_result.tsv"/>
-        </test>
+
     </tests>
     <help>
 ----------------