vg
tools for working with variation graphs
Public Member Functions | Protected Member Functions | List of all members
handlegraph::HandleGraph Class Referenceabstract

#include <handle_graph.hpp>

Inheritance diagram for handlegraph::HandleGraph:
handlegraph::ExpandingOverlayGraph handlegraph::MutableHandleGraph handlegraph::PathHandleGraph handlegraph::RankedHandleGraph vg::ExtraNodeGraph vg::IndexedVG vg::JoinedSpliceGraph vg::NetGraph vg::SnarlGraph vg::SubgraphOverlay

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
 

Detailed Description

This is the interface that a graph that uses handles needs to support. It is also the interface that users should code against.

Constructor & Destructor Documentation

◆ ~HandleGraph()

virtual handlegraph::HandleGraph::~HandleGraph ( )
virtualdefault

Member Function Documentation

◆ edge_handle()

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.

◆ flip()

virtual handle_t handlegraph::HandleGraph::flip ( const handle_t handle) const
pure virtual

◆ follow_edges()

template<typename Iteratee >
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.

◆ follow_edges_impl()

virtual bool handlegraph::HandleGraph::follow_edges_impl ( const handle_t handle,
bool  go_left,
const std::function< bool(const handle_t &)> &  iteratee 
) const
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, and vg::SubgraphOverlay.

◆ for_each_edge()

template<typename Iteratee >
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.

◆ for_each_handle()

template<typename Iteratee >
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.

◆ for_each_handle_impl()

virtual bool handlegraph::HandleGraph::for_each_handle_impl ( const std::function< bool(const handle_t &)> &  iteratee,
bool  parallel = false 
) const
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, and vg::SubgraphOverlay.

◆ forward()

handle_t handlegraph::HandleGraph::forward ( const handle_t handle) const

Get the locally forward version of a handle.

◆ get_base()

char handlegraph::HandleGraph::get_base ( const handle_t handle,
size_t  index 
) const
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.

◆ get_degree()

size_t handlegraph::HandleGraph::get_degree ( const handle_t handle,
bool  go_left 
) const
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.

◆ get_edge_count()

size_t handlegraph::HandleGraph::get_edge_count ( ) const
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.

◆ get_handle()

virtual handle_t handlegraph::HandleGraph::get_handle ( const nid_t node_id,
bool  is_reverse = false 
) const
pure virtual

◆ get_id()

virtual nid_t handlegraph::HandleGraph::get_id ( const handle_t handle) const
pure virtual

◆ get_is_reverse()

virtual bool handlegraph::HandleGraph::get_is_reverse ( const handle_t handle) const
pure virtual

◆ get_length()

virtual size_t handlegraph::HandleGraph::get_length ( const handle_t handle) const
pure virtual

◆ get_node_count()

virtual size_t handlegraph::HandleGraph::get_node_count ( ) const
pure virtual

◆ get_sequence()

virtual std::string handlegraph::HandleGraph::get_sequence ( const handle_t handle) const
pure virtual

◆ get_subsequence()

std::string handlegraph::HandleGraph::get_subsequence ( const handle_t handle,
size_t  index,
size_t  size 
) const
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.

◆ get_total_length()

size_t handlegraph::HandleGraph::get_total_length ( ) const
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.

◆ has_edge() [1/2]

bool handlegraph::HandleGraph::has_edge ( const edge_t edge) const
inline

Convenient wrapper of has_edge for edge_t argument.

◆ has_edge() [2/2]

bool handlegraph::HandleGraph::has_edge ( const handle_t left,
const handle_t right 
) const
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.

◆ has_node()

virtual bool handlegraph::HandleGraph::has_node ( nid_t  node_id) const
pure virtual

◆ max_node_id()

virtual nid_t handlegraph::HandleGraph::max_node_id ( ) const
pure virtual

◆ min_node_id()

virtual nid_t handlegraph::HandleGraph::min_node_id ( ) const
pure virtual

◆ traverse_edge_handle()

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.


The documentation for this class was generated from the following files: