Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ or write the kraken2 read classification output to a file
$ nohuman -k kraken.out in.fq
```

or write the kraken2 [sample report](https://github.com/DerrickWood/kraken2/blob/master/docs/MANUAL.markdown#sample-report-output-format) to file

```
$ nohuman -r kraken.report 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 @@ -229,6 +235,7 @@ Options:
-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
-r, --kraken-report <FILE> Write the Kraken2 report with aggregate counts/clade to 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 @@ -297,6 +304,9 @@ Options:

-k, --kraken-output <FILE>
Write the Kraken2 read classification output to a file

-r, --kraken-report <FILE>
Write the Kraken2 report with aggregate counts/clade to file

-v, --verbose
Set the logging level to verbose
Expand Down
6 changes: 2 additions & 4 deletions src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl std::fmt::Display for CompressionFormat {
CompressionFormat::Xz => "xz",
CompressionFormat::Zstd => "zst",
};
write!(f, "{}", format)
write!(f, "{format}",)
}
}

Expand Down Expand Up @@ -228,9 +228,7 @@ where
.compression_level(Compression::default())
.from_writer(output);
let bytes = io::copy(input, &mut encoder)?;
encoder
.finish()
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
encoder.finish().map_err(io::Error::other)?;

Ok(bytes)
}
Expand Down
2 changes: 1 addition & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn compute_md5(path: &Path) -> Result<String, DownloadError> {
hasher.consume(&buffer[..n]);
}
let result = hasher.compute();
Ok(format!("{:x}", result))
Ok(format!("{result:x}",))
}

async fn download_from_url(url: &str, dest: &Path) -> Result<(), DownloadError> {
Expand Down
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ impl CommandRunner {

let stderr_log = String::from_utf8_lossy(&output.stderr);
if !output.status.success() {
return Err(io::Error::new(
io::ErrorKind::Other,
format!("{} failed with stderr {}", self.command, stderr_log),
));
return Err(io::Error::other(format!(
"{} failed with stderr {}",
self.command, stderr_log
)));
}

debug!("kraken2 stderr:\n {}", stderr_log);
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn check_path_exists<S: AsRef<OsStr> + ?Sized>(s: &S) -> Result<PathBuf, Str
if path.exists() {
Ok(path)
} else {
Err(format!("{:?} does not exist", path))
Err(format!("{path:?} does not exist",))
}
}

Expand Down Expand Up @@ -152,8 +152,7 @@ pub fn validate_db_directory(path: &Path) -> Result<PathBuf, String> {
}

Err(format!(
"Required files ({}) not found in {:?} or its 'db' subdirectory",
files_str, path
"Required files ({files_str}) not found in {path:?} or its 'db' subdirectory",
))
}

Expand Down
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct Args {
#[arg(short, long, value_name = "FILE")]
kraken_output: Option<PathBuf>,

/// Write the Kraken2 report with aggregate counts/clade to file
#[arg(short = 'r', long, value_name = "FILE")]
kraken_report: Option<PathBuf>,

/// Set the logging level to verbose
#[arg(short, long)]
verbose: bool,
Expand Down Expand Up @@ -166,6 +170,11 @@ fn main() -> Result<()> {
"--confidence",
&confidence,
];

if let Some(report_path) = args.kraken_report.as_ref().and_then(|p| p.to_str()) {
kraken_cmd.extend(&["--report", report_path]);
}

match input.len() {
0 => bail!("No input files provided"),
2 => kraken_cmd.push("--paired"),
Expand Down Expand Up @@ -306,6 +315,14 @@ fn main() -> Result<()> {
}
}

if kraken_output != "/dev/null" {
info!("Kraken output file written to: {:?}", &kraken_output);
}

if let Some(report_path) = &args.kraken_report {
info!("Kraken report file written to: {:?}", &report_path);
}

// cleanup the temporary directory, but only issue a warning if it fails
if let Err(e) = tmpdir.close() {
warn!("Failed to remove temporary output directory: {}", e);
Expand Down
Loading