changeset 3:175e062b6a17 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
author galaxyp
date Thu, 15 Aug 2019 08:09:00 -0400
parents 666f3453a99d
children dcd39bcc7481
files init.py maxquant.xml mqparam.py mqwrapper.py
diffstat 4 files changed, 51 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/init.py	Wed Aug 07 10:50:06 2019 -0400
+++ b/init.py	Thu Aug 15 08:09:00 2019 -0400
@@ -45,8 +45,7 @@
     standard_mods = []
     label_mods = []
     for m in mods:
-        if (m.findtext('type') == 'Standard'
-            or m.findtext('type') == 'AaSubstitution'):
+        if (m.findtext('type') == 'Standard' or m.findtext('type') == 'AaSubstitution'):
             standard_mods.append(m.get('title'))
         elif m.findtext('type') == 'Label':
             label_mods.append(m.get('title'))
--- a/maxquant.xml	Wed Aug 07 10:50:06 2019 -0400
+++ b/maxquant.xml	Thu Aug 15 08:09:00 2019 -0400
@@ -1,4 +1,4 @@
-<tool id="maxquant" name="MaxQuant" version="@VERSION@">
+<tool id="maxquant" name="MaxQuant" version="@VERSION@+galaxy1">
     <macros>
         <import>macros.xml</import>
     </macros>
@@ -310,17 +310,29 @@
 - Thermo raw file or mzXML file
     - The datatype has to be 'thermo.raw' or 'mzXML'. Make sure to specify the correct datatype either during upload to Galaxy or afterwards (edit attributes --> datatypes)
 - Optional files:
-    - Tabular file with experimental design template: 
-        - Currently four columns are needed: Name, Fraction, Experiment and PTM. The headers must have this exact naming. Name and Fraction are abitrary strings, Experiment is an integer, PTM is either True or False.
+    - Tabular file with experimental design template:
+        - Currently four columns are needed: Name, Fraction, Experiment and PTM. The headers must have this exact naming. Name and Experiment are abitrary strings, Fraction is an integer or emtpy, PTM is either 'True', 'False' or empty. Consider you uploaded files named File1.mzxml, ..., File5.mzxml. This is a (syntactically) correct experimental design template:
 
                 ::
 
                     Name     Fraction    Experiment   PTM
                     File1        1          E1       False
                     File2        2          E1       False
+                    ghost       234        none
                     File3        3          E1       False
-                    ...
-                    ...
+                    File4                   E2       true
+                    File5                   E1
+
+        - This is the counter-example with one error per line:
+
+                ::
+
+                    Name     Fraction    Experiment   PTM
+                    File1       1           E1        no  (wrong PTM value)
+                    File2.mzxml 1           E2            (filename with extension)
+                    File3       f3          E1            (fraction not an integer)
+                    File4       1                         (missing experiment)
+                                                          (File5 misssing)
 
 **Parameter Options**
 
--- a/mqparam.py	Wed Aug 07 10:50:06 2019 -0400
+++ b/mqparam.py	Thu Aug 15 08:09:00 2019 -0400
@@ -65,6 +65,27 @@
         child = ET.SubElement(el, name, attrib=attrib if attrib else {})
         child.text = str(text)
 
+    @staticmethod
+    def _check_validity(design, len_infiles):
+        "Perform some checks on the exp. design template"
+        design_len = len(design['Name'])
+        match = len(list(filter(lambda x: bool(x), design['Name'])))
+        if match < len_infiles:
+            raise Exception("Error parsing experimental design template: " +
+                            "Found only {} matching entries ".format(design_len) +
+                            "for {} input files".format(len_infiles))
+        for i in range(0, design_len):
+            msg = "Error in line " + str(i + 2) + " of experimental design: "
+            if not (design['Name'][i] and design['Experiment'][i]):
+                raise Exception(msg + " Name or Experiment is empty.")
+            if design['PTM'][i].lower() not in ('true', 'false'):
+                raise Exception(msg + "Defines invalid PTM value, " +
+                                "should be 'True' or 'False'.")
+            try:
+                int(design['Fraction'][i])
+            except ValueError as e:
+                raise Exception(msg + str(e))
+
     def _make_exp_design(self, infiles):
         """Create a dict representing an experimental design from
         an experimental design template and a list of input files.
@@ -80,6 +101,7 @@
         >>> design['Fraction']
         ['1', '2']
         """
+
         design = {s: [] for s in ("Name", "PTM", "Fraction", "Experiment")}
         if not self.exp_design:
             design["Name"] = infiles
@@ -94,11 +116,16 @@
                     if i in design:
                         index.append(i)
                     else:
-                        raise Exception("Invalid comlumn index in experimental"
+                        raise Exception("Invalid column index in experimental"
                                         + " design template: {}".format(i))
+
                 for line in design_file:
                     row = line.strip().split('\t')
                     for e, i in zip_longest(row, index):
+                        if i == "Fraction" and e == '':
+                            e = 32767
+                        elif i == "PTM" and not e:
+                            e = 'False'
                         design[i].append(e)
 
             # map infiles to names in exp. design template
@@ -117,6 +144,7 @@
                              else None)
             # replace orig. file names with matching links to galaxy datasets
             design['Name'] = names
+            MQParam._check_validity(design, len(infiles))
 
         return design
 
@@ -223,6 +251,8 @@
 
         for index in range(len(files)):
             filepath = '<fastaFilePath>' + files[index]
+            identifier = identifier.replace('<', '&lt;')
+            description = description.replace('<', '&lt;')
             fasta = self.fasta_template.replace('<fastaFilePath>', filepath)
             fasta = fasta.replace('<identifierParseRule>',
                                   '<identifierParseRule>' + identifier)
--- a/mqwrapper.py	Wed Aug 07 10:50:06 2019 -0400
+++ b/mqwrapper.py	Thu Aug 15 08:09:00 2019 -0400
@@ -35,7 +35,7 @@
               'summary')
 
 # arguments for mqparam
-## global
+# global
 global_flags = ('calc_peak_properties',
                 'write_mztab',
                 'ibaq',
@@ -51,7 +51,7 @@
                       'min_peptide_len',
                       'max_peptide_mass')
 
-## parameter group specific
+# parameter group specific
 param_group_flags = ('lfq_skip_norm',)
 
 param_group_simple_args = ('missed_cleavages',