Skip to main content

Crate pangraphx_core

Crate pangraphx_core 

Source
Expand description

Core library for PanGraphX.

pangraphx-core provides a unified API for parsing, converting, and manipulating pangenome graph formats.

§What this crate provides

§Supported formats

See GraphFormat for currently supported formats and extension mapping.

§Quick start

Parse a graph and serialize it to another format:

use std::fs::File;
use pangraphx_core::GraphFormat;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut input = File::open("graph.gfa")?;
    let parser = GraphFormat::GFA.get_parser();
    let graph = parser.parse(&mut input)?;

    let serializer = GraphFormat::GBZ.get_serializer();
    let mut output = File::create("graph.gbz")?;
    serializer.serialize(&graph, &mut output)?;
    Ok(())
}

Build a de Bruijn graph from a parsed directed graph:

use std::fs::File;
use pangraphx_core::{CoreGraphDTO, DeBruijn, GraphFormat};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut input = File::open("graph.vg")?;
    let parser = GraphFormat::VG.get_parser();
    let graph: CoreGraphDTO = parser.parse(&mut input)?;

    let dbg = DeBruijn::from_directed_graph(graph, 31)?;
    // One node per k-mer, or `dbg.into_compacted_dto()?` for unitigs.
    let _as_core = CoreGraphDTO::try_from(dbg)?;
    Ok(())
}

§Errors

Library APIs typically return PanResult<T>, an alias around PanGraphXError

Re-exports§

pub use core::core_types::Edge;
pub use core::core_types::Node;
pub use core::core_types::NodeId;
pub use core::core_types::NodeName;
pub use core::core_types::Orientation;
pub use core::core_types::Path;
pub use core::core_types::PathName;
pub use core::core_types::Sequence;
pub use core::core_types::Step;
pub use core::stats::DegreeStats;
pub use core::stats::GraphStats;
pub use core::stats::LenStats;
pub use core::stats::PathStats;
pub use core::graph::CoreGraph;
pub use core::graph_dto::CoreGraphDTO;
pub use de_bruijn_conversion::colored_dbg::ColoredDBG;
pub use de_bruijn_conversion::de_bruijn_graph::DeBruijn;
pub use de_bruijn_conversion::k_mers::Kmer;
pub use error::PanResult;

Modules§

core
de_bruijn_conversion
error
formats
proto_gen
traits

Enums§

GraphFormat
Supported graph formats