vg
tools for working with variation graphs
Public Member Functions | Protected Attributes | List of all members
vg::FlowTraversalFinder Class Reference

#include <traversal_finder.hpp>

Inheritance diagram for vg::FlowTraversalFinder:
vg::TraversalFinder vg::SiteTraversalFinder

Public Member Functions

 FlowTraversalFinder (const HandleGraph &graph, size_t K, function< double(handle_t)> node_weight_callback, function< double(edge_t)> edge_weight_callback, size_t max_traversal_length=numeric_limits< size_t >::max())
 
virtual vector< SnarlTraversal > find_traversals (const Snarl &site)
 
vector< Traversal > find_traversals (const handle_t &snarl_start, const handle_t &snarl_end) override
 
virtual pair< vector< SnarlTraversal >, vector< double > > find_weighted_traversals (const Snarl &site, bool greedy_avg=false, const HandleGraph *overlay=nullptr)
 
virtual pair< vector< Traversal >, vector< double > > find_weighted_traversals (const handle_t &snarl_start, const handle_t &snarl_end, bool greedy_avg=false, const HandleGraph *overlay=nullptr)
 
void setK (size_t k)
 Set K. More...
 
- Public Member Functions inherited from vg::TraversalFinder
virtual ~TraversalFinder ()=default
 
- Public Member Functions inherited from vg::SiteTraversalFinder
virtual ~SiteTraversalFinder ()=default
 

Protected Attributes

const HandleGraph & graph
 
size_t K
 The K-best traversals are returned. More...
 
function< double(handle_t)> node_weight_callback
 Callbacks to get supports. More...
 
function< double(edge_t)> edge_weight_callback
 
size_t max_traversal_length
 Call off the search as soon as a traversal of this length (bp) is encountered. More...
 

Detailed Description

Finds traversals with the most flow. Node and edge weights are specified using the callbacks and can be used, ex, to yield read supports.
If one traversal is requested, then the path with the highest flow (whose node or edge with the minimum weight is maximum) is returned. If K traversals are specified, then the K highest flow traversals are returned. This is designed to be a replacement for RepresentativeTraversalFinder. It should do a better job of enumerating off-reference traversals, and will of course guarantee to return all the optimal traversals (in the context of max flow). Unlike RepresentativeTraversalFinder, it does not currently support nested snarls, so all traversals returned are explicit.
It is possible that it will blow up on massive snarls, espeically for large Ks.

Constructor & Destructor Documentation

◆ FlowTraversalFinder()

vg::FlowTraversalFinder::FlowTraversalFinder ( const HandleGraph &  graph,
size_t  K,
function< double(handle_t)>  node_weight_callback,
function< double(edge_t)>  edge_weight_callback,
size_t  max_traversal_length = numeric_limits<size_t>::max() 
)

Make a finder that searches a graph for the widest traversals.

Parameters
graphThe graph to search. The finder keeps a reference to it, so it must outlive the finder.
KThe most traversals to find for each site.
node_weight_callbackA function giving the flow through a node.
edge_weight_callbackA function giving the flow through an edge.
max_traversal_lengthA length in bases. When a search finds a traversal longer than this, not counting the site's bounds, it stops and returns the traversals found so far, including that one.

Member Function Documentation

◆ find_traversals() [1/2]

vector< Traversal > vg::FlowTraversalFinder::find_traversals ( const handle_t &  snarl_start,
const handle_t &  snarl_end 
)
overridevirtual

Find the K widest traversals through the site between two bound handles.

Returns
The traversals, widest first.

Implements vg::SiteTraversalFinder.

◆ find_traversals() [2/2]

vector< SnarlTraversal > vg::FlowTraversalFinder::find_traversals ( const Snarl &  site)
virtual

Find the K widest (most flow) traversals through a site.

Returns
The traversals, widest first.

Implements vg::TraversalFinder.

◆ find_weighted_traversals() [1/2]

pair< vector< Traversal >, vector< double > > vg::FlowTraversalFinder::find_weighted_traversals ( const handle_t &  snarl_start,
const handle_t &  snarl_end,
bool  greedy_avg = false,
const HandleGraph *  overlay = nullptr 
)
virtual

Find the K widest traversals through the site between two bound handles, with their flows.

Parameters
snarl_startThe start bound of the site, oriented into the site.
snarl_endThe end bound of the site, oriented out of the site.
greedy_avgTrue to search heuristically by the running average flow, which may miss the widest traversals, rather than by the smallest flow along each traversal.
overlayA graph to search instead of the finder's graph, or null. If given, the bound handles must be in the overlay, and the traversals are returned as handles in it.
Returns
The traversals, and a vector whose i-th entry is the flow through the i-th traversal. Without greedy_avg, the traversals come widest first. With greedy_avg, each flow is an average of the weights along the traversal, and a traversal can have more flow than the one before it.

◆ find_weighted_traversals() [2/2]

pair< vector< SnarlTraversal >, vector< double > > vg::FlowTraversalFinder::find_weighted_traversals ( const Snarl &  site,
bool  greedy_avg = false,
const HandleGraph *  overlay = nullptr 
)
virtual

Find the K widest traversals through a site, with their flows.

Parameters
greedy_avgTrue to search heuristically by the running average flow, which may miss the widest traversals, rather than by the smallest flow along each traversal.
overlayA graph to search instead of the finder's graph, or null.
Returns
The traversals, and a vector whose i-th entry is the flow through the i-th traversal. Without greedy_avg, the traversals come widest first. With greedy_avg, each flow is an average of the weights along the traversal, and a traversal can have more flow than the one before it.

◆ setK()

void vg::FlowTraversalFinder::setK ( size_t  k)

Set K.

Member Data Documentation

◆ edge_weight_callback

function<double(edge_t)> vg::FlowTraversalFinder::edge_weight_callback
protected

◆ graph

const HandleGraph& vg::FlowTraversalFinder::graph
protected

The graph to search, unless a search is given an overlay graph to use instead.

◆ K

size_t vg::FlowTraversalFinder::K
protected

The K-best traversals are returned.

◆ max_traversal_length

size_t vg::FlowTraversalFinder::max_traversal_length
protected

Call off the search as soon as a traversal of this length (bp) is encountered.

◆ node_weight_callback

function<double(handle_t)> vg::FlowTraversalFinder::node_weight_callback
protected

Callbacks to get supports.


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