Skip to content

Commit

Permalink
v0.5.5 with output format similar to strobealign
Browse files Browse the repository at this point in the history
  • Loading branch information
bluenote-1577 committed May 30, 2024
1 parent 2515aa7 commit 1a5403c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fairy"
version = "0.5.4"
version = "0.5.5"
edition = "2021"
license = "MIT OR Apache-2.0"

Expand Down
3 changes: 3 additions & 0 deletions src/cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@ pub struct ContainArgs {
pub out_file_name: Option<String>,
#[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,

}
13 changes: 9 additions & 4 deletions src/contain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,28 @@ fn print_cov_matrix(ani_results: Vec<AniResult>, read_files: &FxHashSet<String>,

//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::<Vec<&str>>()[0]).unwrap();
if !args.concoct_format{
if !no_var_and_mean{
write!(writer, "\t{}", contig_to_size[contig]).unwrap();
}
let mut avg_cov = 0.;
Expand All @@ -63,11 +68,11 @@ fn print_cov_matrix(ani_results: Vec<AniResult>, read_files: &FxHashSet<String>,
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();
Expand Down

0 comments on commit 1a5403c

Please sign in to comment.