1use std::path::PathBuf;
2
3use crate::gfa::gfa::GFAtk;
4use crate::load::{load_gfa, load_gfa_stdin};
5use crate::utils;
6use anyhow::{bail, Result};
7
8pub fn fasta(matches: &clap::ArgMatches) -> Result<()> {
15 let gfa_file = matches.get_one::<PathBuf>("GFA");
17
18 let gfa: GFAtk = match gfa_file {
19 Some(f) => {
20 let ext = f.extension();
21 match ext {
22 Some(e) => {
23 if e == "gfa" {
24 GFAtk(load_gfa(f)?)
25 } else {
26 bail!("Input is not a GFA.")
27 }
28 }
29 None => bail!("Could not read file."),
30 }
31 }
32 None => match utils::is_stdin() {
33 true => GFAtk(load_gfa_stdin(std::io::stdin().lock())?),
34 false => bail!("No input from STDIN. Run `gfatk extract -h` for help."),
35 },
36 };
37
38 gfa.print_sequences(None)?;
41
42 Ok(())
43}