Browse Source

Savana CNSegment

Thomas 9 months ago
parent
commit
23d4859f43
2 changed files with 7 additions and 5 deletions
  1. 5 3
      src/callers/savana.rs
  2. 2 2
      src/lib.rs

+ 5 - 3
src/callers/savana.rs

@@ -451,9 +451,11 @@ pub struct CNSegment {
 }
 
 impl SavanaCN {
-    pub fn parse_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
-        let file = File::open(&path).context("Failed to open the file")?;
-        let reader = io::BufReader::new(file);
+    pub fn parse_file(id: &str, config: &Config) -> anyhow::Result<Self> {
+        let path = config.savana_copy_number(id);
+        let reader = get_gz_reader(&path)?;
+        // let file = File::open(&path).context("Failed to open the file")?;
+        // let reader = io::BufReader::new(file);
 
         let mut segments = Vec::new();
 

+ 2 - 2
src/lib.rs

@@ -43,7 +43,7 @@ mod tests {
 
     use self::{collection::pod5::{FlowCellCase, Pod5Collection}, commands::dorado, config::Config};
     use super::*;
-    use crate::{annotation::Annotation, callers::{clairs::ClairS, deep_variant::DeepVariant, nanomonsv::{NanomonSV, NanomonSVSolo}, savana::CNSegment, Callers}, collection::{bam, pod5::{scan_archive, FlowCells}, run_tasks, vcf::VcfCollection, Collections, CollectionsConfig}, commands::dorado::Dorado, pipes::somatic::const_stats, variant::{variant::AlterationCategory, variant_collection::VariantsStats}};
+    use crate::{annotation::Annotation, callers::{clairs::ClairS, deep_variant::DeepVariant, nanomonsv::{NanomonSV, NanomonSVSolo}, savana::{CNSegment, SavanaCN}, Callers}, collection::{bam, pod5::{scan_archive, FlowCells}, run_tasks, vcf::VcfCollection, Collections, CollectionsConfig}, commands::dorado::Dorado, pipes::somatic::const_stats, variant::{variant::AlterationCategory, variant_collection::VariantsStats}};
 
     // export RUST_LOG="debug"
     fn init() {
@@ -797,7 +797,7 @@ Ok(())
     #[test]
     fn parse_savana_seg() {
         init();
-        let r = CNSegment::parse_file("/data/longreads_basic_pipe/ADJAGBA/diag/savana/ADJAGBA_diag_hs1_HP_segmented_absolute_copy_number.tsv").unwrap();
+        let r = SavanaCN::parse_file("ADJAGBA", &config::Config::default()).unwrap().segments;
         println!("{} lines", r.len());
         println!("{:#?}", r.first().unwrap());
     }