Mercurial > repos > galaxyp > maxquant
diff mqparam.py @ 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 | 8bac3cc5c5de |
children | dcd39bcc7481 |
line wrap: on
line diff
--- 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('<', '<') + description = description.replace('<', '<') fasta = self.fasta_template.replace('<fastaFilePath>', filepath) fasta = fasta.replace('<identifierParseRule>', '<identifierParseRule>' + identifier)