Skip to content

Commit

Permalink
Stats mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Mar 19, 2024
1 parent b70eab1 commit b7b6d13
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion polbin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ fn map_file_mut(name: &str) -> MmapMut {
unsafe { MmapMut::map_mut(&file) }.unwrap()
}

fn print_stats(gfa: &flatgfa::FlatGFA) {
eprintln!("header: {}", gfa.header.len());
eprintln!("segs: {}", gfa.segs.len());
eprintln!("paths: {}", gfa.paths.len());
eprintln!("links: {}", gfa.links.len());
eprintln!("steps: {}", gfa.steps.len());
eprintln!("seq_data: {}", gfa.seq_data.len());
eprintln!("overlaps: {}", gfa.overlaps.len());
eprintln!("alignment: {}", gfa.alignment.len());
eprintln!("name_data: {}", gfa.name_data.len());
eprintln!("optional_data: {}", gfa.optional_data.len());
eprintln!("line_order: {}", gfa.line_order.len());
}

#[derive(FromArgs)]
/// Convert between GFA text and FlatGFA binary formats.
struct PolBin {
Expand All @@ -47,6 +61,10 @@ struct PolBin {
/// mutate the input file in place
#[argh(switch, short = 'm')]
mutate: bool,

/// print statistics about the graph
#[argh(switch, short = 's')]
stats: bool,
}

fn main() {
Expand All @@ -62,7 +80,10 @@ fn main() {

// Parse the input into the file.
let stdin = std::io::stdin();
parse::buf_parse(store, toc, stdin.lock());
let store = parse::buf_parse(store, toc, stdin.lock());
if args.stats {
print_stats(&store.view());
}
mmap.flush().unwrap();
return;
}
Expand Down Expand Up @@ -91,6 +112,11 @@ fn main() {
}
};

// Perhaps print some statistics.
if args.stats {
print_stats(&gfa);
}

// Write the output to a file (binary) or stdout (text).
match args.output {
Some(name) => {
Expand Down

0 comments on commit b7b6d13

Please sign in to comment.