|
|
@@ -221,15 +221,23 @@ impl BwaAlign {
|
|
|
all_ranges
|
|
|
}
|
|
|
|
|
|
- pub fn get_ref_positions_indel(&self, sequence: &str) -> Vec<((String, String, i32, i32))> {
|
|
|
- let mut all_ranges = Vec::new();
|
|
|
+ pub fn get_ref_positions_indel(&self, sequence: &str) -> Vec<(String, String, i32, i32)> {
|
|
|
+ let mut all_ranges: Vec<(String, String, i32, i32)> = Vec::new();
|
|
|
let (a, _) = self.aligner.align_read_pair(b"read_name", sequence.as_bytes(), &vec![b'2'; sequence.len()], String::new().as_bytes(), String::new().as_bytes());
|
|
|
|
|
|
if a.len() == 1 {
|
|
|
let record = a.iter().next().unwrap();
|
|
|
let (deletions, insertions) = find_deletion_insertion_ranges(record.pos() as u32 + 1, Cigar::new_from_str(&format!("{}", record.cigar())), record.is_reverse());
|
|
|
+ let contig = self.bwa_tid_contig(record.tid() as usize);
|
|
|
+ deletions.iter().for_each(|(s, e)| {
|
|
|
+ all_ranges.push(("deletion".to_string(), contig.to_string(), *s as i32, *e as i32));
|
|
|
+ });
|
|
|
+ insertions.iter().for_each(|(s, e)| {
|
|
|
+ let s = *s as i32;
|
|
|
+ let e = *e as i32;
|
|
|
+ all_ranges.push(("insertion".to_string(), contig.to_string(), s, e ));
|
|
|
+ });
|
|
|
|
|
|
- println!("{:?}", r);
|
|
|
}
|
|
|
|
|
|
all_ranges
|