Skip to content

Commit 96228d9

Browse files
committed
Add noise to simulated dataset
1 parent 82032a8 commit 96228d9

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

python/FPIC.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ def plot_region(rg, rt = None, mz = None):
4646
show()
4747

4848
def data2mzxml(path, converter = 'C:/Program Files/OpenMS/bin/FileConverter.exe'):
49-
files=os.listdir(path)
49+
if os.path.isfile(path):
50+
files = [path]
51+
path = ""
52+
elif os.path.isdir(path):
53+
files=os.listdir(path)
5054
for f in files:
5155
if f.lower().endswith(".mzdata"):
5256
file_in = path + f
5357
file_out = path + f[0:-6] + "mzxml"
54-
subprocess.Popen([converter, '-in', file_in, '-out', file_out])
58+
subprocess.call([converter, '-in', file_in, '-out', file_out])
5559
if f.lower().endswith(".mzml"):
5660
file_in = path + f
5761
file_out = path + f[0:-4] + "mzxml"
58-
subprocess.Popen([converter, '-in', file_in, '-out', file_out])
62+
subprocess.call([converter, '-in', file_in, '-out', file_out])
5963

6064

6165
def pics_id(pics, n):

python/LCMSSimulation.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ def simulation(fasta, contaminants, out, out_cntm,
2323

2424
subprocess.call([simulator, '-in', fasta, '-out', out, '-out_cntm',out_cntm,
2525
'-algorithm:MSSim:RawSignal:contaminants:file', contaminants,
26+
'-algorithm:MSSim:RawSignal:noise:detector:stddev', '1',
27+
'-algorithm:MSSim:RawSignal:resolution:value', '5000',
28+
'-algorithm:MSSim:RawSignal:resolution:type', 'constant',
2629
'-algorithm:MSSim:Ionization:mz:lower_measurement_limit', '10',
2730
'-algorithm:MSSim:Ionization:mz:upper_measurement_limit', '1000',
2831
'-algorithm:MSSim:RT:total_gradient_time', '1000',
29-
'-algorithm:MSSim:RT:sampling_rate', '0.1',
32+
'-algorithm:MSSim:RT:sampling_rate', '0.25',
3033
'-algorithm:MSSim:RT:scan_window:min', '0',
3134
'-algorithm:MSSim:RT:scan_window:max', '1000'])
3235

@@ -148,22 +151,13 @@ def match_features(ground_truths, df):
148151
subprocess.call([peak_picker,'-in', 'MM48_MSS_Profile.mzML',
149152
'-out', 'MM48_MSS.mzML'])
150153

151-
data2mzxml('./')
154+
data2mzxml('MM48_MSS.mzML')
152155

153156
ground_truths = parse_featureXML_GT('MM48_MSS.featureXML')
154157

155158
mzfile = "MM48_MSS.mzxml"
156159
mzMLfile = "MM48_MSS.mzML"
157160

158-
tic()
159-
parser=mzXMLParser()
160-
lcms = parser.parseFile(mzfile.encode(sys.getfilesystemencoding()))
161-
pics_c = pm.FPICs(lcms, 10.0, 200.0, 0.5)
162-
toc()
163-
164-
match_fpic = ground_truths.copy()
165-
match_features(match_fpic, pics2df(pics_c))
166-
match_fpic.detected.value_counts()
167161

168162
tic()
169163
feature_map = FeatureFindingMetabo(mzMLfile)
@@ -183,5 +177,15 @@ def match_features(ground_truths, df):
183177
match_xcms = ground_truths.copy()
184178
match_features(match_xcms, df_xcms)
185179
match_xcms.detected.value_counts()
180+
181+
tic()
182+
parser=mzXMLParser()
183+
lcms = parser.parseFile(mzfile.encode(sys.getfilesystemencoding()))
184+
pics_c = pm.FPICs(lcms, 10.0, 200.0, 0.5)
185+
toc()
186+
match_fpic = ground_truths.copy()
187+
df_fpic = pics2df(pics_c)
188+
match_features(match_fpic, df_fpic)
189+
match_fpic.detected.value_counts()
186190

187191

0 commit comments

Comments
 (0)