From bcd7ac9ed2fbc9f300ae415ae96138bbbd698a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommi=20M=C3=A4klin?= Date: Fri, 22 Sep 2023 16:04:56 +0300 Subject: [PATCH 1/2] Add optional output filename `-o` option to `ska weed`. --- src/cli.rs | 4 ++++ src/lib.rs | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index b598634..e004b7a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -268,6 +268,10 @@ pub enum Commands { /// A FASTA file containing sequences to remove weed_file: Option, + /// Output filename (omit to overwrite input file) + #[arg(short)] + output: Option, + /// Remove k-mers not in the weed_file #[arg(long, default_value_t = false)] reverse: bool, diff --git a/src/lib.rs b/src/lib.rs index 264cfda..de48c27 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,7 +243,8 @@ //! //! Remove (weed) split k-mers from an `.skf` file. The split k-mers to be removed //! are generated from a FASTA file, which may for example contain known transposons or -//! other repeat sequences. As with `delete`, the input `.skf` file is overwritten. +//! other repeat sequences. As with `delete`, the input `.skf` file is overwritten by default. +//! Use `-o` to write the results to a new file instead of overwriting the input `.skf`. //! //! ```bash //! ska weed all_samples.skf MGEs.fa @@ -635,6 +636,7 @@ pub fn main() { Commands::Weed { skf_file, weed_file, + output, reverse, min_freq, ambig_mask, @@ -649,7 +651,7 @@ pub fn main() { *min_freq, filter, *ambig_mask, - skf_file, + if output.is_none() { skf_file } else { output.as_ref().unwrap().as_str() }, ); } else if let Ok(mut ska_array) = MergeSkaArray::::load(skf_file) { weed( @@ -659,7 +661,7 @@ pub fn main() { *min_freq, filter, *ambig_mask, - skf_file, + if output.is_none() { skf_file } else { output.as_ref().unwrap().as_str() }, ); } else { panic!("Could not read input file: {skf_file}"); From 1a061afb42e04ad2f8f7fed47e6942409a52b873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommi=20M=C3=A4klin?= Date: Mon, 25 Sep 2023 10:06:35 +0300 Subject: [PATCH 2/2] Bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7be10cf..24c93d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ska" -version = "0.3.2" +version = "0.3.3" authors = [ "John Lees ", "Simon Harris ",