From 1a5403c0a825ff1241c1950eea4c346ab14186d6 Mon Sep 17 00:00:00 2001 From: bluenote-1577 Date: Thu, 30 May 2024 17:53:45 +0000 Subject: [PATCH] v0.5.5 with output format similar to strobealign --- CHANGELOG.md | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/cmdline.rs | 3 +++ src/contain.rs | 13 +++++++++---- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a57936..db77e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## fairy v0.5.5 + +* Added the --aemb_format option which is the same as strobealign's format (for single samples). + ## fairy v0.5.4 Updating to try and fix bioconda bug. diff --git a/Cargo.lock b/Cargo.lock index 4d3ecaf..4db6b7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,7 +330,7 @@ dependencies = [ [[package]] name = "fairy" -version = "0.5.4" +version = "0.5.5" dependencies = [ "assert_cmd", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 58c1040..42b9196 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fairy" -version = "0.5.4" +version = "0.5.5" edition = "2021" license = "MIT OR Apache-2.0" diff --git a/src/cmdline.rs b/src/cmdline.rs index 034e3d8..40969c8 100644 --- a/src/cmdline.rs +++ b/src/cmdline.rs @@ -117,4 +117,7 @@ pub struct ContainArgs { pub out_file_name: Option, #[clap(long="maxbin-format", help = "Remove contig length, average depth, and variance columns. (default: MetaBAT2 format with variances)", help_heading="OUTPUT")] pub concoct_format: bool, + #[clap(long="aemb-format", help = "Strobealign --aemb format (default: MetaBAT2 format with variances)", help_heading="OUTPUT")] + pub aemb_format: bool, + } diff --git a/src/contain.rs b/src/contain.rs index 1098ee5..7ea471b 100644 --- a/src/contain.rs +++ b/src/contain.rs @@ -35,23 +35,28 @@ fn print_cov_matrix(ani_results: Vec, read_files: &FxHashSet, //sort(&mut contig_list_sorted); sort(&mut read_list_sorted); + let no_var_and_mean = args.concoct_format | args.aemb_format; if args.concoct_format{ write!(writer, "contigName").unwrap(); for read_name in read_list_sorted.iter(){ write!(writer, "\t{}", read_name).unwrap(); } + write!(writer, "\n").unwrap(); + } + else if args.aemb_format{ } else{ write!(writer, "contigName\tcontigLen\ttotalAvgDepth").unwrap(); for read_name in read_list_sorted.iter(){ write!(writer, "\t{}\t{}-var", read_name, read_name).unwrap(); } + write!(writer, "\n").unwrap(); } - write!(writer, "\n").unwrap(); + for contig in contig_list_sorted{ write!(writer, "{}", contig.split(' ').collect::>()[0]).unwrap(); - if !args.concoct_format{ + if !no_var_and_mean{ write!(writer, "\t{}", contig_to_size[contig]).unwrap(); } let mut avg_cov = 0.; @@ -63,11 +68,11 @@ fn print_cov_matrix(ani_results: Vec, read_files: &FxHashSet, else{ } avg_cov /= read_list_sorted.len() as f64; - if !args.concoct_format{ + if !no_var_and_mean{ write!(writer, "\t{}", avg_cov).unwrap(); } for read in read_list_sorted.iter(){ - if !args.concoct_format{ + if !no_var_and_mean{ if matrix.contains_key(contig) && matrix[contig].contains_key(read){ let (cov, var) = matrix[&contig][read]; write!(writer, "\t{}\t{}", cov, var).unwrap();