diff --git a/README.md b/README.md index b5a3226..38d93c7 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,14 @@ Set a [minimum confidence score][conf] for kraken2 classifications $ nohuman --conf 0.5 in.fq ``` +or write the kraken2 read classification output to a file + +``` +$ nohuman -k kraken.out in.fq +``` + +``` + > [!TIP] > Compressed output will be inferred from the specified output path(s). If no output path is provided, the same > compression as the input will be used. To override the output compression format, use the `--output-type` option. @@ -222,6 +230,7 @@ Options: -t, --threads Number of threads to use in kraken2 and optional output compression. Cannot be 0 [default: 1] -H, --human Output human reads instead of removing them -C, --conf <[0, 1]> Kraken2 minimum confidence score [default: 0.0] + -k, --kraken-output Write the Kraken2 read classification output to a file -v, --verbose Set the logging level to verbose -h, --help Print help (see more with '--help') -V, --version Print version @@ -288,6 +297,9 @@ Options: [default: 0.0] + -k, --kraken-output + Write the Kraken2 read classification output to a file + -v, --verbose Set the logging level to verbose diff --git a/src/main.rs b/src/main.rs index 2bc62bd..ae56366 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,10 @@ struct Args { #[arg(short = 'C', long = "conf", value_name = "[0, 1]", default_value = "0.0", value_parser = parse_confidence_score)] confidence: f32, + /// Write the Kraken2 read classification output to a file. + #[arg(short, long, value_name = "FILE")] + kraken_output: Option, + /// Set the logging level to verbose #[arg(short, long)] verbose: bool, @@ -144,8 +148,8 @@ fn main() -> Result<()> { // error out if input files are not provided, otherwise unwrap to a variable let input = args.input.context("No input files provided")?; - let temp_kraken_output = - tempfile::NamedTempFile::new().context("Failed to create temporary kraken output file")?; + let kraken_output = args.kraken_output.unwrap_or(PathBuf::from("/dev/null")); + let kraken_output = kraken_output.to_string_lossy(); let threads = args.threads.to_string(); let confidence = args.confidence.to_string(); let db = validate_db_directory(&args.database) @@ -158,7 +162,7 @@ fn main() -> Result<()> { "--db", &db, "--output", - temp_kraken_output.path().to_str().unwrap(), + &kraken_output, "--confidence", &confidence, ];