Thomas 1 жил өмнө
parent
commit
79c8dbeec4
3 өөрчлөгдсөн 129 нэмэгдсэн , 694 устгасан
  1. 101 620
      Cargo.lock
  2. 3 3
      Cargo.toml
  3. 25 71
      src/lib.rs

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 101 - 620
Cargo.lock


+ 3 - 3
Cargo.toml

@@ -10,7 +10,7 @@ env_logger = "^0.10.1"
 test-env-log = "0.2.8"
 minimap2 = { git = "https://github.com/jguhlin/minimap2-rs", features = ["simde"] }
 aligner_client = { git = "https://git.t0m4.fr/Thomas/aligner_client.git"}
-rust-htslib = "0.46.0"
+rust-htslib = "0.47.0"
 anyhow = "1.0.75"
 log = "0.4.19"
 rand = "0.8.4"
@@ -19,8 +19,6 @@ seq_io = "0.3.2"
 noodles-fasta = "0.34.0"
 noodles-vcf = "0.51.0"
 crossbeam = "0.8.4"
-pileup = { git = "https://git.t0m4.fr/Thomas/pileup.git" }
-libVariant = { git = "https://git.t0m4.fr/Thomas/libVariant.git" }
 crossbeam-channel = "0.5.12"
 test-log = "0.2.15"
 num-format = "0.4.4"
@@ -29,3 +27,5 @@ indicatif = {version = "0.17.8", features = ["rayon"]}
 indicatif-log-bridge = "0.2.2"
 rayon = "1.8.0"
 dashmap = "5.5.3"
+duct = "0.13.7"
+pandora_lib_variants = {git = "https://git.t0m4.fr/Thomas/pandora_lib_variants.git"}

+ 25 - 71
src/lib.rs

@@ -184,6 +184,7 @@ impl ContigRef {
             ContigRef::Ambigous(a) => Some(to_desc(&mut a.to_owned())),
         }
     }
+
     pub fn hgvs(&self) -> Option<String> {
         let uk = "UNKNOWN".to_string();
         match self {
@@ -388,12 +389,15 @@ impl Genome {
             chromosomes: HashMap::new(),
         }
     }
+
     pub fn iter(&self) -> std::collections::hash_map::Iter<'_, String, Chromosome> {
         self.chromosomes.iter()
     }
+    
     pub fn contigs(&self) -> impl Iterator<Item = &Contig> {
         self.chromosomes.iter().flat_map(|(_, e)| e.iter())
     }
+
     pub fn add_contig(
         &mut self,
         id: String,
@@ -531,6 +535,10 @@ impl Genome {
         Ok(genome)
     }
 
+    pub fn from_dir_bed(dir: &str)  {
+
+    }
+
     // pub fn write_records(&self, file: &str) {
     //     let mut records =  Vec::new();
     //     for (name, chromosome) in self.chromosomes.iter() {
@@ -996,7 +1004,7 @@ mod tests {
     use dashmap::DashSet;
     use indicatif::MultiProgress;
     use indicatif_log_bridge::LogWrapper;
-    use libVariant::{in_out::dict_reader::read_dict, variants::Variant};
+    use pandora_lib_variants::{in_out::dict_reader::read_dict, variants::Variant};
 
     use super::*;
     use crate::{
@@ -1055,13 +1063,13 @@ mod tests {
         let pos = vec![0, i32::MAX];
         let mut all_ways = Vec::new();
         if chrom.len() > 1 {
-        (0..4).into_iter().for_each(|i| {
-            let start_pos = if i < 2 { 0 } else { i32::MAX };
-            let end_pos = pos[i % 2];
-
             (0..4).into_iter().for_each(|i| {
-                let start_sens = if i < 2 { true } else { false };
-                let end_sens = sens[i % 2];
+                let start_pos = if i < 2 { 0 } else { i32::MAX };
+                let end_pos = pos[i % 2];
+
+                (0..4).into_iter().for_each(|i| {
+                    let start_sens = if i < 2 { true } else { false };
+                    let end_sens = sens[i % 2];
                     (0..4).into_iter().for_each(|i| {
                         let start_chr = if i < 2 { chrom[0] } else { chrom[1] };
                         let end_chr = chrom[i % 2];
@@ -1083,8 +1091,8 @@ mod tests {
                             all_ways.push(s);
                         }
                     });
+                });
             });
-        });
         } else {
             let start_chr = chrom[0];
             let end_chr = chrom[0];
@@ -1161,71 +1169,17 @@ mod tests {
     }
 
     #[test]
-    fn phasing() -> Result<()> {
-        let name = "CAMARA";
-        let min_records = 2;
-        let min_var = 2;
-
-        let format = CustomFormat::builder()
-            .grouping(Grouping::Standard)
-            .minus_sign("-")
-            .separator("_")
-            .build()
-            .unwrap();
-
-        let logger =
-            env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
-                .build();
-        let multi = MultiProgress::new();
-        LogWrapper::new(multi.clone(), logger).try_init().unwrap();
-
-        let bam_path = &format!("/data/longreads_basic_pipe/{name}/diag/{name}_diag_hs1.bam");
-        let somatic_path =
-            &format!("/data/longreads_basic_pipe/{name}/diag/{name}_constit.bytes.gz");
-        let bed = &format!("/data/longreads_basic_pipe/{name}/diag/{name}_phases.bed");
-
-        let variants =
-            libVariant::variants::Variants::new_from_bytes(name, &somatic_path, multi.clone())?;
-
-        info!(
-            "Variants loaded {}.",
-            variants.len().to_formatted_string(&format)
-        );
-
-        let mut variants: Vec<Variant> = variants
-            .data
-            .into_par_iter()
-            .filter(|v| {
-                let mut v = v.clone();
-                v.vaf() > 0.4 && v.vaf() < 0.6
-            })
-            .collect();
-
-        let contigs = DashSet::new();
-        variants.par_iter().for_each(|v| {
-            contigs.insert(v.contig.to_string());
-        });
+    fn dir() {
+        todo!();
+        init();
 
-        variants.par_sort_by(|a, b| a.position.cmp(&b.position));
+        let id = "ROBIN";
+        let chrom = vec!["chr9"];
+        info!("This record will be captured by `cargo test`");
 
-        let dict = read_dict("/data/ref/hs1/chm13v2.0.dict")?;
-        for (contig, _) in dict {
-            if !contigs.contains(&contig) {
-                continue;
-            }
-            let v: Vec<_> = variants
-                .clone()
-                .into_par_iter()
-                .filter(|v| v.contig == contig)
-                .collect();
-            if variants.len() > 1 {
-                info!("{contig}: {} variants", v.len());
-                let phases = variants_phasing(v, bam_path, min_records, &multi);
-                write_phases_bed(&phases, min_var, bam_path, &contig, bed)?;
-            }
-        }
+        let dir = format!("/data/longreads_basic_pipe/{id}/diag/scan/reads/{chrom}");
 
-        // TODO: assign somatic to constit phase
-        Ok(())
+        // Load from fasta in dir.
+        let genome = Genome::from_contigs_sequences(&dir).unwrap();
     }
 }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно