Mercurial > repos > galaxyp > maxquant
annotate mqparam.py @ 9:37d669de2828 draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 5e4f8567c0145de8c6f9344fe4ee4c3bf2a81e59"
author | galaxyp |
---|---|
date | Fri, 19 Feb 2021 21:24:41 +0000 |
parents | d253b379322b |
children |
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 |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
9 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
|
10 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
|
11 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
|
12 |
9
37d669de2828
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 5e4f8567c0145de8c6f9344fe4ee4c3bf2a81e59"
galaxyp
parents:
7
diff
changeset
|
13 import yaml |
37d669de2828
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 5e4f8567c0145de8c6f9344fe4ee4c3bf2a81e59"
galaxyp
parents:
7
diff
changeset
|
14 |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
15 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
16 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
|
17 "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
|
18 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
|
19 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
|
20 return child |
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 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
23 class ParamGroup: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
24 """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
|
25 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
26 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
27 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
|
28 """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
|
29 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
30 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
|
31 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
32 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
|
33 """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
|
34 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
39 node.clear() |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
44 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
|
45 """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
|
46 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
51 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
|
52 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
53 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
|
54 """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
|
55 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
72 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
|
73 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
|
74 """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
|
75 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
76 internalLabel: string |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
77 terminalLabel: string |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
84 None |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
85 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
95 |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
96 class MQParam: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
97 """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
|
98 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
|
99 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
100 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
101 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
|
102 """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
|
103 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
|
104 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 """ |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 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
|
115 # 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
|
116 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
|
117 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
|
118 self._paramGroups = [] |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
119 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
|
120 if yaml: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
121 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
|
122 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
123 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
|
124 """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
|
125 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
|
126 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
127 try: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
128 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
|
129 except TypeError: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
130 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
|
131 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
|
132 |
3
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
133 @staticmethod |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
134 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
|
135 """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
|
136 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
|
137 # '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
|
138 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
|
139 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
|
140 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
|
141 "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
|
142 "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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 try: |
175e062b6a17
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 74b5aa29e49deaaebe19ce2355a70d4f570f4951"
galaxyp
parents:
1
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
154 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
|
155 """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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
161 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
|
162 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
|
163 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
164 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
|
165 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 else: |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
174 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
|
175 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
|
176 index = [] |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
177 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
|
178 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
|
179 index.append(i) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
180 else: |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 e = 'False' |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
189 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
|
190 # 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
|
191 names = [] |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
192 names_to_paths = {} |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
193 # 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 # 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
|
200 # 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
|
201 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
|
202 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
|
203 else None) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
204 # 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
|
205 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
|
206 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
|
207 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
|
208 return design |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
209 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
210 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
|
211 """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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
218 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
|
219 parameter group. |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
220 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
221 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
222 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 '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
|
227 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
|
228 # 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
|
229 nodes = dict() |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 .format(nodename)) |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
235 nodes[nodename] = node |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
236 node.clear() |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
237 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
|
238 # 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
|
239 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
|
240 if 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['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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
252 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
|
253 """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
|
254 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
|
255 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
|
256 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
257 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
|
258 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
259 None |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
260 """ |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
261 # 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
|
262 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
|
263 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
|
264 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
|
265 filesNode.clear() |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
266 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
|
267 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
|
268 # 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 # 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
|
275 # 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
|
276 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
|
277 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
|
278 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
|
279 else: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
280 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
|
281 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
282 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
|
283 """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
|
284 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
285 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
|
286 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
|
287 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
288 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
289 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 |
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
298 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
|
299 """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
|
300 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
301 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
|
302 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
|
303 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
304 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
305 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
306 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
|
307 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
|
308 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
|
309 .format(key)) |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
310 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
|
311 |
6
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
312 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
|
313 """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
|
314 Args: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
315 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
|
316 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
|
317 Returns: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
318 None |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
319 """ |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 .format(key)) |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
324 node.clear() |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
325 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
|
326 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
|
327 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
|
328 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
329 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
|
330 """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
|
331 Args: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
332 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
|
333 Returns: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
334 None |
1
8bac3cc5c5de
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit ab4e4f1817080cbe8a031a82cb180610ff140847
galaxyp
parents:
diff
changeset
|
335 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
336 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
|
337 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
|
338 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 if silac: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 if fastafiles: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
357 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
|
358 else: |
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 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
|
363 else: |
2133b0be850a
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit 4e77eeda8a112fb50af00325a5164b986c16fc5c"
galaxyp
parents:
4
diff
changeset
|
364 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
|
365 |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
366 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
|
367 """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
|
368 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
|
369 """ |
4
dcd39bcc7481
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/maxquant commit da342a782ccc391b87fb4fead956b7b3cbd21258"
galaxyp
parents:
3
diff
changeset
|
370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 print(even_prettier, file=f) |