pub mod core;
pub mod de_bruijn_conversion;
pub mod error;
pub mod formats;
pub mod proto_gen;
pub mod traits;
pub use core::core_types::{
Edge, Node, NodeId, NodeLabel, NodeName, Orientation, Path, PathName, Sequence, Step,
};
pub use core::stats::{DegreeStats, GraphStats, LenStats, PathStats};
pub use core::{
graph::CoreGraph,
graph_dto::{CoreGraphDTO, GraphParts},
};
pub use de_bruijn_conversion::{
UnitigSequences, colored_dbg::ColoredDBG, de_bruijn_graph::DeBruijn, k_mers::Kmer,
};
pub use error::PanResult;
use std::fmt::Display;
use crate::error::PanGraphXError;
use crate::formats::{FastgCodec, GBZCodec, GFACodec, ODGICodec, VGCodec};
use crate::traits::{GraphParser, GraphSerializer};
use std::io::{Read, Seek};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GraphFormat {
GBZ,
GFA,
VG,
FASTG,
ODGI,
}
impl Display for GraphFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::GBZ => write!(f, "GBZ"),
Self::GFA => write!(f, "GFA"),
Self::VG => write!(f, "VG"),
Self::FASTG => write!(f, "FASTG"),
Self::ODGI => write!(f, "ODGI"),
}
}
}
impl GraphFormat {
pub fn iter() -> impl Iterator<Item = Self> {
[Self::GFA, Self::GBZ, Self::VG, Self::FASTG, Self::ODGI].into_iter()
}
#[must_use]
pub const fn get_extension(&self) -> &str {
match self {
Self::GBZ => "gbz",
Self::GFA => "gfa",
Self::VG => "vg",
Self::FASTG => "fastg",
Self::ODGI => "og",
}
}
pub fn from_extension(extension: &str) -> PanResult<Self> {
match extension.to_lowercase().as_str() {
"gfa" => Ok(Self::GFA),
"vg" => Ok(Self::VG),
"gbz" => Ok(Self::GBZ),
"fastg" => Ok(Self::FASTG),
"og" => Ok(Self::ODGI),
_ => Err(PanGraphXError::UnsupportedFormat),
}
}
#[must_use]
pub fn get_parser<R: Read + Seek>(&self) -> Box<dyn GraphParser<R>> {
match self {
Self::GFA => Box::new(GFACodec),
Self::VG => Box::new(VGCodec),
Self::GBZ => Box::new(GBZCodec),
Self::FASTG => Box::new(FastgCodec),
Self::ODGI => Box::new(ODGICodec),
}
}
#[must_use]
pub fn get_serializer(&self) -> Box<dyn GraphSerializer> {
match self {
Self::GFA => Box::new(GFACodec),
Self::VG => Box::new(VGCodec),
Self::GBZ => Box::new(GBZCodec),
Self::FASTG => Box::new(FastgCodec),
Self::ODGI => Box::new(ODGICodec),
}
}
#[must_use]
pub const fn get_description(&self) -> &str {
match self {
Self::GFA => {
"Graphical Fragment Assembly (v1.0/v1.1): An interoperable, text-based standard for representing pangenome nodes, edges, and paths."
}
Self::VG => {
"VG Protobuf: A serialized binary format used by the vg toolkit; supports rich metadata but can be storage-intensive."
}
Self::GBZ => "GBZ: A highly compressed format for large pangenomes.",
Self::FASTG => {
"FASTG: A text-based format designed to capture assembly ambiguities; largely superseded by GFA in modern workflows."
}
Self::ODGI => {
"ODGI: A dynamic, memory-efficient binary format optimized for large-scale pangenome analysis and graph manipulation."
}
}
}
}