@@ -1178,32 +1178,38 @@ def get_noindex_stats(self, sub_demux):
11781178 # read sub_demux_manifest into a string
11791179 with open (sub_demux_manifest ) as f :
11801180 manifest_csv = f .read ()
1181- sample_row = (
1182- manifest_csv .split ("[SAMPLES]" )[1 ].strip ().split ("\n " )[- 1 ]
1181+ sample_rows = (
1182+ manifest_csv .split ("[SAMPLES]" )[1 ].strip ().split ("\n " )[1 : ]
11831183 ) # ugh...
1184- sample_name = sample_row .split ("," )[0 ]
1185- lane = sample_row .split ("," )[3 ]
1186- # Extract NumPolonies from RunStats.json
11871184 runstats_json_path = os .path .join (
11881185 self .run_dir , f"Demultiplexing_{ sub_demux } " , "RunStats.json"
11891186 )
1190- if os .path .exists (runstats_json_path ):
1187+ if not os .path .exists (runstats_json_path ):
1188+ logger .error (
1189+ f"No RunStats.json file found for sub-demultiplexing { sub_demux } . Unable to process NoIndex samples. Skipping."
1190+ )
1191+ raise FileNotFoundError
1192+ samples = []
1193+ for sample_row in sample_rows :
1194+ sample_name = sample_row .split ("," )[0 ]
1195+ lane = sample_row .split ("," )[3 ]
1196+ # Extract NumPolonies from RunStats.json
11911197 with open (runstats_json_path ) as json_file :
11921198 demux_info = json .load (json_file )
11931199 demuxed_lanes = demux_info .get ("Lanes" )
11941200 for demuxed_lane in demuxed_lanes :
11951201 if demuxed_lane .get ("Lane" ) == int (lane ):
11961202 polonies = demuxed_lane .get ("NumPolonies" )
11971203 break
1198- return [
1199- {
1204+ sample_info = {
12001205 "SampleName" : sample_name ,
12011206 "I1" : "" ,
12021207 "I2" : "" ,
12031208 "Lane" : lane ,
12041209 "NumPoloniesAssigned" : polonies ,
12051210 }
1206- ]
1211+ samples .append (sample_info )
1212+ return samples
12071213
12081214 # Aggregate stats in UnassignedSequences.csv
12091215 def aggregate_stats_unassigned (
0 commit comments