diff --git a/.gitignore b/.gitignore index 99c8fce..fecf281 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode test.feather Cargo.lock +test.txt diff --git a/Cargo.lock b/Cargo.lock index 9d65f01..1c658a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,7 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cramino" -version = "0.12.0" +version = "0.13.0" dependencies = [ "arrow", "checksums", diff --git a/Cargo.toml b/Cargo.toml index 1d03fcc..d82d507 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cramino" -version = "0.12.0" +version = "0.13.0" edition = "2021" authors = ["Wouter De Coster decosterwouter@gmail.com"] license = "MIT" diff --git a/src/extract_from_bam.rs b/src/extract_from_bam.rs index 21d9fd0..853792b 100644 --- a/src/extract_from_bam.rs +++ b/src/extract_from_bam.rs @@ -58,7 +58,11 @@ pub fn extract(args: &crate::Cli) -> Data { .inspect(|_| all_counts += 1) .filter(|read| filter_closure(read)) { - lengths.push(read.seq_len() as u64); + lengths.push( + read.seq_len() as u64 + - read.cigar().leading_softclips() as u64 + - read.cigar().trailing_softclips() as u64, + ); if args.karyotype || args.phased { tids.push(read.tid()); } diff --git a/src/main.rs b/src/main.rs index 4023caa..b5b4847 100644 --- a/src/main.rs +++ b/src/main.rs @@ -154,7 +154,7 @@ fn generate_main_output( panic!(); } let data_yield: u64 = lengths.iter().sum::(); - println!("Number of reads\t{num_reads}"); + println!("Number of alignments\t{num_reads}"); println!( "% from total reads\t{:.2}", (num_reads as f64) / (all_reads as f64) * 100.0 @@ -213,7 +213,7 @@ fn extract() { #[test] fn extract_ubam() { let args = Cli { - input: "test-data/small-test-phased.bam".to_string(), + input: "test-data/small-test-ubam.bam".to_string(), threads: 8, reference: None, min_read_len: 0,