|
|
@@ -1,8 +1,8 @@
|
|
|
use std::{
|
|
|
fs,
|
|
|
- io::{self, BufRead, BufReader, Write},
|
|
|
+ io::{BufRead, BufReader},
|
|
|
process::Command,
|
|
|
- time::{Duration, SystemTime},
|
|
|
+ time::SystemTime,
|
|
|
};
|
|
|
|
|
|
pub trait Run {
|
|
|
@@ -23,7 +23,7 @@ pub struct Dorado {
|
|
|
start_time: SystemTime,
|
|
|
end_time: SystemTime,
|
|
|
is_done: bool,
|
|
|
- log: Vec<String>
|
|
|
+ log: Vec<String>,
|
|
|
}
|
|
|
|
|
|
impl Dorado {
|
|
|
@@ -59,7 +59,7 @@ impl Run for Dorado {
|
|
|
|
|
|
if !std::path::Path::new(ref_mmi).exists() {
|
|
|
Command::new("minimap2")
|
|
|
- .args(&["-x", "map-ont", "-d", ref_mmi, ref_fa])
|
|
|
+ .args(["-x", "map-ont", "-d", ref_mmi, ref_fa])
|
|
|
.output()
|
|
|
.expect("Failed to execute minimap2");
|
|
|
}
|
|
|
@@ -76,7 +76,7 @@ impl Run for Dorado {
|
|
|
|
|
|
if !std::path::Path::new(&bam).exists() {
|
|
|
let dorado_output = Command::new(dorado_bin)
|
|
|
- .args(&[
|
|
|
+ .args([
|
|
|
"basecaller",
|
|
|
"sup,5mC_5hmC",
|
|
|
pod_dir,
|
|
|
@@ -95,7 +95,7 @@ impl Run for Dorado {
|
|
|
}
|
|
|
|
|
|
let samtools_view_output = Command::new("samtools")
|
|
|
- .args(&["view", "-h", "-@ 20", "-b", "/dev/stdin"])
|
|
|
+ .args(["view", "-h", "-@ 20", "-b", "/dev/stdin"])
|
|
|
.stdin(dorado_output.stdout.unwrap())
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
.stderr(std::process::Stdio::piped())
|
|
|
@@ -107,7 +107,7 @@ impl Run for Dorado {
|
|
|
}
|
|
|
|
|
|
Command::new("samtools")
|
|
|
- .args(&["sort", "-@ 30", "/dev/stdin", "-o", &bam])
|
|
|
+ .args(["sort", "-@ 30", "/dev/stdin", "-o", &bam])
|
|
|
.stdin(samtools_view_output.stdout.unwrap())
|
|
|
.output()
|
|
|
.expect("Failed to execute samtools sort");
|
|
|
@@ -141,7 +141,7 @@ impl Run for Dorado {
|
|
|
// }
|
|
|
|
|
|
Command::new("samtools")
|
|
|
- .args(&["index", "-@ 150", &bam])
|
|
|
+ .args(["index", "-@ 150", &bam])
|
|
|
.output()
|
|
|
.expect("Failed to execute samtools index");
|
|
|
}
|
|
|
@@ -151,16 +151,15 @@ impl Run for Dorado {
|
|
|
println!("[pipe] Quality control of BAM: {}", bam);
|
|
|
|
|
|
Command::new("cramino")
|
|
|
- .args(&["-t", "150", "--hist", "--checksum", "--karyotype", &bam])
|
|
|
+ .args(["-t", "150", "--hist", "--checksum", "--karyotype", &bam])
|
|
|
.output()
|
|
|
- .expect("Failed to execute cramino")
|
|
|
- .stdout;
|
|
|
+ .expect("Failed to execute cramino");
|
|
|
}
|
|
|
|
|
|
let mod_summary = format!("{}/{}_{}_5mC_5hmC_summary.txt", time_dir, name, time);
|
|
|
if !std::path::Path::new(&mod_summary).exists() {
|
|
|
Command::new("modkit")
|
|
|
- .args(&["summary", "-t", "50", &bam])
|
|
|
+ .args(["summary", "-t", "50", &bam])
|
|
|
.output()
|
|
|
.expect("Failed to execute modkit summary");
|
|
|
}
|
|
|
@@ -168,13 +167,13 @@ impl Run for Dorado {
|
|
|
let fastq = format!("{}/{}/{}/{}_{}.fastq.gz", case_dir, name, time, name, time);
|
|
|
if !std::path::Path::new(&fastq).exists() {
|
|
|
Command::new("samtools")
|
|
|
- .args(&["fastq", "-@ 150", &bam])
|
|
|
+ .args(["fastq", "-@ 150", &bam])
|
|
|
.stdout(std::process::Stdio::piped())
|
|
|
.spawn()
|
|
|
.expect("Failed to execute samtools fastq");
|
|
|
|
|
|
Command::new("crabz")
|
|
|
- .args(&["-f", "bgzf", "-", "-o", &fastq])
|
|
|
+ .args(["-f", "bgzf", "-", "-o", &fastq])
|
|
|
.stdin(std::process::Stdio::piped())
|
|
|
.output()
|
|
|
.expect("Failed to execute crabz");
|
|
|
@@ -199,7 +198,7 @@ fn print_stderr(stderr: std::process::ChildStderr, save: &mut Vec<String>) {
|
|
|
Ok(line) => {
|
|
|
eprintln!("{}", line);
|
|
|
save.push(line);
|
|
|
- },
|
|
|
+ }
|
|
|
Err(err) => eprintln!("Error reading stderr: {}", err),
|
|
|
}
|
|
|
}
|