|
@@ -1,15 +1,16 @@
|
|
|
use anyhow::{Ok, Result};
|
|
use anyhow::{Ok, Result};
|
|
|
use log::info;
|
|
use log::info;
|
|
|
use minimap2::{Aligner, Mapping};
|
|
use minimap2::{Aligner, Mapping};
|
|
|
|
|
+use noodles_fasta as fasta;
|
|
|
use rust_htslib::bam::{self, Record};
|
|
use rust_htslib::bam::{self, Record};
|
|
|
use std::{
|
|
use std::{
|
|
|
collections::{HashMap, VecDeque},
|
|
collections::{HashMap, VecDeque},
|
|
|
fmt,
|
|
fmt,
|
|
|
- fs::{File, self},
|
|
|
|
|
- io::{BufWriter, Write}, process::{Command, Stdio},
|
|
|
|
|
|
|
+ fs::{self, File},
|
|
|
|
|
+ io::{BufWriter, Write},
|
|
|
|
|
+ process::{Command, Stdio},
|
|
|
};
|
|
};
|
|
|
use uuid::Uuid;
|
|
use uuid::Uuid;
|
|
|
-use noodles_fasta as fasta;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct Genome {
|
|
pub struct Genome {
|
|
@@ -329,10 +330,16 @@ impl Contig {
|
|
|
fs::create_dir_all(contig_dir.clone())?;
|
|
fs::create_dir_all(contig_dir.clone())?;
|
|
|
|
|
|
|
|
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() )]);
|
|
|
|
|
-
|
|
|
|
|
- let reads_path = format!("{contig_dir}/reads.fq");
|
|
|
|
|
- write_fastq(&reads_path, &self.supporting_records)?;
|
|
|
|
|
|
|
+ write_fasta(&fasta_path, &vec![(self.id.clone(), self.sequence.clone())]);
|
|
|
|
|
+
|
|
|
|
|
+ let reads_path = format!("{contig_dir}/reads.fa");
|
|
|
|
|
+ let n_reads = self.supporting_records.clone().into_iter().map(|r| {
|
|
|
|
|
+ (
|
|
|
|
|
+ String::from_utf8(r.qname().to_vec()).unwrap(),
|
|
|
|
|
+ String::from_utf8(r.seq().as_bytes()).unwrap(),
|
|
|
|
|
+ )
|
|
|
|
|
+ }).collect();
|
|
|
|
|
+ write_fasta(&reads_path, &n_reads);
|
|
|
|
|
|
|
|
let bam_path = format!("{contig_dir}/{}.bam", self.id);
|
|
let bam_path = format!("{contig_dir}/{}.bam", self.id);
|
|
|
create_bam(&fasta_path, &reads_path, &bam_path)?;
|
|
create_bam(&fasta_path, &reads_path, &bam_path)?;
|