annotate maxquant_wrapper.py @ 0:d4b6c9eae635 draft

Initial commit.
author galaxyp
date Fri, 10 May 2013 17:22:51 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
1 #!/usr/bin/env python
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
2 import optparse
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
3 import os
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
4 import shutil
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
5 import sys
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
6 import tempfile
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
7 import subprocess
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
8 import logging
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
9 from string import Template
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
10 from xml.sax.saxutils import escape
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
11 import xml.etree.ElementTree as ET
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
12
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
13 log = logging.getLogger(__name__)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
14
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
15 DEBUG = True
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
16
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
17 working_directory = os.getcwd()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
18 tmp_stderr_name = tempfile.NamedTemporaryFile(dir=working_directory, suffix='.stderr').name
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
19 tmp_stdout_name = tempfile.NamedTemporaryFile(dir=working_directory, suffix='.stdout').name
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
20
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
21
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
22 def stop_err(msg):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
23 sys.stderr.write("%s\n" % msg)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
24 sys.exit()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
25
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
26
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
27 def read_stderr():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
28 stderr = ''
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
29 if(os.path.exists(tmp_stderr_name)):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
30 with open(tmp_stderr_name, 'rb') as tmp_stderr:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
31 buffsize = 1048576
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
32 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
33 while True:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
34 stderr += tmp_stderr.read(buffsize)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
35 if not stderr or len(stderr) % buffsize != 0:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
36 break
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
37 except OverflowError:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
38 pass
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
39 return stderr
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
40
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
41
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
42 def execute(command, stdin=None):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
43 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
44 with open(tmp_stderr_name, 'wb') as tmp_stderr:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
45 with open(tmp_stdout_name, 'wb') as tmp_stdout:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
46 proc = subprocess.Popen(args=command, shell=True, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno(), stdin=stdin, env=os.environ)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
47 returncode = proc.wait()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
48 if returncode != 0:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
49 raise Exception("Program returned with non-zero exit code %d. stderr: %s" % (returncode, read_stderr()))
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
50 finally:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
51 print open(tmp_stderr_name, "r").read(64000)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
52 print open(tmp_stdout_name, "r").read(64000)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
53
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
54
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
55 def delete_file(path):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
56 if os.path.exists(path):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
57 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
58 os.remove(path)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
59 except:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
60 pass
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
61
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
62
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
63 def delete_directory(directory):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
64 if os.path.exists(directory):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
65 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
66 shutil.rmtree(directory)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
67 except:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
68 pass
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
69
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
70
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
71 def symlink(source, link_name):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
72 import platform
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
73 if platform.system() == 'Windows':
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
74 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
75 import win32file
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
76 win32file.CreateSymbolicLink(source, link_name, 1)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
77 except:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
78 shutil.copy(source, link_name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
79 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
80 os.symlink(source, link_name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
81
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
82
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
83 def copy_to_working_directory(data_file, relative_path):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
84 if os.path.abspath(data_file) != os.path.abspath(relative_path):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
85 shutil.copy(data_file, relative_path)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
86 return relative_path
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
87
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
88
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
89 def __main__():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
90 run_script()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
91
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
92
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
93 ## Lock File Stuff
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
94 ## http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
95 import os
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
96 import time
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
97 import errno
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
98
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
99
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
100 class FileLockException(Exception):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
101 pass
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
102
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
103
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
104 class FileLock(object):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
105 """ A file locking mechanism that has context-manager support so
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
106 you can use it in a with statement. This should be relatively cross
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
107 compatible as it doesn't rely on msvcrt or fcntl for the locking.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
108 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
109
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
110 def __init__(self, file_name, timeout=10, delay=.05):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
111 """ Prepare the file locker. Specify the file to lock and optionally
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
112 the maximum timeout and the delay between each attempt to lock.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
113 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
114 self.is_locked = False
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
115 self.lockfile = os.path.join(os.getcwd(), "%s.lock" % file_name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
116 self.file_name = file_name
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
117 self.timeout = timeout
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
118 self.delay = delay
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
119
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
120 def acquire(self):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
121 """ Acquire the lock, if possible. If the lock is in use, it check again
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
122 every `wait` seconds. It does this until it either gets the lock or
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
123 exceeds `timeout` number of seconds, in which case it throws
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
124 an exception.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
125 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
126 start_time = time.time()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
127 while True:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
128 try:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
129 self.fd = os.open(self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
130 break
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
131 except OSError as e:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
132 if e.errno != errno.EEXIST:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
133 raise
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
134 if (time.time() - start_time) >= self.timeout:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
135 raise FileLockException("Timeout occured.")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
136 time.sleep(self.delay)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
137 self.is_locked = True
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
138
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
139 def release(self):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
140 """ Get rid of the lock by deleting the lockfile.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
141 When working in a `with` statement, this gets automatically
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
142 called at the end.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
143 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
144 if self.is_locked:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
145 os.close(self.fd)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
146 os.unlink(self.lockfile)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
147 self.is_locked = False
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
148
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
149 def __enter__(self):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
150 """ Activated when used in the with statement.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
151 Should automatically acquire a lock to be used in the with block.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
152 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
153 if not self.is_locked:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
154 self.acquire()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
155 return self
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
156
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
157 def __exit__(self, type, value, traceback):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
158 """ Activated at the end of the with statement.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
159 It automatically releases the lock if it isn't locked.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
160 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
161 if self.is_locked:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
162 self.release()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
163
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
164 def __del__(self):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
165 """ Make sure that the FileLock instance doesn't leave a lockfile
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
166 lying around.
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
167 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
168 self.release()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
169
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
170 TEMPLATE = """<?xml version="1.0" encoding="utf-8"?>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
171 <MaxQuantParams xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" runOnCluster="false" processFolder="$process_folder">
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
172 $raw_file_info
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
173 <experimentalDesignFilename/>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
174 <slicePeaks>$slice_peaks</slicePeaks>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
175 <tempFolder/>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
176 <ncores>$num_cores</ncores>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
177 <ionCountIntensities>false</ionCountIntensities>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
178 <maxFeatureDetectionCores>1</maxFeatureDetectionCores>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
179 <verboseColumnHeaders>false</verboseColumnHeaders>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
180 <minTime>NaN</minTime>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
181 <maxTime>NaN</maxTime>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
182 <calcPeakProperties>$calc_peak_properties</calcPeakProperties>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
183 <useOriginalPrecursorMz>$use_original_precursor_mz</useOriginalPrecursorMz>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
184 $fixed_mods
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
185 <multiModificationSearch>$multi_modification_search</multiModificationSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
186 <fastaFiles>$database</fastaFiles>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
187 <fastaFilesFirstSearch/>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
188 <fixedSearchFolder/>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
189 <advancedRatios>$advanced_ratios</advancedRatios>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
190 <rtShift>$rt_shift</rtShift>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
191 <fastLfq>$fast_lfq</fastLfq>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
192 <randomize>$randomize</randomize>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
193 <specialAas>$special_aas</specialAas>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
194 <includeContamiants>$include_contamiants</includeContamiants>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
195 <equalIl>$equal_il</equalIl>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
196 <topxWindow>100</topxWindow>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
197 <maxPeptideMass>$max_peptide_mass</maxPeptideMass>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
198 <reporterPif>$reporter_pif</reporterPif>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
199 <reporterFraction>$reporter_fraction</reporterFraction>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
200 <reporterBasePeakRatio>$reporter_base_peak_ratio</reporterBasePeakRatio>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
201 <scoreThreshold>$score_threshold</scoreThreshold>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
202 <filterAacounts>$filter_aacounts</filterAacounts>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
203 <secondPeptide>$second_peptide</secondPeptide>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
204 <matchBetweenRuns>$match_between_runs</matchBetweenRuns>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
205 <matchBetweenRunsFdr>$match_between_runs_fdr</matchBetweenRunsFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
206 <reQuantify>$re_quantify</reQuantify>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
207 <dependentPeptides>$dependent_peptides</dependentPeptides>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
208 <dependentPeptideFdr>$dependent_peptide_fdr</dependentPeptideFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
209 <dependentPeptideMassBin>$dependent_peptide_mass_bin</dependentPeptideMassBin>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
210 <labelFree>$label_free</labelFree>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
211 <lfqMinEdgesPerNode>$lfq_min_edges_per_node</lfqMinEdgesPerNode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
212 <lfqAvEdgesPerNode>$lfq_av_edges_per_node</lfqAvEdgesPerNode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
213 <hybridQuantification>$hybrid_quantification</hybridQuantification>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
214 <msmsConnection>$msms_connection</msmsConnection>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
215 <ibaq>$ibaq</ibaq>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
216 <msmsRecalibration>$msms_recalibration</msmsRecalibration>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
217 <ibaqLogFit>$ibaq_log_fit</ibaqLogFit>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
218 <razorProteinFdr>$razor_protein_fdr</razorProteinFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
219 <calcSequenceTags>$calc_sequence_tags</calcSequenceTags>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
220 <deNovoVarMods>$de_novo_var_mods</deNovoVarMods>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
221 <massDifferenceSearch>$mass_difference_search</massDifferenceSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
222 <minPepLen>$min_pep_len</minPepLen>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
223 <peptideFdr>$peptide_fdr</peptideFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
224 <peptidePep>$peptide_pep</peptidePep>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
225 <proteinFdr>$protein_fdr</proteinFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
226 <siteFdr>$site_fdr</siteFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
227 <minPeptideLengthForUnspecificSearch>$min_peptide_length_for_unspecific_search</minPeptideLengthForUnspecificSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
228 <maxPeptideLengthForUnspecificSearch>$max_peptide_length_for_unspecific_search</maxPeptideLengthForUnspecificSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
229 <useNormRatiosForOccupancy>$use_norm_ratios_for_occupancy</useNormRatiosForOccupancy>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
230 <minPeptides>$min_peptides</minPeptides>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
231 <minRazorPeptides>$min_razor_peptides</minRazorPeptides>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
232 <minUniquePeptides>$min_unique_peptides</minUniquePeptides>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
233 <useCounterparts>$use_counterparts</useCounterparts>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
234 <minRatioCount>$min_ratio_count</minRatioCount>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
235 <lfqMinRatioCount>$lfq_min_ratio_count</lfqMinRatioCount>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
236 <restrictProteinQuantification>$restrict_protein_quantification</restrictProteinQuantification>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
237 $restrict_mods
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
238 <matchingTimeWindow>$matching_time_window</matchingTimeWindow>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
239 <numberOfCandidatesMultiplexedMsms>$number_of_candidates_multiplexed_msms</numberOfCandidatesMultiplexedMsms>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
240 <numberOfCandidatesMsms>$number_of_candidates_msms</numberOfCandidatesMsms>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
241 <separateAasForSiteFdr>$separate_aas_for_site_fdr</separateAasForSiteFdr>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
242 <massDifferenceMods />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
243 <aifParams aifSilWeight="$aif_sil_weight"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
244 aifIsoWeight="$aif_iso_weight"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
245 aifTopx="$aif_topx"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
246 aifCorrelation="$aif_correlation"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
247 aifCorrelationFirstPass="$aif_correlation_first_pass"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
248 aifMinMass="$aif_min_mass"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
249 aifMsmsTol="$aif_msms_tol"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
250 aifSecondPass="$aif_second_pass"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
251 aifIterative="$aif_iterative"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
252 aifThresholdFdr="$aif_threhold_fdr" />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
253 <groups>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
254 <ParameterGroups>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
255 $group_params
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
256 </ParameterGroups>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
257 </groups>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
258 <qcSettings>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
259 <qcSetting xsi:nil="true" />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
260 </qcSettings>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
261 <msmsParams>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
262 $ftms_fragment_settings
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
263 $itms_fragment_settings
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
264 $tof_fragment_settings
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
265 $unknown_fragment_settings
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
266 </msmsParams>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
267 <keepLowScoresMode>$keep_low_scores_mode</keepLowScoresMode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
268 <msmsCentroidMode>$msms_centroid_mode</msmsCentroidMode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
269 <quantMode>$quant_mode</quantMode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
270 <siteQuantMode>$site_quant_mode</siteQuantMode>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
271 <groupParams>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
272 <groupParam>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
273 $group_params
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
274 </groupParam>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
275 </groupParams>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
276 </MaxQuantParams>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
277 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
278
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
279 GROUP_TEMPLATE = """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
280 <maxCharge>$max_charge</maxCharge>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
281 <lcmsRunType>$lcms_run_type</lcmsRunType>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
282 <msInstrument>$ms_instrument</msInstrument>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
283 <groupIndex>$group_index</groupIndex>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
284 <maxLabeledAa>$max_labeled_aa</maxLabeledAa>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
285 <maxNmods>$max_n_mods</maxNmods>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
286 <maxMissedCleavages>$max_missed_cleavages</maxMissedCleavages>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
287 <multiplicity>$multiplicity</multiplicity>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
288 <protease>$protease</protease>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
289 <proteaseFirstSearch>$protease</proteaseFirstSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
290 <useProteaseFirstSearch>false</useProteaseFirstSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
291 <useVariableModificationsFirstSearch>false</useVariableModificationsFirstSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
292 $variable_mods
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
293 $isobaric_labels
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
294 <variableModificationsFirstSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
295 <string>Oxidation (M)</string>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
296 <string>Acetyl (Protein N-term)</string>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
297 </variableModificationsFirstSearch>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
298 <hasAdditionalVariableModifications>false</hasAdditionalVariableModifications>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
299 <additionalVariableModifications>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
300 <ArrayOfString />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
301 </additionalVariableModifications>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
302 <additionalVariableModificationProteins>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
303 <ArrayOfString />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
304 </additionalVariableModificationProteins>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
305 <doMassFiltering>$do_mass_filtering</doMassFiltering>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
306 <firstSearchTol>$first_search_tol</firstSearchTol>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
307 <mainSearchTol>$main_search_tol</mainSearchTol>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
308 $labels
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
309 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
310
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
311 # <labels>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
312 # <string />
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
313 # <string>Arg10; Lys8</string>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
314 # </labels>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
315
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
316 fragment_settings = {
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
317 "FTMS": {"InPpm": "true", "Deisotope": "true", "Topx": "10", "HigherCharges": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
318 "IncludeWater": "true", "IncludeAmmonia": "true", "DependentLosses": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
319 "tolerance_value": "20", "tolerance_unit": "Ppm", "name": "FTMS"},
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
320 "ITMS": {"InPpm": "false", "Deisotope": "false", "Topx": "6", "HigherCharges": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
321 "IncludeWater": "true", "IncludeAmmonia": "true", "DependentLosses": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
322 "tolerance_value": "0.5", "tolerance_unit": "Dalton", "name": "ITMS"},
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
323 "TOF": {"InPpm": "false", "Deisotope": "true", "Topx": "10", "HigherCharges": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
324 "IncludeWater": "true", "IncludeAmmonia": "true", "DependentLosses": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
325 "tolerance_value": "0.1", "tolerance_unit": "Dalton", "name": "TOF"},
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
326 "Unknown": {"InPpm": "false", "Deisotope": "false", "Topx": "6", "HigherCharges": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
327 "IncludeWater": "true", "IncludeAmmonia": "true", "DependentLosses": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
328 "tolerance_value": "0.5", "tolerance_unit": "Dalton", "name": "Unknown"},
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
329 }
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
330
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
331
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
332 def build_isobaric_labels(reporter_type):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
333 if not reporter_type:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
334 return "<isobaricLabels />"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
335 if reporter_type == "itraq_4plex":
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
336 prefix = "iTRAQ4plex"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
337 mzs = [114, 115, 116, 117]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
338 elif reporter_type == "itraq_8plex":
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
339 prefix = "iTRAQ8plex"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
340 mzs = [113, 114, 115, 116, 117, 118, 119, 121]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
341 elif reporter_type == "tmt_2plex":
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
342 prefix = "TMT2plex"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
343 mzs = [126, 127]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
344 elif reporter_type == "tmt_6plex":
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
345 prefix = "TMT6plex"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
346 mzs = [126, 127, 128, 129, 130, 131]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
347 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
348 raise Exception("Unknown reporter type - %s" % reporter_type)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
349 labels = ["%s-%s%d" % (prefix, term, mz) for term in ["Nter", "Lys"] for mz in mzs]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
350 return wrap(map(xml_string, labels), "isobaricLabels")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
351
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
352
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
353 def parse_groups(inputs_file, group_parts=["num"], input_parts=["name", "path"]):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
354 inputs_lines = [line.strip() for line in open(inputs_file, "r").readlines()]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
355 inputs_lines = [line for line in inputs_lines if line and not line.startswith("#")]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
356 cur_group = None
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
357 i = 0
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
358 group_prefixes = ["%s:" % group_part for group_part in group_parts]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
359 input_prefixes = ["%s:" % input_part for input_part in input_parts]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
360 groups = {}
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
361 while i < len(inputs_lines):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
362 line = inputs_lines[i]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
363 if line.startswith(group_prefixes[0]):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
364 # Start new group
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
365 cur_group = line[len(group_prefixes[0]):]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
366 group_data = {}
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
367 for j, group_prefix in enumerate(group_prefixes):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
368 group_line = inputs_lines[i + j]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
369 group_data[group_parts[j]] = group_line[len(group_prefix):]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
370 i += len(group_prefixes)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
371 elif line.startswith(input_prefixes[0]):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
372 input = []
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
373 for j, input_prefix in enumerate(input_prefixes):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
374 part_line = inputs_lines[i + j]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
375 part = part_line[len(input_prefixes[j]):]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
376 input.append(part)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
377 if cur_group not in groups:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
378 groups[cur_group] = {"group_data": group_data, "inputs": []}
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
379 groups[cur_group]["inputs"].append(input)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
380 i += len(input_prefixes)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
381 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
382 # Skip empty line
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
383 i += 1
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
384 return groups
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
385
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
386
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
387 def add_fragment_options(parser):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
388 for name, options in fragment_settings.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
389 for key, value in options.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
390 option_key = ("%s_%s" % (name, key)).lower()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
391 parser.add_option("--%s" % option_key, default=value)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
392
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
393
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
394 def update_fragment_settings(arg_options):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
395 for name, options in fragment_settings.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
396 for key, value in options.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
397 arg_option_key = ("%s_%s" % (name, key)).lower()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
398 options[key] = getattr(arg_options, arg_option_key)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
399
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
400
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
401 def to_fragment_settings(name, values):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
402 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
403 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
404
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
405 fragment_settings_template = """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
406 <FragmentSpectrumSettings Name="$name" InPpm="$InPpm" Deisotope="$Deisotope"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
407 Topx="$Topx" HigherCharges="$HigherCharges" IncludeWater="$IncludeWater" IncludeAmmonia="$IncludeAmmonia"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
408 DependentLosses="$DependentLosses">
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
409 <Tolerance>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
410 <Value>$tolerance_value</Value>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
411 <Unit>$tolerance_unit</Unit>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
412 </Tolerance>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
413 </FragmentSpectrumSettings>
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
414 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
415 safe_values = dict(values)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
416 for key, value in safe_values.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
417 safe_values[key] = escape(value)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
418 return Template(fragment_settings_template).substitute(safe_values)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
419
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
420
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
421 def get_file_paths(files):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
422 return wrap([xml_string(name) for name in files], "filePaths")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
423
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
424
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
425 def get_file_names(file_names):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
426 return wrap([xml_string(name) for name in file_names], "fileNames")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
427
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
428
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
429 def get_file_groups(file_groups):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
430 return wrap([xml_int(file_group) for file_group in file_groups], "paramGroups")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
431
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
432
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
433 def wrap(values, tag):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
434 return "<%s>%s</%s>" % (tag, "".join(values), tag)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
435
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
436
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
437 def xml_string(str):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
438 if str:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
439 return "<string>%s</string>" % escape(str)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
440 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
441 return "<string />"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
442
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
443
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
444 def xml_int(value):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
445 return "<int>%d</int>" % int(value)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
446
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
447
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
448 def get_properties(options):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
449 direct_properties = ["lcms_run_type",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
450 "max_missed_cleavages",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
451 "protease",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
452 "first_search_tol",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
453 "main_search_tol",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
454 "max_n_mods",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
455 "max_charge",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
456 "max_labeled_aa",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
457 "do_mass_filtering",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
458 "calc_peak_properties",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
459 "use_original_precursor_mz",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
460 "multi_modification_search",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
461 "keep_low_scores_mode",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
462 "msms_centroid_mode",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
463 "quant_mode",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
464 "site_quant_mode",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
465 "advanced_ratios",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
466 "rt_shift",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
467 "fast_lfq",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
468 "randomize",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
469 "aif_sil_weight",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
470 "aif_iso_weight",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
471 "aif_topx",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
472 "aif_correlation",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
473 "aif_correlation_first_pass",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
474 "aif_min_mass",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
475 "aif_msms_tol",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
476 "aif_second_pass",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
477 "aif_iterative",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
478 "aif_threhold_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
479 "restrict_protein_quantification",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
480 "matching_time_window",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
481 "number_of_candidates_multiplexed_msms",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
482 "number_of_candidates_msms",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
483 "separate_aas_for_site_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
484 "special_aas",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
485 "include_contamiants",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
486 "equal_il",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
487 "topx_window",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
488 "max_peptide_mass",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
489 "reporter_pif",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
490 "reporter_fraction",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
491 "reporter_base_peak_ratio",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
492 "score_threshold",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
493 "filter_aacounts",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
494 "second_peptide",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
495 "match_between_runs",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
496 "match_between_runs_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
497 "re_quantify",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
498 "dependent_peptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
499 "dependent_peptide_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
500 "dependent_peptide_mass_bin",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
501 "label_free",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
502 "lfq_min_edges_per_node",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
503 "lfq_av_edges_per_node",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
504 "hybrid_quantification",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
505 "msms_connection",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
506 "ibaq",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
507 "msms_recalibration",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
508 "ibaq_log_fit",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
509 "razor_protein_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
510 "calc_sequence_tags",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
511 "de_novo_var_mods",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
512 "mass_difference_search",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
513 "min_pep_len",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
514 "peptide_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
515 "peptide_pep",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
516 "protein_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
517 "site_fdr",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
518 "min_peptide_length_for_unspecific_search",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
519 "max_peptide_length_for_unspecific_search",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
520 "use_norm_ratios_for_occupancy",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
521 "min_peptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
522 "min_razor_peptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
523 "min_unique_peptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
524 "use_counterparts",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
525 "min_ratio_count",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
526 "lfq_min_ratio_count",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
527 ]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
528
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
529 props = {
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
530 "slice_peaks": "true",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
531 "num_cores": str(options.num_cores),
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
532 "database": xml_string(setup_database(options)),
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
533 "process_folder": os.path.join(os.getcwd(), "process"),
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
534 }
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
535 for prop in direct_properties:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
536 props[prop] = str(getattr(options, prop))
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
537
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
538 for name, fragment_options in fragment_settings.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
539 key = "%s_fragment_settings" % name.lower()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
540 props[key] = to_fragment_settings(name, fragment_options)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
541
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
542 restrict_mods_string = wrap(map(xml_string, options.restrict_mods), "restrictMods")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
543 props["restrict_mods"] = restrict_mods_string
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
544 fixed_mods_string = wrap(map(xml_string, options.fixed_mods), "fixedModifications")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
545 props["fixed_mods"] = fixed_mods_string
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
546 variable_mods_string = wrap(map(xml_string, options.variable_mods), "variableModifications")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
547 props["variable_mods"] = variable_mods_string
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
548 return props
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
549
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
550
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
551 # http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
552 def which(program):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
553 import os
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
554
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
555 def is_exe(fpath):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
556 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
557
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
558 fpath, fname = os.path.split(program)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
559 if fpath:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
560 if is_exe(program):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
561 return program
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
562 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
563 for path in os.environ["PATH"].split(os.pathsep):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
564 path = path.strip('"')
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
565 exe_file = os.path.join(path, program)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
566 if is_exe(exe_file):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
567 return exe_file
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
568
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
569 return None
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
570
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
571
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
572 def get_unique_path(base, extension):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
573 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
574 """
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
575 return "%s_%d%s" % (base, int(time.time() * 1000), extension)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
576
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
577
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
578 def get_env_property(name, default):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
579 if name in os.environ:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
580 return os.environ[name]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
581 else:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
582 return default
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
583
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
584
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
585 def setup_database(options):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
586 database_path = options.database
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
587 database_name = options.database_name
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
588 database_name = database_name.replace(" ", "_")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
589 (database_basename, extension) = os.path.splitext(database_name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
590 database_destination = get_unique_path(database_basename, ".fasta")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
591 assert database_destination == os.path.basename(database_destination)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
592 symlink(database_path, database_destination)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
593
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
594 database_conf = get_env_property("MAXQUANT_DATABASE_CONF", None)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
595 if not database_conf:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
596 exe_path = which("MaxQuantCmd.exe")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
597 database_conf = os.path.join(os.path.dirname(exe_path), "conf", "databases.xml")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
598 with FileLock(database_conf + ".galaxy_lock"):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
599 tree = ET.parse(database_conf)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
600 root = tree.getroot()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
601 databases_node = root.find("Databases")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
602 database_node = ET.SubElement(databases_node, 'databases')
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
603 database_node.attrib["search_expression"] = ">([^ ]*)"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
604 database_node.attrib["replacement_expression"] = "%1"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
605 database_node.attrib["filename"] = database_destination
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
606 tree.write(database_conf)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
607 return os.path.abspath(database_destination)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
608
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
609
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
610 def setup_inputs(input_groups_path):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
611 parsed_groups = parse_groups(input_groups_path)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
612 paths = []
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
613 names = []
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
614 group_nums = []
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
615 for group, group_info in parsed_groups.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
616 files = group_info["inputs"]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
617 group_num = group_info["group_data"]["num"]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
618 for (name, path) in files:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
619 name = os.path.basename(name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
620 if not name.lower().endswith(".raw"):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
621 name = "%s.%s" % (name, ".RAW")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
622 symlink(path, name)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
623 paths.append(os.path.abspath(name))
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
624 names.append(os.path.splitext(name)[0])
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
625 group_nums.append(group_num)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
626 file_data = (get_file_paths(paths), get_file_names(names), get_file_groups(group_nums))
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
627 return "<rawFileInfo>%s%s%s<Fractions/><Values/></rawFileInfo> " % file_data
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
628
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
629
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
630 def set_group_params(properties, options):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
631 labels = [""]
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
632 if options.labels:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
633 labels = options.labels
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
634 labels_string = wrap([xml_string(label.replace(",", "; ")) for label in labels], "labels")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
635 group_properties = dict(properties)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
636 group_properties["labels"] = labels_string
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
637 group_properties["multiplicity"] = len(labels)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
638 group_properties["group_index"] = "1"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
639 group_properties["ms_instrument"] = "0"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
640 group_params = Template(GROUP_TEMPLATE).substitute(group_properties)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
641 properties["group_params"] = group_params
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
642
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
643
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
644 def split_mods(mods_string):
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
645 return [mod for mod in mods_string.split(",") if mod] if mods_string else []
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
646
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
647
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
648 def run_script():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
649 parser = optparse.OptionParser()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
650 parser.add_option("--input_groups")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
651 parser.add_option("--database")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
652 parser.add_option("--database_name")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
653 parser.add_option("--num_cores", type="int", default=4)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
654 parser.add_option("--max_missed_cleavages", type="int", default=2)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
655 parser.add_option("--protease", default="Trypsin/P")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
656 parser.add_option("--first_search_tol", default="20")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
657 parser.add_option("--main_search_tol", default="6")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
658 parser.add_option("--max_n_mods", type="int", default=5)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
659 parser.add_option("--max_charge", type="int", default=7)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
660 parser.add_option("--do_mass_filtering", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
661 parser.add_option("--labels", action="append", default=[])
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
662 parser.add_option("--max_labeled_aa", type="int", default=3)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
663 parser.add_option("--keep_low_scores_mode", type="int", default=0)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
664 parser.add_option("--msms_centroid_mode", type="int", default=1)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
665 # 0 = all peptides, 1 = Use razor and unique peptides, 2 = use unique peptides
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
666 parser.add_option("--quant_mode", type="int", default=1)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
667 parser.add_option("--site_quant_mode", type="int", default=0)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
668 parser.add_option("--aif_sil_weight", type="int", default=4)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
669 parser.add_option("--aif_iso_weight", type="int", default=2)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
670 parser.add_option("--aif_topx", type="int", default=50)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
671 parser.add_option("--aif_correlation", type="float", default=0.8)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
672 parser.add_option("--aif_correlation_first_pass", type="float", default=0.8)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
673 parser.add_option("--aif_min_mass", type="float", default=0)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
674 parser.add_option("--aif_msms_tol", type="float", default=10)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
675 parser.add_option("--aif_second_pass", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
676 parser.add_option("--aif_iterative", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
677 parser.add_option("--aif_threhold_fdr", default="0.01")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
678 parser.add_option("--restrict_protein_quantification", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
679 parser.add_option("--matching_time_window", default="2")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
680 parser.add_option("--number_of_candidates_multiplexed_msms", default="50")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
681 parser.add_option("--number_of_candidates_msms", default="15")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
682 parser.add_option("--separate_aas_for_site_fdr", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
683 parser.add_option("--advanced_ratios", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
684 parser.add_option("--rt_shift", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
685 parser.add_option("--fast_lfq", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
686 parser.add_option("--randomize", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
687 parser.add_option("--special_aas", default="KR")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
688 parser.add_option("--include_contamiants", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
689 parser.add_option("--equal_il", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
690 parser.add_option("--topx_window", default="100")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
691 parser.add_option("--max_peptide_mass", default="5000")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
692 parser.add_option("--reporter_pif", default="0.75")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
693 parser.add_option("--reporter_fraction", default="0")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
694 parser.add_option("--reporter_base_peak_ratio", default="0")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
695 parser.add_option("--score_threshold", default="0")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
696 parser.add_option("--filter_aacounts", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
697 parser.add_option("--second_peptide", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
698 parser.add_option("--match_between_runs", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
699 parser.add_option("--match_between_runs_fdr", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
700 parser.add_option("--re_quantify", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
701 parser.add_option("--dependent_peptides", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
702 parser.add_option("--dependent_peptide_fdr", default="0.01")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
703 parser.add_option("--dependent_peptide_mass_bin", default="0.0055")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
704 parser.add_option("--label_free", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
705 parser.add_option("--lfq_min_edges_per_node", default="3")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
706 parser.add_option("--lfq_av_edges_per_node", default="6")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
707 parser.add_option("--hybrid_quantification", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
708 parser.add_option("--msms_connection", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
709 parser.add_option("--ibaq", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
710 parser.add_option("--msms_recalibration", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
711 parser.add_option("--ibaq_log_fit", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
712 parser.add_option("--razor_protein_fdr", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
713 parser.add_option("--calc_sequence_tags", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
714 parser.add_option("--de_novo_var_mods", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
715 parser.add_option("--mass_difference_search", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
716 parser.add_option("--min_pep_len", default="7")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
717 parser.add_option("--peptide_fdr", default="0.01")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
718 parser.add_option("--peptide_pep", default="1")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
719 parser.add_option("--protein_fdr", default="0.01")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
720 parser.add_option("--site_fdr", default="0.01")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
721 parser.add_option("--min_peptide_length_for_unspecific_search", default="8")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
722 parser.add_option("--max_peptide_length_for_unspecific_search", default="25")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
723 parser.add_option("--use_norm_ratios_for_occupancy", default="true")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
724 parser.add_option("--min_peptides", default="1")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
725 parser.add_option("--min_razor_peptides", default="1")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
726 parser.add_option("--min_unique_peptides", default="0")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
727 parser.add_option("--use_counterparts", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
728 parser.add_option("--min_ratio_count", default="2")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
729 parser.add_option("--lfq_min_ratio_count", default="2")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
730 parser.add_option("--calc_peak_properties", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
731 parser.add_option("--use_original_precursor_mz", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
732 parser.add_option("--multi_modification_search", default="false")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
733 parser.add_option("--lcms_run_type", default="0")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
734 parser.add_option("--reporter_type", default=None)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
735 parser.add_option("--output_mqpar", default=None)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
736 text_outputs = {
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
737 "aif_msms": "aifMsms",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
738 "all_peptides": "allPeptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
739 "evidence": "evidence",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
740 "modification_specific_peptides": "modificationSpecificPeptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
741 "msms": "msms",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
742 "msms_scans": "msmsScans",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
743 "mz_range": "mzRange",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
744 "parameters": "parameters",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
745 "peptides": "peptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
746 "protein_groups": "proteinGroups",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
747 "sim_peptides": "simPeptides",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
748 "sim_scans": "simScans",
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
749 "summary": "summary"
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
750 }
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
751 for output in text_outputs.keys():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
752 parser.add_option("--output_%s" % output, default=None)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
753
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
754 parser.add_option("--variable_mods", default="Oxidation (M),Acetyl (Protein N-term)")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
755 parser.add_option("--restrict_mods", default="Oxidation (M),Acetyl (Protein N-term)")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
756 parser.add_option("--fixed_mods", default="Carbamidomethyl (C)")
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
757
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
758 add_fragment_options(parser)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
759
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
760 (options, args) = parser.parse_args()
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
761 options.restrict_mods = split_mods(options.restrict_mods)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
762 options.fixed_mods = split_mods(options.fixed_mods)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
763 options.variable_mods = split_mods(options.variable_mods)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
764
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
765 update_fragment_settings(options)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
766
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
767 raw_file_info = setup_inputs(options.input_groups)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
768 properties = get_properties(options)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
769 properties["raw_file_info"] = raw_file_info
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
770 properties["isobaric_labels"] = build_isobaric_labels(options.reporter_type)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
771 set_group_params(properties, options)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
772 driver_contents = Template(TEMPLATE).substitute(properties)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
773 open("mqpar.xml", "w").write(driver_contents)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
774 print driver_contents
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
775 execute("MaxQuantCmd.exe mqpar.xml %d" % options.num_cores)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
776 for key, basename in text_outputs.iteritems():
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
777 attribute = "output_%s" % key
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
778 destination = getattr(options, attribute, None)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
779 if destination:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
780 source = os.path.join("combined", "txt", "%s.txt" % basename)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
781 shutil.copy(source, destination)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
782 output_mqpar = options.output_mqpar
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
783 if output_mqpar:
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
784 shutil.copy("mqpar.xml", output_mqpar)
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
785
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
786 if __name__ == '__main__':
d4b6c9eae635 Initial commit.
galaxyp
parents:
diff changeset
787 __main__()