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

#include <min_distance.hpp>

Public Member Functions

 SnarlIndex (id_t parent_id, bool rev_in_parent, id_t id_in_parent, id_t end_id, bool is_unary_snarl, size_t depth, size_t num_nodes, bool in_chain)
 
 SnarlIndex ()
 
void load (istream &in, bool include_component)
 
void serialize (ostream &out) const
 Serialize the snarl. More...
 
int64_t snarl_distance (size_t start, size_t end) const
 
int64_t node_length (size_t i) const
 
int64_t snarl_length () const
 
pair< int64_t, int64_t > dist_to_ends (size_t rank, int64_t distL, int64_t distR) const
 
void insert_distance (size_t start, size_t end, int64_t dist)
 
bool is_trivial_snarl () const
 
void print_self () const
 
json_t * snarl_to_json ()
 

Protected Member Functions

size_t index (size_t start, size_t end) const
 The index into distances for distance start->end. More...
 

Protected Attributes

int_vector distances
 
bool in_chain
 True if this snarl is in a chain. More...
 
id_t parent_id
 
bool rev_in_parent
 
id_t id_in_parent
 
id_t end_id
 
size_t num_nodes
 Number of nodes in the snarl. More...
 
size_t depth
 Depth in the snarl tree - 0 for root. More...
 
bool is_unary_snarl
 
bool is_simple_snarl
 True if all children are nodes (not snarls or chains) and for every child node,. More...
 
int64_t max_width
 The maximum width of the snarl - the maximum of all minimum distance paths from each node to. More...
 

Friends

class MinimumDistanceIndex
 
class SnarlSeedClusterer
 

Detailed Description

Index for calculating minimum distances among nodes in a snarl Stores minimum distances between nodes in the netgraph of a snarl Also keeps track of the parent of the snarl

Constructor & Destructor Documentation

◆ SnarlIndex() [1/2]

vg::MinimumDistanceIndex::SnarlIndex::SnarlIndex ( id_t  parent_id,
bool  rev_in_parent,
id_t  id_in_parent,
id_t  end_id,
bool  is_unary_snarl,
size_t  depth,
size_t  num_nodes,
bool  in_chain 
)

Constructor for the snarl index if inChain is true, parent_id and rev_in_parent are for the chain chain the snarl participates in. otherwise, for the parent snarl

◆ SnarlIndex() [2/2]

vg::MinimumDistanceIndex::SnarlIndex::SnarlIndex ( )

Member Function Documentation

◆ dist_to_ends()

pair< int64_t, int64_t > vg::MinimumDistanceIndex::SnarlIndex::dist_to_ends ( size_t  rank,
int64_t  distL,
int64_t  distR 
) const

Given distances from a position to either end of a node, find the shortest distance from that position to the start and end nodes of the snarl rank is in the forward direction, but checks both forward and reverse

◆ index()

size_t vg::MinimumDistanceIndex::SnarlIndex::index ( size_t  start,
size_t  end 
) const
protected

The index into distances for distance start->end.

◆ insert_distance()

void vg::MinimumDistanceIndex::SnarlIndex::insert_distance ( size_t  start,
size_t  end,
int64_t  dist 
)

For use during construction, add the distance from start to end to the index

◆ is_trivial_snarl()

bool vg::MinimumDistanceIndex::SnarlIndex::is_trivial_snarl ( ) const

◆ load()

void vg::MinimumDistanceIndex::SnarlIndex::load ( istream &  in,
bool  include_component 
)

◆ node_length()

int64_t vg::MinimumDistanceIndex::SnarlIndex::node_length ( size_t  i) const
inline

Length of a node in the netgraph of the snarl If it is a node, then the length of the node. If it is a snarl or chain, then the shortest distance between the boundaries i is the rank of the node in the snarl

◆ print_self()

void vg::MinimumDistanceIndex::SnarlIndex::print_self ( ) const

◆ serialize()

void vg::MinimumDistanceIndex::SnarlIndex::serialize ( ostream &  out) const

Serialize the snarl.

◆ snarl_distance()

int64_t vg::MinimumDistanceIndex::SnarlIndex::snarl_distance ( size_t  start,
size_t  end 
) const
inline

Distance between start and end, not including the lengths of the two nodes start and end are the ranks of the node+direction, given by primary_snarls and secondary_snarl Only works for nodes heading their chains (which represent the chains), or snarl boundaries. Rank 0 is the start node and rank num_nodes*2-1 is the end node, both pointing into the snarl

◆ snarl_length()

int64_t vg::MinimumDistanceIndex::SnarlIndex::snarl_length ( ) const

Total length of the snarl-shortest distance from start to end including the lengths of boundary nodes

◆ snarl_to_json()

json_t * vg::MinimumDistanceIndex::SnarlIndex::snarl_to_json ( )

Friends And Related Function Documentation

◆ MinimumDistanceIndex

friend class MinimumDistanceIndex
friend

◆ SnarlSeedClusterer

friend class SnarlSeedClusterer
friend

Member Data Documentation

◆ depth

size_t vg::MinimumDistanceIndex::SnarlIndex::depth
protected

Depth in the snarl tree - 0 for root.

◆ distances

int_vector vg::MinimumDistanceIndex::SnarlIndex::distances
protected

Store the distance between every pair nodes, not including the lengths of the nodes. The lengths of each of the nodes are stored as the first n entries Distances stored are 1 greater than actual distances -1 (stored as 0) indicates no path For child snarls that are unary or only connected to one node in the snarl, distances between that node leaving the snarl and any other node is -1

◆ end_id

id_t vg::MinimumDistanceIndex::SnarlIndex::end_id
protected

◆ id_in_parent

id_t vg::MinimumDistanceIndex::SnarlIndex::id_in_parent
protected

id of this snarl in the parent. If the parent is a chain, then the id of the boundary node that occurs first in the order of the chain

◆ in_chain

bool vg::MinimumDistanceIndex::SnarlIndex::in_chain
protected

True if this snarl is in a chain.

◆ is_simple_snarl

bool vg::MinimumDistanceIndex::SnarlIndex::is_simple_snarl
protected

True if all children are nodes (not snarls or chains) and for every child node,.

◆ is_unary_snarl

bool vg::MinimumDistanceIndex::SnarlIndex::is_unary_snarl
protected

True if this snarl is a unary snarl Since the start and end node are the same, the last ranking node is no longer the end node if this is true

◆ max_width

int64_t vg::MinimumDistanceIndex::SnarlIndex::max_width
protected

The maximum width of the snarl - the maximum of all minimum distance paths from each node to.

◆ num_nodes

size_t vg::MinimumDistanceIndex::SnarlIndex::num_nodes
protected

Number of nodes in the snarl.

◆ parent_id

id_t vg::MinimumDistanceIndex::SnarlIndex::parent_id
protected

id of the parent snarl or chain of this snarl 0 if this is a top level snarl with no chain

◆ rev_in_parent

bool vg::MinimumDistanceIndex::SnarlIndex::rev_in_parent
protected

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