Skip to content

Commit

Permalink
feat: add kraken2 classification output file option -k
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Oct 1, 2024
1 parent 419ede9 commit a4146bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -222,6 +230,7 @@ Options:
-t, --threads <INT> 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 <FILE> 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
Expand Down Expand Up @@ -288,6 +297,9 @@ Options:

[default: 0.0]
-k, --kraken-output <FILE>
Write the Kraken2 read classification output to a file

-v, --verbose
Set the logging level to verbose

Expand Down
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,

/// Set the logging level to verbose
#[arg(short, long)]
verbose: bool,
Expand Down Expand Up @@ -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)
Expand All @@ -158,7 +162,7 @@ fn main() -> Result<()> {
"--db",
&db,
"--output",
temp_kraken_output.path().to_str().unwrap(),
&kraken_output,
"--confidence",
&confidence,
];
Expand Down

0 comments on commit a4146bb

Please sign in to comment.