use clap::*;
use intspan::*;
use std::io::BufRead;
pub fn make_subcommand() -> Command {
Command::new("paf2ovlp")
.about("Convert minimap .paf to overlaps")
.arg(
Arg::new("infiles")
.required(true)
.num_args(1..)
.index(1)
.help("Sets the input files to use"),
)
.arg(
Arg::new("outfile")
.long("outfile")
.short('o')
.num_args(1)
.default_value("stdout")
.help("Output filename. [stdout] for screen"),
)
}
pub fn execute(args: &ArgMatches) -> anyhow::Result<()> {
let mut writer = writer(args.get_one::<String>("outfile").unwrap());
for infile in args.get_many::<String>("infiles").unwrap() {
let reader = reader(infile);
for line in reader.lines().map_while(Result::ok) {
let ovlp = Overlap::from_paf(&line);
writer.write_all((ovlp.to_string() + "\n").as_ref())?;
}
}
Ok(())
}