use std::sync::{Arc, Mutex}; pub mod commands; pub mod config; pub mod modkit; pub mod callers; pub mod runners; pub mod collection; pub mod functions; #[macro_use] extern crate lazy_static; // Define DOCKER_ID lock for handling Docker kill when ctrlc is pressed lazy_static! { static ref DOCKER_ID: Arc>> = Arc::new(Mutex::new(None)); } #[cfg(test)] mod tests { use log::info; use self::{callers::deep_variant::DeepVariantConfig, collection::pod5::{FlowCellCase, Pod5Collection}, commands::dorado, config::Config}; use super::*; use crate::{callers::{clairs::{ClairS, ClairSConfig}, deep_variant::DeepVariant, nanomonsv::{NanomonSV, NanomonSVConfig}}, collection::{bam::{self, BamType}, run_tasks, variants::VariantsCollection, vcf::VcfCollection, Collections, CollectionsConfig}, commands::{bcftools::{bcftools_keep_pass, BcftoolsConfig}, dorado::Dorado}}; #[test] fn it_works() { let bam_path = "/data/longreads_basic_pipe/PARACHINI/diag/PARACHINI_diag_hs1.bam"; modkit::modkit(bam_path); } #[test] fn run_dorado() -> anyhow::Result<()> { let case = FlowCellCase { id: "CONSIGNY".to_string(), time_point: "mrd".to_string(), barcode: "07".to_string(), pod_dir: "/data/run_data/20240326-CL/CONSIGNY-MRD-NB07_RICCO-DIAG-NB08/20240326_1355_1E_PAU78333_bc25da25/pod5_pass/barcode07".into() }; dorado::Dorado::init(case, Config::default())?.run_pipe() } #[test] fn pod5() -> anyhow::Result<()> { let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")) .build(); let _ = Pod5Collection::new( "/data/run_data", "/data/flow_cells.tsv", "/data/longreads_basic_pipe", )?; // let runs = Runs::import_dir("/home/prom/store/banana-pool/run_data", "/data/flow_cells.tsv")?; Ok(()) } #[test_log::test] fn bam() -> anyhow::Result<()> { let bam_collection = bam::load_bam_collection("/data/longreads_basic_pipe"); bam_collection .bams .iter() .filter(|b| matches!(b.bam_type, BamType::Panel(_))) .for_each(|b| println!("{b:#?}")); let u = bam_collection.get("PARACHINI", "mrd"); println!("{u:#?}"); Ok(()) } #[test_log::test] fn vcf() -> anyhow::Result<()> { let mut vcf_collection = VcfCollection::new("/data/longreads_basic_pipe"); vcf_collection.sort_by_id(); vcf_collection .vcfs .iter() .for_each(|v| v.println().unwrap()); Ok(()) } #[test_log::test] fn mux() -> anyhow::Result<()> { let cases = vec![ FlowCellCase { id: "test_04".to_string(), time_point: "diag".to_string(), barcode: "04".to_string(), pod_dir: "/data/test_d".into() }, FlowCellCase { id: "test_05".to_string(), time_point: "diag".to_string(), barcode: "05".to_string(), pod_dir: "/data/test_d".into() }, ]; Dorado::from_mux(cases, Config::default()) } #[test_log::test] fn deep_variant() -> anyhow::Result<()> { let config = DeepVariantConfig { result_dir: "/data/test".to_string(), ..DeepVariantConfig::default() }; DeepVariant::new("test_a", "diag", "/data/test_data/subset.bam", config).run(); Ok(()) } #[test_log::test] fn clairs() -> anyhow::Result<()> { let config = ClairSConfig { result_dir: "/data/test".to_string(), ..ClairSConfig::default() }; ClairS::new("test_a", "/data/test_data/subset.bam", "/data/test_data/subset_mrd.bam", config).run(); Ok(()) } #[test_log::test] fn nanomonsv() -> anyhow::Result<()> { let config = NanomonSVConfig { result_dir: "/data/test".to_string(), ..NanomonSVConfig::default() }; NanomonSV::new("test_a", "/data/test_data/subset.bam", "/data/test_data/subset_mrd.bam", config).run(); Ok(()) } // cargo test run -- --nocapture; ~/run_scripts/notify_finish.sh & #[test_log::test] fn todo() -> anyhow::Result<()> { let mut collections = Collections::new( CollectionsConfig::default() )?; info!("Runing todo with config: {:#?}", collections); collections.todo()?; println!("{:#?}", collections.tasks); println!("{}", collections.tasks.len()); Ok(()) } // export RUST_LOG="debug" #[test_log::test] fn run_t() -> anyhow::Result<()> { run_tasks(CollectionsConfig::default()) } #[test_log::test] fn somatic() -> anyhow::Result<()> { let variants_collection = VariantsCollection::new("/data/longreads_basic_pipe")?; variants_collection.data.iter().for_each(|v| println!("{}\t{}", v.id, v.path.display())); Ok(()) } #[test_log::test] fn bcftools_pass() { let config = BcftoolsConfig::default(); let id = "RICCO"; let i = format!("/data/longreads_basic_pipe/{id}/diag/nanomonsv/{id}_diag.nanomonsv.result.vcf"); let o = format!("/data/longreads_basic_pipe/{id}/diag/nanomonsv/{id}_diag_nanomonsv_PASSED.vcf.gz"); bcftools_keep_pass(&i, &o, config).unwrap(); } #[test_log::test] fn bam_ok() -> anyhow::Result<()> { let collections = Collections::new( CollectionsConfig::default() )?; let mut res: Vec<_> = collections.bam.by_id_completed(15.0, 10.0).iter().map(|b| { (b.id.to_string(), b.time_point.to_string(), b.path.to_str().unwrap().to_string()) }).collect(); res.sort_by_key(|b| b.1.clone()); res.sort_by_key(|b| b.0.clone()); res.iter().for_each(|(id, tp, path)| println!("{id}\t{tp}\t{path}")); Ok(()) } #[test_log::test] fn todo_assembler() -> anyhow::Result<()> { let mut collections = Collections::new( CollectionsConfig::default() )?; collections.todo_assembler()?; Ok(()) } }