|
@@ -331,6 +331,7 @@ impl Contig {
|
|
|
|
|
|
|
|
let fasta_path = format!("{contig_dir}/contig.fa");
|
|
let fasta_path = format!("{contig_dir}/contig.fa");
|
|
|
write_fasta(&fasta_path, &vec![(self.id.clone(), self.sequence.clone())]);
|
|
write_fasta(&fasta_path, &vec![(self.id.clone(), self.sequence.clone())]);
|
|
|
|
|
+ write_fai(&fasta_path);
|
|
|
|
|
|
|
|
let reads_path = format!("{contig_dir}/reads.fa");
|
|
let reads_path = format!("{contig_dir}/reads.fa");
|
|
|
let n_reads = self.supporting_records.clone().into_iter().map(|r| {
|
|
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 write_aln_sh()
|
|
|
|
|
|
|
|
pub fn create_bam(ref_path: &str, reads_path: &str, bam_path: &str) -> Result<()> {
|
|
pub fn create_bam(ref_path: &str, reads_path: &str, bam_path: &str) -> Result<()> {
|
|
|
let rg_id = uuid::Uuid::new_v4();
|
|
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("-t")
|
|
|
.arg("128")
|
|
.arg("128")
|
|
|
.arg("-ax")
|
|
.arg("-ax")
|
|
|
.arg("map-ont")
|
|
.arg("map-ont")
|
|
|
.arg("-R")
|
|
.arg("-R")
|
|
|
.arg(format!(
|
|
.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(ref_path)
|
|
|
.arg(reads_path)
|
|
.arg(reads_path)
|
|
@@ -510,6 +515,8 @@ pub fn create_bam(ref_path: &str, reads_path: &str, bam_path: &str) -> Result<()
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
#[cfg(test)]
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
mod tests {
|
|
|
use super::*;
|
|
use super::*;
|