Thomas 2 سال پیش
والد
کامیت
70ffba8f0b
1فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 10 3
      src/lib.rs

+ 10 - 3
src/lib.rs

@@ -331,6 +331,7 @@ impl Contig {
 
         let fasta_path = format!("{contig_dir}/contig.fa");
         write_fasta(&fasta_path, &vec![(self.id.clone(), self.sequence.clone())]);
+        write_fai(&fasta_path);
 
         let reads_path = format!("{contig_dir}/reads.fa");
         let n_reads = self.supporting_records.clone().into_iter().map(|r| {
@@ -459,20 +460,24 @@ pub fn write_fasta(fasta_path: &str, d: &Vec<(String, String)>) {
     }
 }
 
+pub fn write_fai(path: &str) {
+    let mut faidx = Command::new("samtools").arg("faidx").arg(path).spawn().expect("Samtools faidx failed to start");
+    faidx.wait().unwrap();
+}
+
 // pub fn write_aln_sh()
 
 pub fn create_bam(ref_path: &str, reads_path: &str, bam_path: &str) -> Result<()> {
     let rg_id = uuid::Uuid::new_v4();
-    let output_file = File::create("test.sam").unwrap();
 
-    let mut mm2 = Command::new("minimap2")
+    let mm2 = Command::new("minimap2")
         .arg("-t")
         .arg("128")
         .arg("-ax")
         .arg("map-ont")
         .arg("-R")
         .arg(format!(
-            "@RG\\tPL:ONTASM_PROM\\tID:ONTASM_${rg_id}\\tSM:${rg_id}\\tLB:ONTASM_NB_PROM"
+            "@RG\\tPL:ONTASM_PROM\\tID:ONTASM_{rg_id}\\tSM:{rg_id}\\tLB:ONTASM_NB_PROM"
         ))
         .arg(ref_path)
         .arg(reads_path)
@@ -510,6 +515,8 @@ pub fn create_bam(ref_path: &str, reads_path: &str, bam_path: &str) -> Result<()
     Ok(())
 }
 
+
+
 #[cfg(test)]
 mod tests {
     use super::*;