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

#include <genome_state.hpp>

Public Member Functions

 SnarlState (const NetGraph *graph)
 Create a SnarlState that uses the given net graph. More...
 
void dump () const
 Dump internal state to cerr. More...
 
size_t size () const
 How many haplotypes traverse this snarl? More...
 
void trace (size_t overall_lane, bool backward, const function< void(const handle_t &, size_t)> &iteratee) const
 
void insert (const vector< pair< handle_t, size_t >> &haplotype)
 
const vector< pair< handle_t, size_t > > & append (const vector< handle_t > &haplotype, bool backward=false)
 
const vector< pair< handle_t, size_t > > & insert (size_t overall_lane, const vector< handle_t > &haplotype, bool backward=false)
 
vector< pair< handle_t, size_t > > erase (size_t overall_lane)
 
void swap (size_t lane1, size_t lane2)
 

Protected Attributes

vector< vector< pair< handle_t, size_t > > > haplotypes
 
unordered_map< handle_t, vector< decltype(haplotypes)::value_type::iterator > > net_node_lanes
 
const NetGraphgraph
 

Detailed Description

Represents the state of a snarl: zero or more haplotypes traversing its NetGraph.

Only admits full-length traversals of a snarl from start to end.

Every traversing haplotype is assigned a "lane" number at which it traverses the snarl. Lane is the same looking backward or forward through the snarl. Within each child snarl or child node, the traversal is also assigned a lane. The lane assignments at the start and end nodes are the same, and define the lane assignments for the overall snarl. Traversals can be inserted at any lane number in any internal node.

Constructor & Destructor Documentation

◆ SnarlState()

vg::SnarlState::SnarlState ( const NetGraph graph)

Create a SnarlState that uses the given net graph.

Member Function Documentation

◆ append()

const vector< pair< handle_t, size_t > > & vg::SnarlState::append ( const vector< handle_t > &  haplotype,
bool  backward = false 
)

Insert the given traversal of this snarl from start to end or end to start (as determined by the backward flag), assigning each visit to a handle to the next available lane. Returns the haplotype annotated with lane assignments. If handles to the same node or child snarl appear more than once, their lane numbers will be strictly increasing.

◆ dump()

void vg::SnarlState::dump ( ) const

Dump internal state to cerr.

◆ erase()

vector< pair< handle_t, size_t > > vg::SnarlState::erase ( size_t  overall_lane)

Erase the traversal of this haplotype in the given overall lane. Shifts everything in a higher lane 1 rank down. Returns the erased haplotype and its old lane assignments.

◆ insert() [1/2]

void vg::SnarlState::insert ( const vector< pair< handle_t, size_t >> &  haplotype)

Insert the given traversal of this snarl from start to end, with the given lane assignments for each oriented handle. If handles to the same node or child snarl appear more than once, their lane numbers must be strictly increasing.

◆ insert() [2/2]

const vector< pair< handle_t, size_t > > & vg::SnarlState::insert ( size_t  overall_lane,
const vector< handle_t > &  haplotype,
bool  backward = false 
)

Insert the given traversal of this snarl from start to end or end to start (as determined by the backward flag), assigning it to the given overall lane. Returns the haplotype annotated with lane assignments for all the internal handles. If the internal handles represent child snarls, this can be used to recurse down and insert traversals of them at the right lanes. If handles to the same node or child snarl appear more than once, their assigned lane numbers will be strictly increasing. Returns the haplotype annotated with lane assignments.

◆ size()

size_t vg::SnarlState::size ( ) const

How many haplotypes traverse this snarl?

◆ swap()

void vg::SnarlState::swap ( size_t  lane1,
size_t  lane2 
)

Swap the traversals of this haplotype in the two given overall lanes. Internal lane assignments (as are used by child snarls) are not affected.

◆ trace()

void vg::SnarlState::trace ( size_t  overall_lane,
bool  backward,
const function< void(const handle_t &, size_t)> &  iteratee 
) const

Trace the haplotype int eh given overall lane in the given orientation. Yields the oriented handles visited and the per-forward-handle lane assignments.

Member Data Documentation

◆ graph

const NetGraph* vg::SnarlState::graph
protected

We need to keep track of the net graph, because we may need to traverse haplotypes forward or reverse and we need to flip things.

◆ haplotypes

vector<vector<pair<handle_t, size_t> > > vg::SnarlState::haplotypes
protected

◆ net_node_lanes

unordered_map<handle_t, vector<decltype(haplotypes)::value_type::iterator> > vg::SnarlState::net_node_lanes
protected

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