#bioinformatics #gfa #parser

bin+lib parfait-gfa

gfa v1/v2 parser and validator

4 releases

Uses new Rust 2024

0.1.3 Jan 14, 2026
0.1.2 Nov 5, 2025
0.1.1 Nov 5, 2025
0.1.0 Oct 22, 2025

#254 in Biology

MIT license

190KB
4.5K SLoC

parfait-gfa

a gfa v1 and v2 parser with validation and error reporting. originally built for the parfait gfa visualisation tool, but can be used standalone as an executable or crate.

currently a work in progress; the api is not stable. please open issues for any features you would like to see.

usage (cli)

prints any errors and shows file stats

parfait-gfa path/to/file.gfa

example (crate)

use parfait_gfa::gfa::{GfaParser, ParseOptions, GFAVersion};
use parfait_gfa::optional_field::OptionalFieldValue;

let mut gfa = GfaParser::new();

// parse a gfa file
let result = gfa.parse("path/to/file.gfa", &ParseOptions::default());

match result {
  Ok(_) => println!("Parsed successfully"),
  Err(errors) => println!("Failed to parse file"),
}

// add an integer tag "ab" with value 12345 to all segments
for segment in gfa.segments_mut() {
    segment.tags.add_tag("ab", OptionalFieldValue::Int(12345));
}

// write the modified GFA to a new file
let _ = gfa.write_to_file("file_with_ab_tags.gfa", GFAVersion::V2);

missing features

  • groups cannot be derived into paths (they are still are parsed/validated)
  • jump connections in walks are ignored, any valid link/jump is accepted
  • optional field tags that use JSON are parsed as strings
  • path/walk parsing isn't very efficient and may be slow on large files
  • error messages are missing context in most cases

licence

MIT

Dependencies

~1.2–1.7MB
~31K SLoC