@@ -105,6 +105,9 @@ def process_scans(source, function_noise, snr_thres, ppm, min_fraction=None, rsd
105
105
if len (pls_scans [h ]) >= 1 :
106
106
if sum (pl .shape [0 ] for pl in pls_scans [h ]) == 0 :
107
107
logging .warning ("No scan data available for {}" .format (h ))
108
+ d = dict ((k , [pls_scans [h ][0 ].metadata [k ]]) for k in pls_scans [h ][0 ].metadata )
109
+ pls_avg .append (PeakList (ID = h , mz = [], intensity = [], ** d ))
110
+ n_peaks , median_rsd = 0 , "NA"
108
111
else :
109
112
pl_avg = average_replicate_scans (h , pls_scans [h ], ppm , min_fraction , rsd_thres , "intensity" , block_size , ncpus )
110
113
pls_avg .append (pl_avg )
@@ -115,21 +118,26 @@ def process_scans(source, function_noise, snr_thres, ppm, min_fraction=None, rsd
115
118
if report is not None :
116
119
out .write ("{}\t {}\t {}\t {}\t {}\n " .format (os .path .basename (filenames [i ]), h , nscans , n_peaks , median_rsd ))
117
120
118
- if len ( pls_avg ) == 0 :
119
- raise IOError ("No peaks remaining after filtering. Remove file from Study (filelist)." )
121
+ if sum ( pl . shape [ 0 ] for pl in pls_avg ) == 0 :
122
+ logging . warning ("No peaks remaining after filtering. Remove file from Study (filelist)." )
120
123
121
124
if not skip_stitching or len (pls_scans .keys ()) == 1 :
122
125
pl = join_peaklists (os .path .basename (filenames [i ]), pls_avg )
123
126
pl = update_metadata_and_labels ([pl ], fl )
124
127
pls .extend (pl )
128
+
129
+ if hasattr (pl [0 ], 'rsd' ):
130
+ median_rsd = np .nanmedian (pl [0 ].rsd )
131
+ else :
132
+ median_rsd = "NA"
133
+
125
134
if len (pls_scans .keys ()) > 1 and report is not None :
126
- out .write ("{}\t {}\t {}\t {}\t {}\n " .format (os .path .basename (filenames [i ]), "SIM-Stitch" , "NA" , pl [0 ].shape [0 ], np . nanmedian ( pl [ 0 ]. rsd ) ))
135
+ out .write ("{}\t {}\t {}\t {}\t {}\n " .format (os .path .basename (filenames [i ]), "SIM-Stitch" , "NA" , pl [0 ].shape [0 ], median_rsd ))
127
136
else :
128
137
for pl in pls_avg :
129
- pl = update_metadata_and_labels ([pl ], fl )
130
- pl = join_peaklists ("{}#{}" .format (os .path .basename (filenames [i ]), pl [0 ].metadata ["header" ][0 ]), pl )
131
- pls .append (pl )
132
-
138
+ pl = join_peaklists ("{}#{}" .format (os .path .basename (filenames [i ]), pl .metadata ["header" ][0 ]), [pl ])
139
+ pl = update_metadata_and_labels ([pl ], fl , os .path .basename (filenames [i ]))
140
+ pls .extend (pl )
133
141
return pls
134
142
135
143
@@ -244,9 +252,10 @@ def replicate_filter(source, ppm, replicates, min_peaks, rsd_thres=None, filelis
244
252
245
253
if sum ([comb [- 1 ] for comb in temp ]) == 0.0 :
246
254
logging .warning ("insufficient data available to calculate scores for {}" .format (str ([comb [0 ].ID for comb in temp ])))
247
-
248
- # sort the scores from high to low
249
- temp .sort (key = operator .itemgetter (- 1 ), reverse = True )
255
+ temp .sort (key = operator .itemgetter (1 ), reverse = True )
256
+ else :
257
+ # sort the scores from high to low
258
+ temp .sort (key = operator .itemgetter (- 1 ), reverse = True )
250
259
# select the replicate filtered peaklist that is ranked first
251
260
pls_rep_filt .append (temp [0 ][0 ])
252
261
0 commit comments