vg
tools for working with variation graphs
|
#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, NodeSide > | by_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 |
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.
using vg::PathIndex::iterator = map<size_t, vg::NodeSide>::const_iterator |
We keep iterators to node occurrences along the ref path.
vg::PathIndex::PathIndex | ( | const Path & | path | ) |
Index just a path.
vg::PathIndex::PathIndex | ( | const list< mapping_t > & | mappings | ) |
Index just a list of mappings.
Index a list of mappings embedded in the given vg's Paths object, and pull sequence from the given vg.
vg::PathIndex::PathIndex | ( | const Path & | path, |
const HandleGraph & | graph | ||
) |
Index a path and pull sequence from a graph.
vg::PathIndex::PathIndex | ( | VG & | vg, |
const string & | path_name, | ||
bool | extract_sequence = false |
||
) |
Make a PathIndex from a path in a graph.
vg::PathIndex::PathIndex | ( | const PathHandleGraph & | graph, |
const string & | path_name, | ||
bool | extract_sequence = false |
||
) |
Make a PathIndex from a path in an indexed graph.
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.
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.
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.
PathIndex::iterator vg::PathIndex::begin | ( | ) | const |
Get the iterator to the first node occurrence on the indexed path.
PathIndex::iterator vg::PathIndex::end | ( | ) | const |
Get the iterator to the last node occurrence on the indexed path.
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.
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.
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.
size_t vg::PathIndex::node_length | ( | const iterator & | here | ) | const |
Get the length of the node occurrence on the path represented by this iterator.
|
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.
bool vg::PathIndex::path_contains_node | ( | int64_t | node_id | ) | const |
Check whether a node is on the reference path.
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.
|
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.
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.
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.
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.
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.
|
protected |
This, combined with by_start, gets us the length of every node on the indexed path.
map<const mapping_t*, size_t> vg::PathIndex::mapping_positions |
This holds all the places that a particular node occurs, in order. TODO: use this to replace by_id
std::string vg::PathIndex::sequence |
The actual sequence of the path, if desired.