use pandora_lib_scan::par_whole_scan;

#[derive(Debug, Clone)]
pub struct WholeScanConfig {
    pub result_dir: String,
    pub scan_dir: String,
    pub dict_file: String,
}

impl Default for WholeScanConfig {
    fn default() -> Self {
        Self {
            result_dir: "/data/longreads_basic_pipe".to_string(),
            scan_dir: "scan".to_string(),
            dict_file: "/data/ref/hs1/chm13v2.0.dict".to_string(),
        }
    }
}

#[derive(Debug)]
pub struct WholeScan {
    pub id: String,
    pub time_point: String,
    pub bam_path: String,
    pub config: WholeScanConfig,
}

impl WholeScan {
    pub fn new(
        id: String,
        time_point: String,
        bam_path: String,
        config: WholeScanConfig
    ) -> anyhow::Result<Self> {
        Ok(WholeScan {
            id,
            time_point,
            config,
            bam_path,
        })
    }
    pub fn run(&self) -> anyhow::Result<()> {
        let scan_dir = format!(
            "{}/{}/{}/{}",
            &self.config.result_dir, self.id, self.time_point, self.config.scan_dir
        );
        par_whole_scan(&self.config.dict_file, &self.bam_path, &scan_dir)?;
        Ok(())
    }
}
