Ver Fonte

error substraction zero

Your Name há 1 ano atrás
pai
commit
a4032dfcb5
2 ficheiros alterados com 8 adições e 2 exclusões
  1. 7 1
      src/bam.rs
  2. 1 1
      src/lib.rs

+ 7 - 1
src/bam.rs

@@ -124,6 +124,7 @@ pub fn get_all_positions(
     bam_path: &str,
     // bam: &mut IndexedReader,
 ) -> anyhow::Result<Vec<(String, u32, u32)>> {
+let tol = 2;
     let mut positions = Vec::new();
     let qname = record.qname();
     let mut bam = rust_htslib::bam::IndexedReader::from_path(bam_path).unwrap();
@@ -143,12 +144,17 @@ pub fn get_all_positions(
             let start: u32 = parts.get(1).unwrap().parse().unwrap();
             // SAM format is 1-based!
             let start = start - 1;
+            let start_tol = if start >= tol {
+                start - tol
+            } else {
+                    start
+                };
             // let strand = parts.get(2).unwrap();
             // // CIGAR SA != CIGAR can't calculate the end from it.
             // let cigar_str = *parts.get(3).unwrap();
             // let end = calculate_end_position(start, cigar_str).unwrap();
 
-            bam.fetch((chr, start - 2, start + 2))?;
+            bam.fetch((chr, start_tol, start + tol))?;
             let mut founded = false;
             for record in bam.records().flatten() {
                 if qname == record.qname() {

+ 1 - 1
src/lib.rs

@@ -370,7 +370,7 @@ mod tests {
     #[test]
     fn whole() {
         init();
-        let id = "ROBIN";
+        let id = "HENAUX";
         let bam_path = format!("/data/longreads_basic_pipe/{id}/diag/{id}_diag_hs1.bam");
         let out_dir = format!("/data/longreads_basic_pipe/{id}/diag/scan");
         par_whole_scan("/data/ref/hs1/chm13v2.0.dict", &bam_path, &out_dir).unwrap();