@@ -88,14 +88,18 @@ pub struct GalahAnalyser<'a> {
8888}
8989
9090impl GalahAnalyser < ' _ > {
91- pub fn analyse ( & mut self ) -> Result < std:: collections:: HashMap < String , GenomeOutput > , String > {
91+ pub fn analyse (
92+ & mut self ,
93+ output_quality_report_path : & Option < String > ,
94+ ) -> Result < std:: collections:: HashMap < String , GenomeOutput > , String > {
9295 crate :: analyse:: analyse (
9396 self . genome_fasta_files ,
9497 self . threads ,
9598 & mut self . quality_analyser ,
9699 & self . rrna_analyser ,
97100 & self . trna_analyser ,
98101 & self . checkm2_quality_report ,
102+ output_quality_report_path,
99103 & self . checkm_tab_table ,
100104 & self . barrnap_gff_list ,
101105 & self . trnascan_out_list ,
@@ -108,6 +112,7 @@ pub struct GalahAnalyserCommandDefinition {
108112 pub rrna_method_argument : String ,
109113 pub trna_method_argument : String ,
110114 pub output_mimag_summary_argument : String ,
115+ pub output_quality_report_argument : String ,
111116 pub checkm2_db_path_argument : String ,
112117 pub checkm2_quality_report_argument : String ,
113118 pub checkm_tab_table_argument : String ,
@@ -116,12 +121,13 @@ pub struct GalahAnalyserCommandDefinition {
116121}
117122
118123lazy_static ! {
119- static ref ANALYSE_COMMAND_DEFINITION : GalahAnalyserCommandDefinition = {
124+ pub static ref ANALYSE_COMMAND_DEFINITION : GalahAnalyserCommandDefinition = {
120125 GalahAnalyserCommandDefinition {
121126 quality_method_argument: "quality-method" . to_string( ) ,
122127 rrna_method_argument: "rrna-method" . to_string( ) ,
123128 trna_method_argument: "trna-method" . to_string( ) ,
124129 output_mimag_summary_argument: "output-mimag-summary" . to_string( ) ,
130+ output_quality_report_argument: "output-quality-report" . to_string( ) ,
125131 checkm2_db_path_argument: "checkm2-db-path" . to_string( ) ,
126132 checkm2_quality_report_argument: "checkm2-quality-report" . to_string( ) ,
127133 checkm_tab_table_argument: "checkm-tab-table" . to_string( ) ,
@@ -314,7 +320,21 @@ pub fn add_analyse_subcommand(app: clap::Command) -> clap::Command {
314320 Arg :: new ( & * ANALYSE_COMMAND_DEFINITION . output_mimag_summary_argument )
315321 . long ( "output-mimag-summary" )
316322 . value_name ( "SUMMARY" )
317- . help ( "Path to output MIMAG summary file" ) ,
323+ . help ( "Path to output MIMAG summary file" )
324+ . required_unless_present_any ( [
325+ "output-quality-report" ,
326+ "full-help" ,
327+ "full-help-roff" , ] ) ,
328+ )
329+ . arg (
330+ Arg :: new ( & * ANALYSE_COMMAND_DEFINITION . output_quality_report_argument )
331+ . long ( "output-quality-report" )
332+ . value_name ( "REPORT" )
333+ . help ( "Path to output CheckM2-format quality report" )
334+ . required_unless_present_any ( [
335+ "output-mimag-summary" ,
336+ "full-help" ,
337+ "full-help-roff" , ] ) ,
318338 )
319339 . arg (
320340 Arg :: new ( & * ANALYSE_COMMAND_DEFINITION . rrna_method_argument )
@@ -460,15 +480,22 @@ pub fn add_analyse_output_parameters_to_section(
460480 section : Section ,
461481 definition : & GalahAnalyserCommandDefinition ,
462482) -> Section {
463- section. option (
464- Opt :: new ( "PATH" )
465- . long ( & format ! ( "--{}" , definition. output_mimag_summary_argument) )
466- . help ( "Output a tsv file summarising the MIMAG status for each genome." ) ,
467- )
483+ section
484+ . option (
485+ Opt :: new ( "PATH" )
486+ . long ( & format ! ( "--{}" , definition. output_mimag_summary_argument) )
487+ . help ( "Output a tsv file summarising the MIMAG status for each genome." ) ,
488+ )
489+ . option (
490+ Opt :: new ( "PATH" )
491+ . long ( & format ! ( "--{}" , definition. output_quality_report_argument) )
492+ . help ( "Output a CheckM2-format quality report TSV file." ) ,
493+ )
468494}
469495
470496pub struct AnalyseOutput {
471497 pub output_mimag_summary : Option < std:: fs:: File > ,
498+ pub output_quality_report_path : Option < String > ,
472499}
473500
474501pub fn setup_analyse_outputs (
@@ -479,8 +506,13 @@ pub fn setup_analyse_outputs(
479506 . get_one :: < String > ( & command_definition. output_mimag_summary_argument )
480507 . map ( |o| std:: fs:: File :: create ( o) . expect ( "Failed to open output MIMAG summary file" ) ) ;
481508
509+ let output_quality_report_path = m
510+ . get_one :: < String > ( & command_definition. output_quality_report_argument )
511+ . map ( |s| s. to_string ( ) ) ;
512+
482513 AnalyseOutput {
483514 output_mimag_summary,
515+ output_quality_report_path,
484516 }
485517}
486518
@@ -511,9 +543,11 @@ pub fn run_analyse_subcommand(
511543 let output_definitions = setup_analyse_outputs ( m, & ANALYSE_COMMAND_DEFINITION ) ;
512544
513545 info ! ( "Analysing {} genomes .." , genome_fasta_files. len( ) ) ;
514- let analysis = galah. analyse ( ) . expect ( "Failed to analyse genomes" ) ;
546+ let analysis = galah
547+ . analyse ( & output_definitions. output_quality_report_path )
548+ . expect ( "Failed to analyse genomes" ) ;
515549
516- write_analyse_outputs ( output_definitions, & analysis, genome_fasta_files) ;
550+ write_analyse_outputs ( output_definitions, & analysis, & genome_fasta_files) ;
517551 info ! ( "Finished printing genome analysis" ) ;
518552}
519553
@@ -580,10 +614,10 @@ fn generate_galah_analyser<'a>(
580614 } )
581615}
582616
583- fn write_analyse_outputs (
617+ pub fn write_analyse_outputs (
584618 output_definitions : AnalyseOutput ,
585619 analysis : & HashMap < String , GenomeOutput > ,
586- genome_fasta_files : Vec < String > ,
620+ genome_fasta_files : & Vec < String > ,
587621) {
588622 if let Some ( mut f) = output_definitions. output_mimag_summary {
589623 writeln ! (
@@ -592,7 +626,7 @@ fn write_analyse_outputs(
592626 )
593627 . unwrap ( ) ;
594628 for genome in genome_fasta_files {
595- if let Some ( output_data) = analysis. get ( & * genome) {
629+ if let Some ( output_data) = analysis. get ( & * * genome) {
596630 writeln ! (
597631 f,
598632 "{genome}\t {completeness:.2}\t {contamination:.2}\t {r5s}\t {r16s}\t {r23s}\t {trnas}\t {mimag_quality}" ,
0 commit comments