|
|
@@ -5,7 +5,7 @@ use csv::ByteRecord;
|
|
|
use log::error;
|
|
|
use rust_htslib::bam::{ext::BamRecordExtensions, record::Aux, IndexedReader, Read, Record};
|
|
|
|
|
|
-use crate::io::{bam::{primary_record, primary_records}, tsv::{parse_csv_u32_into, parse_u32}};
|
|
|
+use crate::io::{bam::{fb_inv_from_record, primary_record, primary_records}, tsv::{parse_csv_u32_into, parse_u32}};
|
|
|
|
|
|
/// A genomic bin containing reads from a specific region.
|
|
|
///
|
|
|
@@ -30,6 +30,7 @@ pub struct Bin {
|
|
|
pub low_qualities: Vec<u32>,
|
|
|
/// Vec of depths
|
|
|
pub depths: Vec<u32>,
|
|
|
+ pub fb_invs: Vec<u32>,
|
|
|
}
|
|
|
|
|
|
impl Bin {
|
|
|
@@ -65,10 +66,12 @@ impl Bin {
|
|
|
bam_reader
|
|
|
.fetch((contig, start as i64, end as i64))
|
|
|
.with_context(|| format!("Failed to fetch region {}:{}-{}", contig, start, end))?;
|
|
|
+ let header = bam_reader.header().clone();
|
|
|
|
|
|
let mut reads_store: HashMap<Vec<u8>, Record> = HashMap::new();
|
|
|
let mut depths = vec![0u32; length as usize]; // Optional pseudo-depth
|
|
|
let mut low_qualities = vec![0u32; length as usize]; // Optional pseudo-depth
|
|
|
+ let mut fb_invs = vec![0u32; length as usize];
|
|
|
|
|
|
for record_result in bam_reader.rc_records() {
|
|
|
let rc_record = match record_result {
|
|
|
@@ -102,6 +105,9 @@ impl Bin {
|
|
|
if record.mapq() < min_mapq {
|
|
|
low_qualities[i] += 1;
|
|
|
}
|
|
|
+ if let Some(_fbinv) = fb_inv_from_record(record, &header, min_mapq, Some(150), Some(200)) {
|
|
|
+ fb_invs[i] += 1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -114,6 +120,7 @@ impl Bin {
|
|
|
reads_store,
|
|
|
low_qualities,
|
|
|
depths,
|
|
|
+ fb_invs,
|
|
|
})
|
|
|
}
|
|
|
/// Returns the total number of reads in this bin.
|