@@ -65,9 +65,6 @@ def get_common_param(margs):
6565 pat_split = margs .pattern .split ("*" )
6666 param_dict ["input_files" ].extend (
6767 glob (os .path .join ("*" .join (pat_split [:- 1 ]), "*" + pat_split [- 1 ])))
68-
69- # read_count = int(margs.read_count)
70- # param_dict["read_count"] = read_count
7168
7269 if len (param_dict ["input_files" ]) == 0 :
7370 parsing_error_msg += "No input file(s) were provided.\n "
@@ -88,8 +85,6 @@ def get_common_param(margs):
8885 except OSError :
8986 parsing_error_msg += "Cannot create folder for " + param_dict ["output_folder" ] + " \n "
9087
91- param_dict ["out_prefix" ] = margs .outprefix
92-
9388 # Set up logging to file and stdout
9489 if margs .log is None or margs .log == "" :
9590 parsing_error_msg += "No log file was provided.\n "
@@ -113,6 +108,7 @@ def get_common_param(margs):
113108 param_dict ["log_level" ] = margs .log_level
114109
115110 param_dict ["threads" ] = margs .threads
111+ param_dict ["sample_name" ] = margs .sample
116112
117113 # Reset the param_dict if there are parsing errors
118114 if parsing_error_msg != "" :
@@ -133,17 +129,15 @@ def fq_module(margs):
133129
134130 else :
135131 logging .info ('Input file(s) are:\n %s' , '\n ' .join (param_dict ["input_files" ]))
136- param_dict ["out_prefix" ] += "fastq"
137132
138133 # Import the SWIG Python wrapper for our C++ module
139134 input_para = lrst .Input_Para ()
140135 input_para .threads = param_dict ["threads" ]
141136
142137 input_para .other_flags = 0
143138 input_para .user_defined_fastq_base_qual_offset = margs .udqual
144-
145139 input_para .output_folder = str (param_dict ["output_folder" ])
146- input_para .out_prefix = str ( param_dict ["out_prefix" ])
140+ input_para .sample_name = param_dict ["sample_name" ]
147141
148142 for _ipf in param_dict ["input_files" ]:
149143 input_para .add_input_file (str (_ipf ))
@@ -157,7 +151,7 @@ def fq_module(margs):
157151 fq_html_gen = generate_html .ST_HTML_Generator (
158152 [["basic_st" , "read_length_bar" , "read_length_hist" , "gc_content_hist" , "base_counts" , "base_quality" ,
159153 "read_avg_base_quality" ], "FASTQ QC" , param_dict ], plot_filepaths , static = False )
160- fq_html_gen .generate_html ()
154+ fq_html_gen .generate_html (input_para . sample_name , "fastq" )
161155
162156 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
163157 else :
@@ -176,12 +170,11 @@ def fa_module(margs):
176170 else :
177171 # If there are no parse errors, run the filetype-specific module
178172 logging .info ('Input file(s) are:\n %s' , '\n ' .join (param_dict ["input_files" ]))
179- param_dict ["out_prefix" ] += "fasta"
180173 input_para = lrst .Input_Para ()
181174 input_para .threads = param_dict ["threads" ]
182175 input_para .other_flags = 0
183176 input_para .output_folder = str (param_dict ["output_folder" ])
184- input_para .out_prefix = str ( param_dict ["out_prefix" ])
177+ input_para .sample_name = param_dict ["sample_name" ]
185178
186179 for _ipf in param_dict ["input_files" ]:
187180 input_para .add_input_file (str (_ipf ))
@@ -195,7 +188,7 @@ def fa_module(margs):
195188 fa_html_gen = generate_html .ST_HTML_Generator (
196189 [["basic_st" , "read_length_bar" , "read_length_hist" , "gc_content_hist" , "base_counts" ], "FASTA QC" ,
197190 param_dict ], plot_filepaths , static = True )
198- fa_html_gen .generate_html ()
191+ fa_html_gen .generate_html (input_para . sample_name , "fasta" )
199192 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
200193
201194 else :
@@ -211,11 +204,10 @@ def bam_module(margs):
211204
212205 else :
213206 logging .info ('Input file(s) are:\n %s' , '\n ' .join (param_dict ["input_files" ]))
214- param_dict ["out_prefix" ] += "bam" ;
215207 input_para = lrst .Input_Para ()
216208 input_para .threads = param_dict ["threads" ]
217209 input_para .output_folder = str (param_dict ["output_folder" ])
218- input_para .out_prefix = str ( param_dict ["out_prefix" ])
210+ input_para .sample_name = param_dict ["sample_name" ]
219211
220212 # Set the reference genome file and base modification threshold
221213 ref_genome = margs .ref if margs .ref != "" or margs .ref is not None else ""
@@ -269,7 +261,7 @@ def bam_module(margs):
269261 # Generate the HTML report
270262 bam_html_gen = generate_html .ST_HTML_Generator (
271263 [qc_info_list , "BAM QC" , param_dict ], plot_filepaths , static = False )
272- bam_html_gen .generate_html ()
264+ bam_html_gen .generate_html (input_para . sample_name , "bam" )
273265 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
274266
275267 else :
@@ -288,26 +280,19 @@ def rrms_module(margs):
288280 input_para = lrst .Input_Para ()
289281 input_para .threads = param_dict ["threads" ]
290282 input_para .output_folder = str (param_dict ["output_folder" ])
291- input_para .out_prefix = str (param_dict ["out_prefix" ])
283+ input_para .sample_name = param_dict ["sample_name" ]
284+
292285 for _ipf in param_dict ["input_files" ]:
293286 input_para .add_input_file (str (_ipf ))
294287
295288 # Set the RRMS input CSV file
296289 input_para .rrms_csv = margs .csv
297290 logging .info ("RRMS CSV file is " + input_para .rrms_csv )
298291
299- # Get the output prefix
300- output_prefix = param_dict ["out_prefix" ]
301-
302292 # Run QC for both accepted and rejected reads
303293 rrms_filter = [True , False ]
304294 for filter_type in rrms_filter :
305-
306- # Set the RRMS filter type
307- input_para .rrms_filter = filter_type
308-
309- # Set the output prefix
310- param_dict ["out_prefix" ] = output_prefix + "rrms_" + ("accepted" if filter_type else "rejected" )
295+ input_para .rrms_filter = filter_type # True for accepted reads, False for rejected reads
311296 param_dict ["mod" ] = input_para .mod_analysis = False # Disable base modification analysis for RRMS (use BAM module for this)
312297
313298 # Run the QC module
@@ -332,7 +317,7 @@ def rrms_module(margs):
332317 # Generate the HTML report
333318 bam_html_gen = generate_html .ST_HTML_Generator (
334319 [qc_info_list , "BAM QC" , param_dict ], plot_filepaths , static = False )
335- bam_html_gen .generate_html ()
320+ bam_html_gen .generate_html (input_para . sample_name , "rrms_bam_" + ( "accepted" if filter_type else "rejected" ) )
336321 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
337322
338323 else :
@@ -349,11 +334,10 @@ def seqtxt_module(margs):
349334
350335 else :
351336 logging .info ('Input file(s) are:\n %s' , '\n ' .join (param_dict ["input_files" ]))
352- param_dict ["out_prefix" ] += "seqtxt"
353337 input_para = lrst .Input_Para ()
354338 input_para .threads = param_dict ["threads" ]
355339 input_para .output_folder = str (param_dict ["output_folder" ])
356- input_para .out_prefix = str ( param_dict ["out_prefix" ])
340+ input_para .sample_name = param_dict ["sample_name" ]
357341
358342 for _ipf in param_dict ["input_files" ]:
359343 input_para .add_input_file (str (_ipf ))
@@ -370,7 +354,7 @@ def seqtxt_module(margs):
370354 [["basic_st" , "read_length_bar" , "read_length_hist" ],
371355 report_title , param_dict ], plot_filepaths , static = False )
372356
373- seqtxt_html_gen .generate_html ()
357+ seqtxt_html_gen .generate_html (input_para . sample_name , "basecall_summary" )
374358 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
375359 else :
376360 logging .error ("QC did not generate." )
@@ -386,11 +370,10 @@ def fast5_module(margs):
386370
387371 else :
388372 # logging.info('Input file(s) are:\n%s', '\n'.join(param_dict["input_files"]))
389- param_dict ["out_prefix" ] += "FAST5"
390373 input_para = lrst .Input_Para ()
391374 input_para .threads = param_dict ["threads" ]
392375 input_para .output_folder = str (param_dict ["output_folder" ])
393- input_para .out_prefix = str ( param_dict ["out_prefix" ])
376+ input_para .sample_name = param_dict ["sample_name" ]
394377 input_para .other_flags = 0 # 0 for normal QC, 1 for signal statistics output
395378
396379 for _ipf in param_dict ["input_files" ]:
@@ -405,7 +388,7 @@ def fast5_module(margs):
405388 fast5_html_obj = generate_html .ST_HTML_Generator (
406389 [["basic_st" , "read_length_bar" , "read_length_hist" , "gc_content_hist" , "base_counts" , "base_quality" ],
407390 "FAST5 QC" , param_dict ], plot_filepaths , static = False )
408- fast5_html_obj .generate_html ()
391+ fast5_html_obj .generate_html (input_para . sample_name , "fast5" )
409392 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
410393
411394 else :
@@ -421,11 +404,11 @@ def fast5_signal_module(margs):
421404
422405 else :
423406 # logging.info('Input file(s) are:\n%s', '\n'.join(param_dict["input_files"]))
424- param_dict ["out_prefix" ] += "fast5_signal"
425407 input_para = lrst .Input_Para ()
426408 input_para .threads = param_dict ["threads" ]
427409 input_para .output_folder = str (param_dict ["output_folder" ])
428- input_para .out_prefix = str (param_dict ["out_prefix" ])
410+ input_para .sample_name = param_dict ["sample_name" ]
411+
429412 input_para .other_flags = 1 # 0 for normal QC, 1 for signal statistics output
430413
431414 # Get the read count if specified
@@ -450,7 +433,7 @@ def fast5_signal_module(margs):
450433 plot_filepaths = plot (fast5_output , param_dict , 'FAST5s' )
451434 fast5_html_obj = generate_html .ST_HTML_Generator (
452435 [["basic_st" , "read_length_bar" , "read_length_hist" , "gc_content_hist" , "base_counts" , "ont_signal" ], "FAST5 QC" , param_dict ], plot_filepaths , static = False )
453- fast5_html_obj .generate_html (signal_plots = True )
436+ fast5_html_obj .generate_html (input_para . sample_name , "fast5_signal" , signal_plots = True )
454437 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
455438
456439 else :
@@ -467,11 +450,10 @@ def pod5_module(margs):
467450
468451 else :
469452 # logging.info('Input file(s) are:\n%s', '\n'.join(param_dict["input_files"]))
470- param_dict ["out_prefix" ] += "POD5"
471453 input_para = {}
472454 input_para ['threads' ] = param_dict ["threads" ]
473455 input_para ['output_folder' ] = str (param_dict ["output_folder" ])
474- input_para ['out_prefix ' ] = str ( param_dict ["out_prefix" ])
456+ input_para ['sample_name ' ] = param_dict ["sample_name" ]
475457 input_para ['other_flags' ] = 0 # 0 for normal QC, 1 for signal statistics output
476458 input_para ['input_files' ] = []
477459 for input_file in param_dict ["input_files" ]:
@@ -496,7 +478,6 @@ def pod5_module(margs):
496478 basecalls_input = lrst .Input_Para ()
497479 basecalls_input .threads = param_dict ["threads" ]
498480 basecalls_input .output_folder = str (param_dict ["output_folder" ])
499- basecalls_input .out_prefix = str (param_dict ["out_prefix" ])
500481 basecalls_input .add_input_file (basecalls )
501482 bam_output = lrst .Output_BAM ()
502483 exit_code = lrst .callBAMModule (basecalls_input , bam_output )
@@ -518,7 +499,7 @@ def pod5_module(margs):
518499 webpage_title = "POD5 QC"
519500 fast5_html_obj = generate_html .ST_HTML_Generator (
520501 [["basic_st" , "read_length_bar" , "read_length_hist" , "gc_content_hist" , "base_counts" , "ont_signal" ], webpage_title , param_dict ], plot_filepaths , static = False )
521- fast5_html_obj .generate_html (signal_plots = True )
502+ fast5_html_obj .generate_html (input_para . sample_name , "pod5_signal" , signal_plots = True )
522503 logging .info ("Done. Output files are in %s" , param_dict ["output_folder" ])
523504
524505 else :
@@ -543,6 +524,8 @@ def set_file_parser_defaults(file_parser):
543524 help = "The number of threads used. Default: 1." )
544525 file_parser .add_argument ("-Q" , "--outprefix" , type = str , default = "QC_" ,
545526 help = "The prefix for output filenames. Default: `QC_`." )
527+ file_parser .add_argument ("-s" , "--sample" , type = str , default = "Sample" ,
528+ help = "Sample name. Default: `Sample`" )
546529
547530
548531# Set up the argument parser
0 commit comments