Mercurial > repos > galaxyp > maxquant
annotate mqparam.py @ 8:ea0a1d50c83f draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 72cbf6fcc4930abe5da8e895a2b35951a63e881a"
author | galaxyp |
---|---|
date | Wed, 03 Jun 2020 15:32:53 -0400 |
parents | d253b379322b |
children | 37d669de2828 |
rev | line source |
---|---|
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
1 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
2 Create a project-specific MaxQuant parameter file. |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
3 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
4 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
5 import copy |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
6 import ntpath |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
7 import os |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
8 import re |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
9 import yaml |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
10 import xml.etree.ElementTree as ET |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
11 from itertools import zip_longest |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
12 from xml.dom import minidom |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
13 |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
14 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
15 def et_add_child(el, name, text, attrib=None): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
16 "Add a child element to an xml.etree.ElementTree.Element" |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
17 child = ET.SubElement(el, name, attrib=attrib if attrib else {}) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
18 child.text = str(text) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
19 return child |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
20 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
21 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
22 class ParamGroup: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
23 """Represents one parameter Group |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
24 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
25 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
26 def __init__(self, root): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
27 """Initialize with its xml.etree.ElementTree root Element. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
28 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
29 self._root = copy.deepcopy(root) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
30 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
31 def set_list_param(self, key, vals): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
32 """Set a list parameter. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
33 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
34 node = self._root.find(key) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
35 if node is None: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
36 raise ValueError('Element {} not found in parameter file' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
37 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
38 node.clear() |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
39 node.tag = key |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
40 for e in vals: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
41 et_add_child(node, name='string', text=e) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
42 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
43 def set_simple_param(self, key, value): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
44 """Set a simple parameter. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
45 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
46 node = self._root.find(key) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
47 if node is None: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
48 raise ValueError('Element {} not found in parameter file' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
49 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
50 node.text = str(value) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
51 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
52 def set_silac(self, light_labels, medium_labels, heavy_labels): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
53 """Set label modifications. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
54 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
55 if medium_labels and not (heavy_labels or light_labels): # medium omly with heavy and light |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
56 raise Exception("Incorrect SILAC specification. Use medium only together with light and heavy labels.") |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
57 multiplicity = 3 if medium_labels else 2 if heavy_labels else 1 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
58 max_label = str(max(len(light_labels) if light_labels else 0, |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
59 len(medium_labels) if medium_labels else 0, |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
60 len(heavy_labels) if heavy_labels else 0)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
61 self._root.find('multiplicity').text = str(multiplicity) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
62 self._root.find('maxLabeledAa').text = max_label |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
63 node = self._root.find('labelMods') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
64 node[0].text = ';'.join(light_labels) if light_labels else '' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
65 if multiplicity == 3: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
66 et_add_child(node, name='string', text=';'.join(medium_labels)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
67 if multiplicity > 1: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
68 et_add_child(node, name='string', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
69 text=';'.join(heavy_labels) if heavy_labels else '') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
70 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
71 def set_isobaric_label(self, internalLabel, terminalLabel, |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
72 cm2, cm1, cp1, cp2, tmtLike): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
73 """Add isobaric label info. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
74 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
75 internalLabel: string |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
76 terminalLabel: string |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
77 cm2: (float) correction factor |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
78 cm1: (float) correction factor |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
79 cp1: (float) correction factor |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
80 cp2: (float) correction factor |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
81 tmtLike: bool or string |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
82 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
83 None |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
84 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
85 iso_labels_node = self._root.find('isobaricLabels') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
86 label = et_add_child(iso_labels_node, 'IsobaricLabelInfo', '') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
87 et_add_child(label, 'internalLabel', internalLabel) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
88 et_add_child(label, 'terminalLabel', terminalLabel) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
89 for num, factor in (('M2', cm2), ('M1', cm1), ('P1', cp1), ('P2', cp2)): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
90 et_add_child(label, 'correctionFactor' + num, |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
91 str(float(factor) if factor % 1 else int(factor))) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
92 et_add_child(label, 'tmtLike', str(tmtLike)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
93 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
94 |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
95 class MQParam: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
96 """Represents a mqpar.xml and provides methods to modify |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
97 some of its parameters. |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
98 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
99 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
100 def __init__(self, mqpar_in, exp_design=None, yaml=None, substitution_rx=r'[^\s\S]'): # no sub by default |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
101 """Initialize MQParam class. mqpar_in can either be a template |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
102 or a already suitable mqpar file. |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
103 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
104 mqpar_in: a template parameter file |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
105 exp_design: a experimental design template (see MaxQuant documentation), |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
106 can be None |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
107 substitution_rx: a regular expression for replacements in the file names. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
108 It is applied before comparing input file names (e.g. from the exp. design) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
109 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
110 self.orig_mqpar = mqpar_in |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
111 self.exp_design = exp_design |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
112 self._root = ET.parse(mqpar_in).getroot() |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
113 self.version = self._root.find('maxQuantVersion').text |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
114 # regex for substitution of certain file name characters |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
115 self.substitution_rx = substitution_rx |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
116 self.pg_node = copy.deepcopy(self._root.find('parameterGroups')[0]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
117 self._paramGroups = [] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
118 self.fasta_file_node = copy.deepcopy(self._root.find('fastaFiles')[0]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
119 if yaml: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
120 self._from_yaml(yaml) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
121 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
122 def __getitem__(self, index): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
123 """Return paramGroup if indexed with integer, else try to find |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
124 matching Element in XML root and return its text or None. |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
125 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
126 try: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
127 return self._paramGroups[index] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
128 except TypeError: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
129 ret = self._root.find(index) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
130 return ret.text if ret is not None else None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
131 |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
132 @staticmethod |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
133 def _check_validity(design, len_infiles): |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
134 """Perform some checks on the exp. design template""" |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
135 design_len = len(design['Name']) |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
136 # 'Name' can be None, we need at least len_infiles valid entries |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
137 match = len(list(filter(lambda x: bool(x), design['Name']))) |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
138 if match < len_infiles: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
139 raise Exception(' '.join(["Error parsing experimental design template:", |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
140 "Found only {} matching entries".format(match), |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
141 "for {} input files".format(len_infiles)])) |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
142 for i in range(0, design_len): |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
143 msg = "(in line " + str(i + 2) + " of experimental design) " |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
144 if not design['Experiment'][i]: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
145 raise ValueError(msg + " Experiment is empty.") |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
146 if design['PTM'][i].lower() not in ('true', 'false'): |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
147 raise ValueError(msg + "Defines invalid PTM value, should be 'True' or 'False'.") |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
148 try: |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
149 int(design['Fraction'][i]) |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
150 except ValueError as e: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
151 raise ValueError(msg + str(e)) |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
152 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
153 def _make_exp_design(self, groups, files): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
154 """Create a dict representing an experimental design from an |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
155 experimental design template and a list input files. |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
156 If the experimental design template is None, create a default |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
157 design with one experiment for each input file and no fractions |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
158 for all files. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
159 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
160 files: list of input file paths |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
161 groups: list of parameter group indices |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
162 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
163 dict: The (complete) experimental design template |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
164 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
165 design = {s: [] for s in ("Name", "PTM", "Fraction", "Experiment", "paramGroup")} |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
166 if not self.exp_design: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
167 design["Name"] = files |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
168 design["Fraction"] = ('32767',) * len(files) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
169 design["Experiment"] = [os.path.split(f)[1] for f in files] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
170 design["PTM"] = ('False',) * len(files) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
171 design["paramGroup"] = groups |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
172 else: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
173 with open(self.exp_design) as design_file: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
174 index_line = design_file.readline().strip() |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
175 index = [] |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
176 for i in index_line.split('\t'): |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
177 if i in design: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
178 index.append(i) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
179 else: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
180 raise Exception("Invalid column index in experimental design template: {}".format(i)) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
181 for line in design_file: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
182 row = line.strip().split('\t') |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
183 for e, i in zip_longest(row, index): |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
184 if i == "Fraction" and not e: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
185 e = '32767' |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
186 elif i == "PTM" and not e: |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
187 e = 'False' |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
188 design[i].append(e) |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
189 # map files to names in exp. design template |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
190 names = [] |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
191 names_to_paths = {} |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
192 # strip path and extension |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
193 for f in files: |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
194 b = os.path.basename(f) |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
195 basename = b[:-11] if b.lower().endswith('.thermo.raw') else b.rsplit('.', maxsplit=1)[0] |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
196 names_to_paths[basename] = f |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
197 for name in design['Name']: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
198 # same substitution as in maxquant.xml, |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
199 # when passing the element identifiers |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
200 fname = re.sub(self.substitution_rx, '_', name) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
201 names.append(names_to_paths[fname] if fname in names_to_paths |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
202 else None) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
203 # replace orig. file names with matching links to galaxy datasets |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
204 design['Name'] = names |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
205 design['paramGroup'] = groups |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
206 MQParam._check_validity(design, len(files)) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
207 return design |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
208 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
209 def add_infiles(self, infiles): |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
210 """Add a list of raw/mzxml files to the mqpar.xml. |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
211 If experimental design template was specified, |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
212 modify other parameters accordingly. |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
213 The files must be specified as absolute paths |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
214 for maxquant to find them. |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
215 Also add parameter Groups. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
216 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
217 infiles: a list of infile lists. first dimension denotes the |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
218 parameter group. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
219 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
220 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
221 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
222 groups, files = zip(*[(num, f) for num, l in enumerate(infiles) for f in l]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
223 self._paramGroups = [ParamGroup(self.pg_node) for i in range(len(infiles))] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
224 nodenames = ('filePaths', 'experiments', 'fractions', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
225 'ptms', 'paramGroupIndices', 'referenceChannel') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
226 design = self._make_exp_design(groups, files) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
227 # Get parent nodes from document |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
228 nodes = dict() |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
229 for nodename in nodenames: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
230 node = self._root.find(nodename) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
231 if node is None: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
232 raise ValueError('Element {} not found in parameter file' |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
233 .format(nodename)) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
234 nodes[nodename] = node |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
235 node.clear() |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
236 node.tag = nodename |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
237 # Append sub-elements to nodes (one per file) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
238 for i, name in enumerate(design['Name']): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
239 if name: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
240 et_add_child(nodes['filePaths'], 'string', name) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
241 et_add_child(nodes['experiments'], 'string', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
242 design['Experiment'][i]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
243 et_add_child(nodes['fractions'], 'short', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
244 design['Fraction'][i]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
245 et_add_child(nodes['ptms'], 'boolean', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
246 design['PTM'][i]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
247 et_add_child(nodes['paramGroupIndices'], 'int', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
248 design['paramGroup'][i]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
249 et_add_child(nodes['referenceChannel'], 'string', '') |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
250 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
251 def translate(self, infiles): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
252 """Map a list of given infiles to the files specified in the parameter file. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
253 Needed for the mqpar upload in galaxy. Removes the path and then tries |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
254 to match the files. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
255 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
256 infiles: list or tuple of the input |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
257 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
258 None |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
259 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
260 # kind of a BUG: fails if filename starts with '.' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
261 infilenames = [os.path.basename(f).split('.')[0] for f in infiles] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
262 filesNode = self._root.find('filePaths') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
263 files_from_mqpar = [e.text for e in filesNode] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
264 filesNode.clear() |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
265 filesNode.tag = 'filePaths' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
266 for f in files_from_mqpar: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
267 # either windows or posix path |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
268 win = ntpath.basename(f) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
269 posix = os.path.basename(f) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
270 basename = win if len(win) < len(posix) else posix |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
271 basename_with_sub = re.sub(self.substitution_rx, '_', |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
272 basename.split('.')[0]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
273 # match infiles to their names in mqpar.xml, |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
274 # ignore files missing in mqpar.xml |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
275 if basename_with_sub in infilenames: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
276 i = infilenames.index(basename_with_sub) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
277 et_add_child(filesNode, 'string', infiles[i]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
278 else: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
279 raise ValueError("no matching infile found for " + f) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
280 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
281 def add_fasta_files(self, files, parse_rules={}): |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
282 """Add fasta file groups. |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
283 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
284 files: (list) of fasta file paths |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
285 parseRules: (dict) the parse rules as (tag, text)-pairs |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
286 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
287 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
288 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
289 fasta_node = self._root.find('fastaFiles') |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
290 fasta_node.clear() |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
291 for f in files: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
292 fasta_node.append(copy.deepcopy(self.fasta_file_node)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
293 fasta_node[-1].find('fastaFilePath').text = f |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
294 for rule in parse_rules: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
295 fasta_node[-1].find(rule).text = parse_rules[rule] |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
296 |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
297 def set_simple_param(self, key, value): |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
298 """Set a simple parameter. |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
299 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
300 key: (string) XML tag of the parameter |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
301 value: the text of the parameter XML node |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
302 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
303 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
304 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
305 node = self._root.find(key) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
306 if node is None: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
307 raise ValueError('Element {} not found in parameter file' |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
308 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
309 node.text = str(value) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
310 |
6
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
311 def set_list_param(self, key, values): |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
312 """Set a list parameter. |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
313 Args: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
314 key: (string) XML tag of the parameter |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
315 values: the lit of values of the parameter XML node |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
316 Returns: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
317 None |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
318 """ |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
319 node = self._root.find(key) |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
320 if node is None: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
321 raise ValueError('Element {} not found in parameter file' |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
322 .format(key)) |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
323 node.clear() |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
324 node.tag = key |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
325 for e in values: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
326 et_add_child(node, name='string', text=e) |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
327 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
328 def _from_yaml(self, conf): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
329 """Read a yaml config file. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
330 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
331 conf: (string) path to the yaml conf file |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
332 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
333 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
334 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
335 with open(conf) as f: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
336 conf_dict = yaml.safe_load(f.read()) |
6
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
337 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
338 paramGroups = conf_dict.pop('paramGroups') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
339 self.add_infiles([pg.pop('files') for pg in paramGroups]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
340 for i, pg in enumerate(paramGroups): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
341 silac = pg.pop('labelMods', False) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
342 if silac: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
343 self[i].set_silac(*silac) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
344 isobaricLabels = pg.pop('isobaricLabels', False) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
345 if isobaricLabels: |
7
d253b379322b
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit f63ff6d5d0c44012a17e87293811765951655bd5"
galaxyp
parents:
6
diff
changeset
|
346 for ibl in isobaricLabels: |
d253b379322b
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit f63ff6d5d0c44012a17e87293811765951655bd5"
galaxyp
parents:
6
diff
changeset
|
347 self[i].set_isobaric_label(*ibl) |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
348 for el in ['fixedModifications', 'variableModifications', 'enzymes']: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
349 lst = pg.pop(el, None) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
350 if lst is not None: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
351 self[i].set_list_param(el, lst) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
352 for key in pg: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
353 self[i].set_simple_param(key, pg[key]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
354 fastafiles = conf_dict.pop('fastaFiles', False) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
355 if fastafiles: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
356 self.add_fasta_files(fastafiles, parse_rules=conf_dict.pop('parseRules', {})) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
357 else: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
358 raise Exception('No fasta files provided.') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
359 for key in conf_dict: |
6
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
360 if key in ['restrictMods']: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
361 self.set_list_param(key, conf_dict[key]) |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
362 else: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
363 self.set_simple_param(key, conf_dict[key]) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
364 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
365 def write(self, mqpar_out): |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
366 """Write pretty formatted xml parameter file. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
367 Compose it from global parameters and parameter Groups. |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
368 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
369 if self._paramGroups: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
370 pg_node = self._root.find('parameterGroups') |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
371 pg_node.remove(pg_node[0]) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
372 for group in self._paramGroups: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
373 pg_node.append(group._root) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
374 rough_string = ET.tostring(self._root, 'utf-8', short_empty_elements=False) |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
375 reparsed = minidom.parseString(rough_string) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
376 pretty = reparsed.toprettyxml(indent="\t") |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
377 even_prettier = re.sub(r"\n\s+\n", r"\n", pretty) |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
378 with open(mqpar_out, 'w') as f: |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
379 print(even_prettier, file=f) |