diff --git a/src/cmd/dazzname.rs b/src/cmd/dazzname.rs index 03ea33b..5f4dba8 100644 --- a/src/cmd/dazzname.rs +++ b/src/cmd/dazzname.rs @@ -53,11 +53,12 @@ pub fn execute(args: &ArgMatches) -> anyhow::Result<()> { let outfile = args.get_one::("outfile").unwrap(); let mut fa_out = fasta::Writer::new(intspan::writer(outfile)); - let mut writer_rplc = intspan::writer(&format!("{}.replace.tsv", outfile)); let opt_prefix = args.get_one::("prefix").unwrap(); let mut opt_start = *args.get_one::("start").unwrap(); + let mut rplc_lines = vec![]; + //---------------------------- // Ops //---------------------------- @@ -85,12 +86,19 @@ pub fn execute(args: &ArgMatches) -> anyhow::Result<()> { .expect("Write fasta file failed"); if !is_no_replace { - writer_rplc.write_fmt(format_args!("{}\t{}\n", name_new, name))?; + rplc_lines.push(format!("{}\t{}", name_new, name)); } opt_start += 1; } } + if !is_no_replace { + intspan::write_lines( + &format!("{}.replace.tsv", outfile), + &rplc_lines.iter().map(AsRef::as_ref).collect(), + )?; + } + Ok(()) }