vg
tools for working with variation graphs
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
vg::PathIndex Struct Reference

#include <path_index.hpp>

Public Types

using iterator = map< size_t, vg::NodeSide >::const_iterator
 We keep iterators to node occurrences along the ref path. More...
 

Public Member Functions

 PathIndex (const Path &path)
 Index just a path. More...
 
 PathIndex (const list< mapping_t > &mappings)
 Index just a list of mappings. More...
 
 PathIndex (const list< mapping_t > &mappings, VG &vg)
 
 PathIndex (const Path &path, const HandleGraph &graph)
 Index a path and pull sequence from a graph. More...
 
 PathIndex (VG &vg, const string &path_name, bool extract_sequence=false)
 Make a PathIndex from a path in a graph. More...
 
 PathIndex (const PathHandleGraph &graph, const string &path_name, bool extract_sequence=false)
 Make a PathIndex from a path in an indexed graph. More...
 
void update_mapping_positions (VG &vg, const string &path_name)
 
NodeSide at_position (size_t position) const
 
bool path_contains_node (int64_t node_id) const
 Check whether a node is on the reference path. More...
 
bool path_contains_node_in_orientation (int64_t node_id, bool is_reverse) const
 Check whether a node is on the reference path in a given path-relative orientation. More...
 
pair< bool, bool > get_contained_orientations (int64_t node_id) const
 
iterator find_in_orientation (int64_t node_id, bool is_reverse) const
 Find the first occurrence of the given node in the given orientation. More...
 
iterator begin () const
 Get the iterator to the first node occurrence on the indexed path. More...
 
iterator end () const
 Get the iterator to the last node occurrence on the indexed path. More...
 
iterator find_position (size_t position) const
 
size_t node_length (const iterator &here) const
 
pair< size_t, size_t > round_outward (size_t start, size_t past_end) const
 
void apply_translation (const Translation &translation)
 
void apply_translations (const vector< Translation > &translations)
 

Public Attributes

map< int64_t, pair< size_t, bool > > by_id
 
map< size_t, NodeSideby_start
 
std::string sequence
 The actual sequence of the path, if desired. More...
 
map< const mapping_t *, size_t > mapping_positions
 

Protected Member Functions

map< id_t, vector< Mapping > > parse_translation (const Translation &translation)
 
void replace_occurrence (iterator to_replace, const vector< Mapping > &replacements)
 

Protected Attributes

size_t last_node_length
 
map< id_t, vector< iterator > > node_occurrences
 

Detailed Description

Holds indexes of the reference in a graph: position to node, node to position and orientation, and the full reference string. Also knows about the lengths of nodes on the path, and lets you iterate back and forth over it.

Member Typedef Documentation

◆ iterator

using vg::PathIndex::iterator = map<size_t, vg::NodeSide>::const_iterator

We keep iterators to node occurrences along the ref path.

Constructor & Destructor Documentation

◆ PathIndex() [1/6]

vg::PathIndex::PathIndex ( const Path path)

Index just a path.

◆ PathIndex() [2/6]

vg::PathIndex::PathIndex ( const list< mapping_t > &  mappings)

Index just a list of mappings.

◆ PathIndex() [3/6]

vg::PathIndex::PathIndex ( const list< mapping_t > &  mappings,
VG vg 
)

Index a list of mappings embedded in the given vg's Paths object, and pull sequence from the given vg.

◆ PathIndex() [4/6]

vg::PathIndex::PathIndex ( const Path path,
const HandleGraph graph 
)

Index a path and pull sequence from a graph.

◆ PathIndex() [5/6]

vg::PathIndex::PathIndex ( VG vg,
const string &  path_name,
bool  extract_sequence = false 
)

Make a PathIndex from a path in a graph.

◆ PathIndex() [6/6]

vg::PathIndex::PathIndex ( const PathHandleGraph graph,
const string &  path_name,
bool  extract_sequence = false 
)

Make a PathIndex from a path in an indexed graph.

Member Function Documentation

◆ apply_translation()

void vg::PathIndex::apply_translation ( const Translation translation)

Update the index to reflect the changes described by a Translation. References to nodes along the "from" path are changed to references to nodes along the "to" path. The translation must contain two paths of equal length, containing only matches. The translation must only divide nodes; it may not join nodes together. The translation must fully account for each old node that it touches (it can't translate only part of a node). The translation may not re-use the ID from one original node for a piece of a different original node. All the Mappings in the Translation must have Edits.

◆ apply_translations()

void vg::PathIndex::apply_translations ( const vector< Translation > &  translations)

Update the index to reflect the changes described by the given collection of Translations. These translations are expected to be in the format produced by VG::edit() which is one to Mapping per translation. The vector may include both forward and reverse versions of each to node, and may also include translations mapping nodes that did not change to themselves.

◆ at_position()

NodeSide vg::PathIndex::at_position ( size_t  position) const

Find what node and orientation covers a position. The position must not be greater than the path length.

◆ begin()

PathIndex::iterator vg::PathIndex::begin ( ) const

Get the iterator to the first node occurrence on the indexed path.

◆ end()

PathIndex::iterator vg::PathIndex::end ( ) const

Get the iterator to the last node occurrence on the indexed path.

◆ find_in_orientation()

PathIndex::iterator vg::PathIndex::find_in_orientation ( int64_t  node_id,
bool  is_reverse 
) const

Find the first occurrence of the given node in the given orientation.

◆ find_position()

PathIndex::iterator vg::PathIndex::find_position ( size_t  position) const

Find the iterator at the given position along the ref path. The position must not be greater than the path length.

◆ get_contained_orientations()

pair< bool, bool > vg::PathIndex::get_contained_orientations ( int64_t  node_id) const

Return two flags for if the path contains the given node in forward and reverse orientation.

◆ node_length()

size_t vg::PathIndex::node_length ( const iterator here) const

Get the length of the node occurrence on the path represented by this iterator.

◆ parse_translation()

map< id_t, vector< Mapping > > vg::PathIndex::parse_translation ( const Translation translation)
protected

Convert a Translation that partitions old nodes into a map from old node ID to the Mappings that replace it in its forward orientation.

◆ path_contains_node()

bool vg::PathIndex::path_contains_node ( int64_t  node_id) const

Check whether a node is on the reference path.

◆ path_contains_node_in_orientation()

bool vg::PathIndex::path_contains_node_in_orientation ( int64_t  node_id,
bool  is_reverse 
) const

Check whether a node is on the reference path in a given path-relative orientation.

◆ replace_occurrence()

void vg::PathIndex::replace_occurrence ( iterator  to_replace,
const vector< Mapping > &  replacements 
)
protected

Given an iterator into by_start, replace the occurrence of the node there with occurrences of the nodes given in the vector of mappings, which partition the forward strand of the node being replaced.

◆ round_outward()

pair< size_t, size_t > vg::PathIndex::round_outward ( size_t  start,
size_t  past_end 
) const

Given an end-exclusive range on the path, round outward to the nearest node boundary positions.

◆ update_mapping_positions()

void vg::PathIndex::update_mapping_positions ( VG vg,
const string &  path_name 
)

Rebuild the mapping positions map by tracing all the paths in the given graph. TODO: We ought to move this functionality to the Paths object and make it use a good datastructure instead of brute force.

Member Data Documentation

◆ by_id

map<int64_t, pair<size_t, bool> > vg::PathIndex::by_id

Index from node ID to first position on the reference string and orientation it occurs there.

◆ by_start

map<size_t, NodeSide> vg::PathIndex::by_start

Index from start position on the reference to the side of the node that begins there. If it is a right side, the node occurs on the path in a reverse orientation.

◆ last_node_length

size_t vg::PathIndex::last_node_length
protected

This, combined with by_start, gets us the length of every node on the indexed path.

◆ mapping_positions

map<const mapping_t*, size_t> vg::PathIndex::mapping_positions

Index from Mapping pointers in a VG Paths object to their actual positions along their paths. Pointers may dangle if the vg graph changes the path.

◆ node_occurrences

map<id_t, vector<iterator> > vg::PathIndex::node_occurrences
protected

This holds all the places that a particular node occurs, in order. TODO: use this to replace by_id

◆ sequence

std::string vg::PathIndex::sequence

The actual sequence of the path, if desired.


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