vg
tools for working with variation graphs
|
#include <handle_graph.hpp>
Public Member Functions | |
virtual | ~HandleGraph ()=default |
virtual bool | has_node (nid_t node_id) const =0 |
Method to check if a node exists by ID. More... | |
virtual handle_t | get_handle (const nid_t &node_id, bool is_reverse=false) const =0 |
Look up the handle for the node with the given ID in the given orientation. More... | |
virtual nid_t | get_id (const handle_t &handle) const =0 |
Get the ID from a handle. More... | |
virtual bool | get_is_reverse (const handle_t &handle) const =0 |
Get the orientation of a handle. More... | |
virtual handle_t | flip (const handle_t &handle) const =0 |
Invert the orientation of a handle (potentially without getting its ID) More... | |
virtual size_t | get_length (const handle_t &handle) const =0 |
Get the length of a node. More... | |
virtual std::string | get_sequence (const handle_t &handle) const =0 |
virtual size_t | get_node_count () const =0 |
Return the number of nodes in the graph. More... | |
virtual nid_t | min_node_id () const =0 |
virtual nid_t | max_node_id () const =0 |
template<typename Iteratee > | |
bool | follow_edges (const handle_t &handle, bool go_left, const Iteratee &iteratee) const |
template<typename Iteratee > | |
bool | for_each_handle (const Iteratee &iteratee, bool parallel=false) const |
virtual size_t | get_degree (const handle_t &handle, bool go_left) const |
virtual bool | has_edge (const handle_t &left, const handle_t &right) const |
bool | has_edge (const edge_t &edge) const |
Convenient wrapper of has_edge for edge_t argument. More... | |
virtual size_t | get_edge_count () const |
virtual size_t | get_total_length () const |
virtual char | get_base (const handle_t &handle, size_t index) const |
virtual std::string | get_subsequence (const handle_t &handle, size_t index, size_t size) const |
handle_t | forward (const handle_t &handle) const |
Get the locally forward version of a handle. More... | |
edge_t | edge_handle (const handle_t &left, const handle_t &right) const |
handle_t | traverse_edge_handle (const edge_t &edge, const handle_t &left) const |
template<typename Iteratee > | |
bool | for_each_edge (const Iteratee &iteratee, bool parallel=false) const |
Protected Member Functions | |
virtual bool | follow_edges_impl (const handle_t &handle, bool go_left, const std::function< bool(const handle_t &)> &iteratee) const =0 |
virtual bool | for_each_handle_impl (const std::function< bool(const handle_t &)> &iteratee, bool parallel=false) const =0 |
This is the interface that a graph that uses handles needs to support. It is also the interface that users should code against.
|
virtualdefault |
std::pair< handle_t, handle_t > handlegraph::HandleGraph::edge_handle | ( | const handle_t & | left, |
const handle_t & | right | ||
) | const |
A pair of handles can be used as an edge. When so used, the handles have a canonical order and orientation.
Invert the orientation of a handle (potentially without getting its ID)
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::SubgraphOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
bool handlegraph::HandleGraph::follow_edges | ( | const handle_t & | handle, |
bool | go_left, | ||
const Iteratee & | iteratee | ||
) | const |
Loop over all the handles to next/previous (right/left) nodes. Passes them to a callback. If called with a bool-returning invocable thing, can stop early when the function returns false. Returns true if we finished and false if we stopped early.
|
protectedpure virtual |
Loop over all the handles to next/previous (right/left) nodes. Passes them to a callback which returns false to stop iterating and true to continue. Returns true if we finished and false if we stopped early.
Implemented in vg::SnarlGraph, xg::XG, vg::SubpathOverlay, and vg::SubgraphOverlay.
bool handlegraph::HandleGraph::for_each_edge | ( | const Iteratee & | iteratee, |
bool | parallel = false |
||
) | const |
Loop over all edges in their canonical orientation (as returned by edge_handle) as edge_t items and execute an iteratee on each one. If the iteratee returns bool, and it returns false, stop iteration. Return true if the iteration completed and false if it stopped early. If run in parallel (parallel = true), stopping early is best-effort.
bool handlegraph::HandleGraph::for_each_handle | ( | const Iteratee & | iteratee, |
bool | parallel = false |
||
) | const |
Loop over all the nodes in the graph in their local forward orientations, in their internal stored order. If called with a bool-returning invocable thing, can stop early when the function returns false. Returns true if we finished and false if we stopped early. Can be told to run in parallel, in which case stopping after a false return value is on a best-effort basis and iteration order is not defined.
|
protectedpure virtual |
Loop over all the nodes in the graph in their local forward orientations, in their internal stored order. Stop if the iteratee returns false. Can be told to run in parallel, in which case stopping after a false return value is on a best-effort basis and iteration order is not defined. Returns true if we finished and false if we stopped early.
Implemented in vg::SnarlGraph, xg::XG, vg::SubpathOverlay, and vg::SubgraphOverlay.
Get the locally forward version of a handle.
|
virtual |
Returns one base of a handle's sequence, in the orientation of the handle.
Reimplemented in xg::XG, vg::JoinedSpliceGraph, vg::VG, and vg::IncrementalSubgraph.
|
virtual |
Get the number of edges on the right (go_left = false) or left (go_left = true) side of the given handle. The default implementation is O(n) in the number of edges returned, but graph implementations that track this information more efficiently can override this method.
Reimplemented in vg::VG, vg::IncrementalSubgraph, vg::SourceSinkOverlay, and vg::ExtraNodeGraph.
|
virtual |
Return the total number of edges in the graph. If not overridden, counts them all in linear time.
Reimplemented in xg::XG, vg::VG, and vg::IncrementalSubgraph.
|
pure virtual |
Look up the handle for the node with the given ID in the given orientation.
Implemented in vg::SnarlGraph, xg::XG, vg::VG, vg::SubgraphOverlay, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::NetGraph, vg::JoinedSpliceGraph, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::DozeuPinningOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, vg::NullMaskingGraph, vg::SourceSinkOverlay, and vg::ExtraNodeGraph.
Get the ID from a handle.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::SubgraphOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
|
pure virtual |
Get the orientation of a handle.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::SubgraphOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
|
pure virtual |
Get the length of a node.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::SubgraphOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
|
pure virtual |
Return the number of nodes in the graph.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::DozeuPinningOverlay, vg::ExtraNodeGraph, vg::PathSubgraph, vg::SubHandleGraph, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, vg::NullMaskingGraph, vg::SubgraphOverlay, and vg::SubpathOverlay.
|
pure virtual |
Get the sequence of a node, presented in the handle's local forward orientation.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::SubgraphOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
|
virtual |
Returns a substring of a handle's sequence, in the orientation of the handle. If the indicated substring would extend beyond the end of the handle's sequence, the return value is truncated to the sequence's end. By default O(n) in the size of the handle's sequence, but can be overriden.
Reimplemented in xg::XG, vg::JoinedSpliceGraph, vg::VG, and vg::IncrementalSubgraph.
|
virtual |
Return the total length of all nodes in the graph, in bp. If not overridden, loops over all nodes in linear time.
Reimplemented in xg::XG.
|
inline |
Convenient wrapper of has_edge for edge_t argument.
|
virtual |
Returns true if there is an edge that allows traversal from the left handle to the right handle. By default O(n) in the number of edges on left, but can be overridden with more efficient implementations.
Reimplemented in vg::VG.
|
pure virtual |
Method to check if a node exists by ID.
Implemented in vg::SnarlGraph, xg::XG, vg::SubgraphOverlay, vg::SubpathOverlay, handlegraph::algorithms::SubHandleGraph, vg::VG, vg::NetGraph, vg::JoinedSpliceGraph, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::ExtraNodeGraph, vg::DozeuPinningOverlay, vg::PathSubgraph, vg::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, and vg::NullMaskingGraph.
|
pure virtual |
Return the largest ID in the graph, or some larger number if the largest ID is unavailable. Return value is unspecified if the graph is empty.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::DozeuPinningOverlay, vg::PathSubgraph, vg::ExtraNodeGraph, vg::SubHandleGraph, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, vg::NullMaskingGraph, vg::SubgraphOverlay, and vg::SubpathOverlay.
|
pure virtual |
Return the smallest ID in the graph, or some smaller number if the smallest ID is unavailable. Return value is unspecified if the graph is empty.
Implemented in vg::SnarlGraph, vg::NetGraph, xg::XG, vg::JoinedSpliceGraph, vg::VG, vg::IndexedVG, vg::IncrementalSubgraph, vg::TreeSubgraph, vg::SourceSinkOverlay, vg::DozeuPinningOverlay, vg::ExtraNodeGraph, vg::PathSubgraph, vg::SubHandleGraph, handlegraph::algorithms::SubHandleGraph, vg::StrandSplitGraph, vg::MemoizingGraph, vg::ReverseGraph, vg::DagifiedGraph, vg::IdentityOverlay, vg::NullMaskingGraph, vg::SubgraphOverlay, and vg::SubpathOverlay.
handle_t handlegraph::HandleGraph::traverse_edge_handle | ( | const edge_t & | edge, |
const handle_t & | left | ||
) | const |
Such a pair can be viewed from either inward end handle and produce the outward handle you would arrive at.