Browse Source

AlterationCategory::TRL OK

Thomas 9 months ago
parent
commit
5ea860dae7
2 changed files with 10 additions and 10 deletions
  1. 1 1
      src/lib.rs
  2. 9 9
      src/variant/variant.rs

+ 1 - 1
src/lib.rs

@@ -718,7 +718,7 @@ mod tests {
         let variants = variant_collection::Variants::load_from_json(&path)?;
         println!("n variants {}", variants.data.len());
         variants.data.iter()
-            .filter(|v| v.alteration_category().contains(&AlterationCategory::BND))
+            .filter(|v| v.alteration_category().contains(&AlterationCategory::TRL))
             .for_each(|v| {
             println!("{:?} {}", 
                 v.vcf_variants.iter().map(|v| v.bnd_desc()).collect::<Vec<_>>(), 

+ 9 - 9
src/variant/variant.rs

@@ -247,15 +247,15 @@ impl VcfVariant {
             }
             _ => match self.svtype() {
                 Some(sv_type) => {
-                    // if let Ok(bnd_desc) = self.bnd_desc() {
-                    //     if bnd_desc.a_contig != bnd_desc.b_contig {
-                    //         AlterationCategory::TRL
-                    //     } else {
-                            // AlterationCategory::DEL
-                        // }
-                    // } else {
+                    if let Ok(bnd_desc) = self.bnd_desc() {
+                        if bnd_desc.a_contig != bnd_desc.b_contig {
+                            AlterationCategory::TRL
+                        } else {
+                            AlterationCategory::DEL
+                        }
+                    } else {
                         AlterationCategory::from(sv_type) 
-                    // }
+                    }
                 },
                 None => AlterationCategory::Other,
             },
@@ -278,7 +278,7 @@ impl VcfVariant {
     /// - The b_position cannot be parsed as a number
     pub fn bnd_desc(&self) -> anyhow::Result<BNDDesc> {
         let alt = self.alternative.to_string();
-        if self.alteration_category() == AlterationCategory::BND {
+        if alt.contains('[') || alt.contains(']') {
             let b_sens = alt.contains('[');
 
             let a_sens = if b_sens {