vg
tools for working with variation graphs
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
vg::VG Class Reference

#include <vg.hpp>

Inheritance diagram for vg::VG:
vg::Progressive handlegraph::MutablePathDeletableHandleGraph handlegraph::MutablePathMutableHandleGraph handlegraph::DeletableHandleGraph handlegraph::MutablePathHandleGraph handlegraph::MutableHandleGraph handlegraph::MutableHandleGraph handlegraph::PathHandleGraph handlegraph::MutablePathMetadata handlegraph::HandleGraph handlegraph::HandleGraph handlegraph::HandleGraph handlegraph::PathMetadata handlegraph::PathMetadata

Classes

struct  Plan
 Structure for managing parallel construction of a graph. More...
 

Public Member Functions

virtual void serialize (ostream &out) const
 Write the contents of this graph to an ostream. More...
 
virtual void deserialize (istream &in)
 
virtual handle_t get_handle (const nid_t &node_id, bool is_reverse=false) const
 Look up the handle for the node with the given ID in the given orientation. More...
 
virtual nid_t get_id (const handle_t &handle) const
 Get the ID from a handle. More...
 
virtual bool get_is_reverse (const handle_t &handle) const
 Get the orientation of a handle. More...
 
virtual handle_t flip (const handle_t &handle) const
 Invert the orientation of a handle (potentially without getting its ID) More...
 
virtual size_t get_length (const handle_t &handle) const
 Get the length of a node. More...
 
virtual string get_sequence (const handle_t &handle) const
 
virtual bool follow_edges_impl (const handle_t &handle, bool go_left, const function< bool(const handle_t &)> &iteratee) const
 
virtual bool for_each_handle_impl (const function< bool(const handle_t &)> &iteratee, bool parallel=false) const
 
virtual size_t get_node_count () const
 Return the number of nodes in the graph. More...
 
virtual size_t get_edge_count () const
 Return the total number of edges in the graph. More...
 
virtual nid_t min_node_id () const
 Get the minimum node ID used in the graph, if any are used. More...
 
virtual nid_t max_node_id () const
 Get the maximum node ID used in the graph, if any are used. More...
 
virtual size_t get_degree (const handle_t &handle, bool go_left) const
 
virtual bool has_edge (const handle_t &left, const handle_t &right) const
 
virtual char get_base (const handle_t &handle, size_t index) const
 
virtual string get_subsequence (const handle_t &handle, size_t index, size_t size) const
 
virtual size_t get_path_count () const
 Returns the number of paths stored in the graph. More...
 
virtual bool has_path (const string &path_name) const
 Determine if a path name exists and is legal to get a path handle for. More...
 
virtual path_handle_t get_path_handle (const string &path_name) const
 Look up the path handle for the given path name. More...
 
virtual string get_path_name (const path_handle_t &path_handle) const
 Look up the name of a path from a handle to it. More...
 
virtual bool get_is_circular (const path_handle_t &path_handle) const
 Look up whether a path is circular. More...
 
virtual size_t get_step_count (const path_handle_t &path_handle) const
 Returns the number of node steps in the path. More...
 
virtual handle_t get_handle_of_step (const step_handle_t &step_handle) const
 Get a node handle (node ID and orientation) from a handle to an step on a path. More...
 
virtual path_handle_t get_path_handle_of_step (const step_handle_t &step_handle) const
 Returns a handle to the path that an step is on. More...
 
virtual step_handle_t path_begin (const path_handle_t &path_handle) const
 
virtual step_handle_t path_end (const path_handle_t &path_handle) const
 
virtual step_handle_t path_back (const path_handle_t &path_handle) const
 
virtual step_handle_t path_front_end (const path_handle_t &path_handle) const
 
virtual step_handle_t get_next_step (const step_handle_t &step_handle) const
 
virtual step_handle_t get_previous_step (const step_handle_t &step_handle) const
 
virtual bool has_next_step (const step_handle_t &step_handle) const
 Returns true if the step is not the last step in a non-circular path. More...
 
virtual bool has_previous_step (const step_handle_t &step_handle) const
 Returns true if the step is not the first step in a non-circular path. More...
 
virtual bool for_each_path_handle_impl (const function< bool(const path_handle_t &)> &iteratee) const
 Execute a function on each path in the graph. More...
 
virtual bool for_each_step_on_handle_impl (const handle_t &handle, const function< bool(const step_handle_t &)> &iteratee) const
 Loop over the steps of a handle in paths. More...
 
virtual handle_t create_handle (const string &sequence)
 
virtual handle_t create_handle (const string &sequence, const nid_t &id)
 
virtual void destroy_handle (const handle_t &handle)
 
virtual void create_edge (const handle_t &left, const handle_t &right)
 Create an edge connecting the given handles in the given order and orientations. More...
 
virtual void destroy_edge (const handle_t &left, const handle_t &right)
 Remove the edge connecting the given handles in the given order and orientations. More...
 
virtual void clear ()
 Remove all nodes and edges. Does not update any stored paths. More...
 
virtual void swap_handles (const handle_t &a, const handle_t &b)
 
virtual handle_t apply_orientation (const handle_t &handle)
 
virtual vector< handle_tdivide_handle (const handle_t &handle, const vector< size_t > &offsets)
 
virtual void optimize (bool allow_id_reassignment=true)
 
virtual bool apply_ordering (const std::vector< handle_t > &order, bool compact_ids=false)
 
virtual void set_id_increment (const nid_t &min_id)
 No-op function (required by MutableHandleGraph interface) More...
 
virtual void increment_node_ids (nid_t increment)
 Add the given value to all node IDs. Preserves the paths. More...
 
virtual void reassign_node_ids (const std::function< nid_t(const nid_t &)> &get_new_id)
 Reassign all node IDs as specified by the old->new mapping function. More...
 
virtual void destroy_path (const path_handle_t &path)
 Destroy the given path. Invalidates handles to the path and its node steps. More...
 
virtual path_handle_t create_path_handle (const string &name, bool is_circular=false)
 Create a path with the given name. More...
 
virtual step_handle_t append_step (const path_handle_t &path, const handle_t &to_append)
 Append a visit to a node to the given path. More...
 
virtual step_handle_t prepend_step (const path_handle_t &path, const handle_t &to_prepend)
 Append a visit to a node to the given path. More...
 
virtual pair< step_handle_t, step_handle_trewrite_segment (const step_handle_t &segment_begin, const step_handle_t &segment_end, const vector< handle_t > &new_segment)
 
virtual void set_circularity (const path_handle_t &path, bool circular)
 
void set_edge (Edge *)
 
void print_edges (void)
 
vector< pair< nid_t, bool > > & edges_start (Node *node)
 Get nodes and backward flags following edges that attach to this node's start. More...
 
vector< pair< nid_t, bool > > & edges_start (nid_t id)
 Get nodes and backward flags following edges that attach to this node's start. More...
 
vector< pair< nid_t, bool > > & edges_end (Node *node)
 Get nodes and backward flags following edges that attach to this node's end. More...
 
vector< pair< nid_t, bool > > & edges_end (nid_t id)
 Get nodes and backward flags following edges that attach to this node's end. More...
 
size_t size (void)
 Number of nodes. More...
 
size_t length (void)
 Total sequence length. More...
 
 VG (void)
 Default constructor. More...
 
 VG (istream &in, bool showp=false, bool warn_on_duplicates=true)
 Construct from Graph objects serialized in a tagged group stream. More...
 
void from_istream (istream &in, bool showp=false, bool warn_on_duplicates=true)
 
 VG (const function< void(const function< void(Graph &)> &)> &send_graphs, bool showp=false, bool warn_on_duplicates=true)
 
 VG (const Graph &from, bool showp=false, bool warn_on_duplicates=true)
 Construct from a single Protobuf graph. The same as making an empty VG and using extend(). More...
 
 VG (set< Node * > &nodes, set< Edge * > &edges)
 
map< nid_t, vcflib::Variant > get_node_nid_to_variant (vcflib::VariantCallFile vfile)
 
VG dagify (uint32_t expand_scc_steps, unordered_map< nid_t, pair< nid_t, bool > > &node_translation, size_t target_min_walk_length=0, size_t component_length_max=0)
 
VG unfold (uint32_t max_length, unordered_map< nid_t, pair< nid_t, bool > > &node_translation)
 
VG reverse_complement_graph (unordered_map< nid_t, pair< nid_t, bool >> &node_translation)
 Create the reverse complemented graph with topology preserved. Record translation in provided map. More...
 
void identity_translation (unordered_map< nid_t, pair< nid_t, bool >> &node_translation)
 Record the translation of this graph into itself in the provided map. More...
 
unordered_map< nid_t, pair< nid_t, bool > > overlay_node_translations (const unordered_map< nid_t, pair< nid_t, bool > > &over, const unordered_map< nid_t, pair< nid_t, bool > > &under)
 Assume two node translations, the over is based on the under; merge them. More...
 
vector< Edgebreak_cycles (void)
 
void remove_non_path (void)
 Remove pieces of the graph which are not part of any path. More...
 
void remove_path (void)
 Remove pieces of the graph which are part of some path. More...
 
set< Edge * > get_path_edges (void)
 Get all of the edges that are on any path. More...
 
void flip_doubly_reversed_edges (void)
 Convert edges that are both from_start and to_end to "regular" ones from end to start. More...
 
void from_turtle (string filename, string baseuri, bool showp=false)
 Build a graph from a Turtle stream. More...
 
 ~VG (void)
 Destructor. More...
 
 VG (const VG &other)
 Copy constructor. More...
 
 VG (VG &&other) noexcept
 Move constructor. More...
 
VGoperator= (const VG &other)
 Copy assignment operator. More...
 
VGoperator= (VG &&other) noexcept
 Move assignment operator. More...
 
void build_indexes (void)
 
void build_node_indexes (void)
 
void build_edge_indexes (void)
 
void build_indexes_no_init_size (void)
 
void build_node_indexes_no_init_size (void)
 
void build_edge_indexes_no_init_size (void)
 
void clear_node_indexes (void)
 
void clear_node_indexes_no_resize (void)
 
void clear_edge_indexes (void)
 
void clear_edge_indexes_no_resize (void)
 
void clear_indexes (void)
 
void clear_indexes_no_resize (void)
 
void resize_indexes (void)
 
void rebuild_indexes (void)
 
void rebuild_edge_indexes (void)
 
void merge (Graph &g)
 Literally merge protobufs. More...
 
void merge (VG &g)
 Literally merge protobufs. More...
 
void clear_paths (void)
 Clear the paths object (which indexes the graph.paths) and the graph paths themselves. More...
 
void sync_paths (void)
 Synchronize in-memory indexes and protobuf graph. More...
 
void merge_union (VG &g)
 
void remove_duplicated_in (VG &g)
 Helper to merge_union. More...
 
void remove_duplicates (void)
 Remove duplicated nodes and edges. More...
 
void serialize_to_function (const function< void(Graph &)> &emit, nid_t chunk_size=1000)
 
void serialize_to_emitter (vg::io::ProtobufEmitter< Graph > &emitter, nid_t chunk_size=1000)
 
void serialize_to_ostream (ostream &out, nid_t chunk_size=1000)
 
void serialize_to_file (const string &file_name, nid_t chunk_size=1000)
 
void compact_ids (void)
 Squish the node IDs down into as small a space as possible. Fixes up paths itself. More...
 
void compact_ids (hash_map< nid_t, nid_t > &new_id)
 
void decrement_node_ids (nid_t decrement)
 Subtract the given value from all the node IDs. Must not create a node with 0 or negative IDs. Invalidates the paths. More...
 
void swap_node_id (nid_t node_id, nid_t new_id)
 
void swap_node_id (Node *node, nid_t new_id)
 
void sort ()
 
void id_sort ()
 Order the backing graph data structure by node ID. More...
 
void extend (const VG &g, bool warn_on_duplicates=false)
 
void extend (const Graph &graph, bool warn_on_duplicates=false)
 
void append (VG &g)
 
void combine (VG &g)
 
void include (const Path &path)
 Edit the graph to include the path. More...
 
void edit (vector< Path > &paths_to_add, vector< Translation > *out_translations=nullptr, bool save_paths=false, bool update_paths=false, bool break_at_ends=false)
 
void edit (const string &paths_to_add_path, vector< Translation > *out_translations=nullptr, bool save_paths=false, const string &out_gam_path="", bool break_at_ends=false, bool remove_softclips=false)
 
vector< Translationedit_fast (const Path &path, set< NodeSide > &dangling, size_t max_node_size=1024)
 
void add_node (const Node &node)
 Add in the given node, by value. More...
 
void add_nodes (const vector< Node > &nodes)
 Add in the given nodes, by value. More...
 
void add_edge (const Edge &edge)
 Add in the given edge, by value. More...
 
void add_edges (const vector< Edge > &edges)
 Add in the given edges, by value. More...
 
void add_edges (const vector< Edge * > &edges)
 Add in the given edges, by value. More...
 
void add_nodes (const set< Node * > &nodes)
 Add in the given nodes, by value. More...
 
void add_edges (const set< Edge * > &edges)
 Add in the given edges, by value. More...
 
size_t node_count (void) const
 Return the number of nodes in the graph. More...
 
size_t edge_count (void) const
 Count the number of edges in the graph. More...
 
int node_rank (Node *node)
 Get the rank of the node in the protobuf array that backs the graph. More...
 
int node_rank (nid_t id)
 Get the rank of the node in the protobuf array that backs the graph. More...
 
int start_degree (Node *node)
 Get the number of edges attached to the start of a node. More...
 
int end_degree (Node *node)
 Get the number of edges attached to the end of a node. More...
 
int left_degree (NodeTraversal node)
 Get the number of edges attached to the left side of a NodeTraversal. More...
 
int right_degree (NodeTraversal node)
 Get the number of edges attached to the right side of a NodeTraversal. More...
 
void edges_of_node (Node *node, vector< Edge * > &edges)
 
vector< Edge * > edges_of (Node *node)
 Get the edges of the specified node. More...
 
vector< Edge * > edges_from (Node *node)
 Get the edges from the specified node. More...
 
vector< Edge * > edges_to (Node *node)
 Get the edges to the specified node. More...
 
void edges_of_nodes (set< Node * > &nodes, set< Edge * > &edges)
 Get the edges of the specified set of nodes, and add them to the given set of edge pointers. More...
 
set< NodeSidesides_to (NodeSide side)
 Get the sides on the other side of edges to this side of the node. More...
 
set< NodeSidesides_from (NodeSide side)
 Get the sides on the other side of edges from this side of the node. More...
 
set< NodeSidesides_from (nid_t id)
 Get the sides from both sides of the node. More...
 
set< NodeSidesides_to (nid_t id)
 Get the sides to both sides of the node. More...
 
set< NodeSidesides_of (NodeSide side)
 Union of sides_to and sides_from. More...
 
set< pair< NodeSide, bool > > sides_context (nid_t node_id)
 Get all sides connecting to this node. More...
 
bool same_context (nid_t id1, nid_t id2)
 Use sides_from an sides_to to determine if both nodes have the same context. More...
 
bool is_ancestor_prev (nid_t node_id, nid_t candidate_id)
 Determine if the node is a prev ancestor of this one. More...
 
bool is_ancestor_prev (nid_t node_id, nid_t candidate_id, set< nid_t > &seen, size_t steps=64)
 Determine if the node is a prev ancestor of this one by trying to find it in a given number of steps. More...
 
bool is_ancestor_next (nid_t node_id, nid_t candidate_id)
 Determine if the node is a next ancestor of this one. More...
 
bool is_ancestor_next (nid_t node_id, nid_t candidate_id, set< nid_t > &seen, size_t steps=64)
 Determine if the node is a next ancestor of this one by trying to find it in a given number of steps. More...
 
nid_t common_ancestor_prev (nid_t id1, nid_t id2, size_t steps=64)
 Try to find a common ancestor by walking back up to steps from the first node. More...
 
nid_t common_ancestor_next (nid_t id1, nid_t id2, size_t steps=64)
 Try to find a common ancestor by walking forward up to steps from the first node. More...
 
bool adjacent (const Position &pos1, const Position &pos2)
 Determine if pos1 occurs directly before pos2. More...
 
Nodecreate_node (const string &seq)
 Create a node. Use the VG class to generate ids. More...
 
Nodecreate_node (const string &seq, nid_t id)
 Create a node. Use a specified, nonzero node ID. More...
 
Nodeget_node (nid_t id)
 Find a particular node. More...
 
const Nodeget_node (nid_t id) const
 
void nonoverlapping_node_context_without_paths (Node *node, VG &g)
 
void expand_context (VG &g, size_t distance, bool add_paths=true, bool use_steps=true)
 
void expand_context_by_steps (VG &g, size_t steps, bool add_paths=true)
 Expand the context of the given graph by the given number of steps. More...
 
void expand_context_by_length (VG &g, size_t length, bool add_paths=true, bool reflect=false, const set< NodeSide > &barriers=set< NodeSide >())
 
void destroy_node (Node *node)
 Destroy the node at the given pointer. This pointer must point to a Node owned by the graph. More...
 
void destroy_node (nid_t id)
 Destroy the node with the given ID. More...
 
bool has_node (nid_t id) const
 Determine if the graph has a node with the given ID. More...
 
bool has_node (const Node *node) const
 Determine if the graph contains the given node. More...
 
bool has_node (const Node &node) const
 Determine if the graph contains the given node. More...
 
Nodefind_node_by_name_or_add_new (string name)
 Find a node with the given name, or create a new one if none is found. More...
 
void for_each_node (function< void(Node *)> lambda)
 Run the given function on every node. More...
 
void for_each_node (function< void(const Node *)> lambda) const
 
void for_each_node_parallel (function< void(Node *)> lambda)
 Run the given function on every node in parallel. More...
 
void for_each_connected_node (Node *node, function< void(Node *)> lambda)
 Go through all the nodes in the same connected component as the given node. Ignores relative orientation. More...
 
void dfs (const function< void(NodeTraversal)> &node_begin_fn, const function< void(NodeTraversal)> &node_end_fn, const function< bool(void)> &break_fn, const function< void(Edge *)> &edge_fn, const function< void(Edge *)> &tree_fn, const function< void(Edge *)> &edge_curr_fn, const function< void(Edge *)> &edge_cross_fn, const vector< NodeTraversal > *sources, const unordered_set< NodeTraversal > *sinks)
 
void dfs (const function< void(NodeTraversal)> &node_begin_fn, const function< void(NodeTraversal)> &node_end_fn, const vector< NodeTraversal > *sources=NULL, const unordered_set< NodeTraversal > *sinks=NULL)
 Specialization of dfs for only handling nodes. More...
 
void dfs (const function< void(NodeTraversal)> &node_begin_fn, const function< void(NodeTraversal)> &node_end_fn, const function< bool(void)> &break_fn)
 Specialization of dfs for only handling nodes + break function. More...
 
bool empty (void) const
 Is the graph empty? More...
 
const string hash (void)
 Generate a digest of the serialized graph. More...
 
void remove_null_nodes (void)
 
void remove_node_forwarding_edges (Node *node)
 Remove a node but connect all of its predecessor and successor nodes with new edges. More...
 
void remove_null_nodes_forwarding_edges (void)
 Remove null nodes but connect predecessors and successors, preserving structure. More...
 
void remove_orphan_edges (void)
 Remove edges for which one of the nodes is not present. More...
 
void remove_inverting_edges (void)
 Remove edges representing an inversion and edges on the reverse complement. More...
 
bool has_inverting_edges (void)
 Determine if the graph has inversions. More...
 
void keep_paths (const set< string > &path_names, set< string > &kept_names)
 
void keep_path (const string &path_name)
 
int path_edge_count (list< NodeTraversal > &path, int32_t offset, int path_length)
 
int path_end_node_offset (list< NodeTraversal > &path, int32_t offset, int path_length)
 
const vector< Alignmentpaths_as_alignments (void)
 Convert the stored paths in this graph to alignments. More...
 
const string path_sequence (const Path &path)
 Return sequence string of path. More...
 
double path_identity (const Path &path1, const Path &path2)
 
string trav_sequence (const NodeTraversal &trav)
 Get the sequence of a NodeTraversal. More...
 
nid_t get_node_at_nucleotide (string pathname, int nuc)
 
Edgecreate_edge (Node *from, Node *to, bool from_start=false, bool to_end=false)
 
Edgecreate_edge (nid_t from, nid_t to, bool from_start=false, bool to_end=false)
 
Edgecreate_edge (NodeTraversal left, NodeTraversal right)
 
Edgecreate_edge (NodeSide side1, NodeSide side2)
 
Edgeget_edge (const NodeSide &side1, const NodeSide &side2)
 
Edgeget_edge (const pair< NodeSide, NodeSide > &sides)
 
Edgeget_edge (const NodeTraversal &left, const NodeTraversal &right)
 Get the edge connecting the given oriented nodes in the given order. More...
 
void destroy_edge (Edge *edge)
 Destroy the edge at the given pointer. This pointer must point to an edge owned by the graph. More...
 
void destroy_edge (const NodeSide &side1, const NodeSide &side2)
 Destroy the edge between the given sides of nodes. These can be in either order. More...
 
void destroy_edge (const pair< NodeSide, NodeSide > &sides)
 Destroy the edge between the given sides of nodes. This can take sides in any order. More...
 
void unindex_edge_by_node_sides (const NodeSide &side1, const NodeSide &side2)
 
void unindex_edge_by_node_sides (Edge *edge)
 
void index_edge_by_node_sides (Edge *edge)
 
bool has_edge (const NodeSide &side1, const NodeSide &side2) const
 Get the edge between the given node sides, which can be in either order. More...
 
bool has_edge (const pair< NodeSide, NodeSide > &sides) const
 Determine if the graph has an edge. This can take sides in any order. More...
 
bool has_edge (Edge *edge) const
 Determine if the graph has an edge. This can take sides in any order. More...
 
bool has_edge (const Edge &edge) const
 Determine if the graph has an edge. This can take sides in any order. More...
 
bool has_inverting_edge (Node *n)
 Determine if the graph has an inverting edge on the given node. More...
 
bool has_inverting_edge_from (Node *n)
 Determine if the graph has an inverting edge from the given node. More...
 
bool has_inverting_edge_to (Node *n)
 Determine if the graph has an inverting edge to the given node. More...
 
void for_each_edge (function< void(Edge *)> lambda)
 Run the given function for each edge. More...
 
void for_each_edge (function< void(const Edge *)> lambda) const
 
void for_each_edge_parallel (function< void(Edge *)> lambda)
 Run the given function for each edge, in parallel. More...
 
void circularize (nid_t head, nid_t tail)
 Circularize a subgraph / path using the head / tail nodes. More...
 
void circularize (vector< string > pathnames)
 
void connect_node_to_nodes (NodeTraversal node, vector< NodeTraversal > &nodes)
 
void connect_node_to_nodes (Node *node, vector< Node * > &nodes, bool from_start=false)
 
void connect_nodes_to_node (vector< NodeTraversal > &nodes, NodeTraversal node)
 
void connect_nodes_to_node (vector< Node * > &nodes, Node *node, bool to_end=false)
 connect nodes -> node. More...
 
void divide_node (Node *node, int pos, Node *&left, Node *&right)
 
void divide_node (Node *node, vector< int > &positions, vector< Node * > &parts)
 Divide a node at a given internal position. This version works on a collection of internal positions, in linear time. More...
 
void divide_path (map< long, nid_t > &path, long pos, Node *&left, Node *&right)
 Divide a path at a position. Also invalidates stored rank information. More...
 
void to_dot (ostream &out, vector< Alignment > alignments={}, vector< Locus > loci={}, bool show_paths=false, bool walk_paths=false, bool annotate_paths=false, bool show_mappings=false, bool simple_mode=false, bool noseq_mode=false, bool invert_edge_ports=false, bool color_variants=false, bool ultrabubble_labeling=false, bool skip_missing_nodes=false, bool ascii_labels=false, int random_seed=0)
 Convert the graph to Dot format. More...
 
void to_turtle (ostream &out, const string &rdf_base_uri, bool precompress)
 Convert the graph to Turtle format. More...
 
bool is_valid (bool check_nodes=true, bool check_edges=true, bool check_paths=true, bool check_orphans=true)
 Determine if the graph is valid or not, according to the specified criteria. More...
 
void swap_nodes (Node *a, Node *b)
 Swap the given nodes. TODO: what does that mean? More...
 
Alignment align (const string &sequence, const Aligner *aligner, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align (const Alignment &alignment, const Aligner *aligner, const vector< MaximalExactMatch > &mems, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align (const Alignment &alignment, const Aligner *aligner, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align (const Alignment &alignment, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align (const string &sequence, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align_qual_adjusted (const Alignment &alignment, const QualAdjAligner *qual_adj_aligner, const vector< MaximalExactMatch > &mems, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align_qual_adjusted (const Alignment &alignment, const QualAdjAligner *qual_adj_aligner, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
Alignment align_qual_adjusted (const string &sequence, const QualAdjAligner *qual_adj_aligner, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
void paths_between (Node *from, Node *to, vector< Path > &paths)
 
void paths_between (nid_t from, nid_t to, vector< Path > &paths)
 
void likelihoods (vector< Alignment > &alignments, vector< Path > &paths, vector< long double > &likelihoods)
 
void nodes_prev (NodeTraversal n, vector< NodeTraversal > &nodes)
 Get the nodes attached to the left side of the given NodeTraversal, in their proper orientations. More...
 
vector< NodeTraversalnodes_prev (NodeTraversal n)
 Get the nodes attached to the left side of the given NodeTraversal, in their proper orientations. More...
 
set< NodeTraversaltravs_to (NodeTraversal node)
 Get traversals before this node on the same strand. Same as nodes_prev but using set. More...
 
void nodes_next (NodeTraversal n, vector< NodeTraversal > &nodes)
 Get the nodes attached to the right side of the given NodeTraversal, in their proper orientations. More...
 
vector< NodeTraversalnodes_next (NodeTraversal n)
 Get the nodes attached to the right side of the given NodeTraversal, in their proper orientations. More...
 
set< NodeTraversaltravs_from (NodeTraversal node)
 Get traversals after this node on the same strand. Same as nodes_next but using set. More...
 
set< NodeTraversaltravs_of (NodeTraversal node)
 Get traversals either before or after this node on the same strand. More...
 
int node_count_prev (NodeTraversal n)
 Count the nodes attached to the left side of the given NodeTraversal. More...
 
int node_count_next (NodeTraversal n)
 Count the nodes attached to the right side of the given NodeTraversal. More...
 
Path create_path (const list< NodeTraversal > &nodes)
 Create a path. More...
 
Path create_path (const vector< NodeTraversal > &nodes)
 Create a path. More...
 
void expand_path (const list< NodeTraversal > &path, vector< NodeTraversal > &expanded)
 Expand a path. TODO: what does that mean? More...
 
void node_starts_in_path (const list< NodeTraversal > &path, map< Node *, int > &node_start)
 
bool mapping_is_total_match (const Mapping &m)
 Return true if the mapping completely covers the node it maps to and is a perfect match. More...
 
map< string, vector< mapping_t > > concat_mappings_for_node_pair (nid_t id1, nid_t id2)
 Concatenate the mappings for a pair of nodes; handles multiple mappings per path. More...
 
void expand_path (list< NodeTraversal > &path, vector< list< NodeTraversal >::iterator > &expanded)
 
void node_starts_in_path (list< NodeTraversal > &path, map< NodeTraversal *, int > &node_start)
 
Alignment random_read (size_t read_len, mt19937 &rng, nid_t min_id, nid_t max_id, bool either_strand)
 
void head_nodes (vector< Node * > &nodes)
 Get the head nodes (nodes with edges only to their right sides). These are required to be oriented forward. More...
 
vector< Node * > head_nodes (void)
 Get the head nodes (nodes with edges only to their right sides). These are required to be oriented forward. More...
 
bool is_head_node (nid_t id)
 Determine if a node is a head node. More...
 
bool is_head_node (Node *node)
 Determine if a node is a head node. More...
 
vector< Node * > tail_nodes (void)
 Get the tail nodes (nodes with edges only to their left sides). These are required to be oriented forward. More...
 
void tail_nodes (vector< Node * > &nodes)
 Get the tail nodes (nodes with edges only to their left sides). These are required to be oriented forward. More...
 
bool is_tail_node (nid_t id)
 Determine if a node is a tail node. More...
 
bool is_tail_node (Node *node)
 Determine if a node is a tail node. More...
 
void collect_subgraph (Node *node, set< Node * > &subgraph)
 Collect the subgraph of a Node. TODO: what does that mean? More...
 
Nodejoin_heads (void)
 Join head nodes of graph to common null node, creating a new single head. More...
 
void join_heads (Node *node, bool from_start=false)
 Join head nodes of graph to specified node. Optionally from the start/to the end of the new node. More...
 
void join_tails (Node *node, bool to_end=false)
 Join tail nodes of graph to specified node. Optionally from the start/to the end of the new node. More...
 
void wrap_with_null_nodes (void)
 Add singular head and tail null nodes to graph. More...
 
void add_start_end_markers (int length, char start_char, char end_char, Node *&start_node, Node *&end_node, nid_t &start_id, nid_t &end_id)
 
- Public Member Functions inherited from vg::Progressive
void preload_progress (const string &message)
 
void create_progress (const string &message, long count)
 
void create_progress (long count)
 
void update_progress (long i)
 
void increment_progress ()
 
void destroy_progress (void)
 
- Public Member Functions inherited from handlegraph::MutablePathDeletableHandleGraph
virtual ~MutablePathDeletableHandleGraph ()=default
 
- Public Member Functions inherited from handlegraph::MutablePathMutableHandleGraph
virtual ~MutablePathMutableHandleGraph ()=default
 
- Public Member Functions inherited from handlegraph::MutablePathHandleGraph
virtual ~MutablePathHandleGraph ()=default
 
virtual path_handle_t create_path_handle (const std::string &name, bool is_circular=false)=0
 
virtual path_handle_t rename_path (const path_handle_t &path_handle, const std::string &new_name)
 
virtual void pop_front_step (const path_handle_t &path_handle)
 
virtual void pop_back_step (const path_handle_t &path_handle)
 
virtual std::pair< step_handle_t, step_handle_trewrite_segment (const step_handle_t &segment_begin, const step_handle_t &segment_end, const std::vector< handle_t > &new_segment)=0
 
- Public Member Functions inherited from handlegraph::PathHandleGraph
virtual ~PathHandleGraph ()=default
 
virtual bool has_path (const std::string &path_name) const =0
 Determine if a path name exists and is legal to get a path handle for. More...
 
virtual path_handle_t get_path_handle (const std::string &path_name) const =0
 
virtual size_t get_step_count (const handle_t &handle) const
 Returns the number of node steps on a handle. More...
 
template<typename Iteratee >
bool for_each_path_handle (const Iteratee &iteratee) const
 
template<typename Iteratee >
bool for_each_step_on_handle (const handle_t &handle, const Iteratee &iteratee) const
 
virtual std::vector< step_handle_tsteps_of_handle (const handle_t &handle, bool match_orientation=false) const
 
virtual bool is_empty (const path_handle_t &path_handle) const
 Returns true if the given path is empty, and false otherwise. More...
 
PathForEachSocket scan_path (const path_handle_t &path) const
 
template<typename Iteratee >
bool for_each_step_in_path (const path_handle_t &path, const Iteratee &iteratee) const
 
- Public Member Functions inherited from handlegraph::HandleGraph
virtual ~HandleGraph ()=default
 
template<typename Iteratee >
bool follow_edges (const handle_t &handle, bool go_left, const Iteratee &iteratee) const
 
template<typename Iteratee >
bool for_each_handle (const Iteratee &iteratee, bool parallel=false) const
 
bool has_edge (const edge_t &edge) const
 Convenient wrapper of has_edge for edge_t argument. More...
 
virtual size_t get_total_length () const
 
handle_t forward (const handle_t &handle) const
 Get the locally forward version of a handle. More...
 
edge_t edge_handle (const handle_t &left, const handle_t &right) const
 
handle_t traverse_edge_handle (const edge_t &edge, const handle_t &left) const
 
template<typename Iteratee >
bool for_each_edge (const Iteratee &iteratee, bool parallel=false) const
 
- Public Member Functions inherited from handlegraph::MutableHandleGraph
virtual ~MutableHandleGraph ()=default
 
virtual handle_t create_handle (const std::string &sequence)=0
 
virtual handle_t create_handle (const std::string &sequence, const nid_t &id)=0
 
void create_edge (const edge_t &edge)
 Convenient wrapper for create_edge. More...
 
virtual std::vector< handle_tdivide_handle (const handle_t &handle, const std::vector< size_t > &offsets)=0
 
std::pair< handle_t, handle_tdivide_handle (const handle_t &handle, size_t offset)
 Specialization of divide_handle for a single division point. More...
 
virtual void increment_node_ids (long increment)
 This specialization for long appears to be needed to avoid confusion about nid_t. More...
 
- Public Member Functions inherited from handlegraph::DeletableHandleGraph
virtual ~DeletableHandleGraph ()=default
 
virtual handle_t truncate_handle (const handle_t &handle, bool trunc_left, size_t offset)
 
void destroy_edge (const edge_t &edge)
 Convenient wrapper for destroy_edge. More...
 

Public Attributes

Graph graph
 Protobuf-based representation. More...
 
Paths paths
 
string name
 Name of the graph. More...
 
nid_t current_id
 Current id for Node to be added next. More...
 
hash_map< nid_t, Node * > node_by_id
 Nodes by id. More...
 
pair_hash_map< pair< NodeSide, NodeSide >, Edge * > edge_by_sides
 
hash_map< Node *, int > node_index
 
hash_map< Edge *, int > edge_index
 
hash_map< nid_t, vector< pair< nid_t, bool > > > edges_on_start
 Stores the destinations and backward flags for edges attached to the starts of nodes (whether that node is "from" or "to"). More...
 
hash_map< nid_t, vector< pair< nid_t, bool > > > edges_on_end
 Stores the destinations and backward flags for edges attached to the ends of nodes (whether that node is "from" or "to"). More...
 
map< string, SnarlTraversalvariant_to_traversal
 
- Public Attributes inherited from vg::Progressive
bool show_progress = false
 

Private Member Functions

bool is_self_looping (Node *node)
 Does the specified node have any self-loops? More...
 
Nodemerge_nodes (const list< Node * > &nodes)
 Use the orientation of the first node as the basis. More...
 
void _for_each_kmer (int kmer_size, bool path_only, int edge_max, function< void(string &, list< NodeTraversal >::iterator, int, list< NodeTraversal > &, VG &)> lambda, bool parallel, int stride, bool allow_dups, bool allow_negatives, Node *node=nullptr)
 
Alignment align (const Alignment &alignment, const Aligner *aligner, const QualAdjAligner *qual_adj_aligner, const vector< MaximalExactMatch > &mems, bool traceback=true, bool acyclic_and_sorted=false, size_t max_query_graph_ratio=0, bool pinned_alignment=false, bool pin_left=false, bool banded_global=false, size_t band_padding_override=0, size_t max_span=0, size_t unroll_length=0, int xdrop_alignment=0)
 
void init (void)
 

Private Attributes

vector< nid_tempty_ids
 Placeholder for functions that sometimes need to be passed an empty vector. More...
 
vector< pair< nid_t, bool > > empty_edge_ends
 Placeholder for functions that sometimes need to be passed an empty vector. More...
 
bool warned_about_rewrites = false
 

Additional Inherited Members

- Protected Member Functions inherited from handlegraph::PathHandleGraph
virtual bool for_each_path_handle_impl (const std::function< bool(const path_handle_t &)> &iteratee) const =0
 
virtual bool for_each_step_on_handle_impl (const handle_t &handle, const std::function< bool(const step_handle_t &)> &iteratee) const =0
 
- Protected Member Functions inherited from handlegraph::HandleGraph
virtual bool follow_edges_impl (const handle_t &handle, bool go_left, const std::function< bool(const handle_t &)> &iteratee) const =0
 
virtual bool for_each_handle_impl (const std::function< bool(const handle_t &)> &iteratee, bool parallel=false) const =0
 

Detailed Description

Represents a variation graph. Graphs consist of nodes, connected by edges. Graphs are bidirected and may be cyclic. Nodes carry forward-oriented sequences. Edges are directed, with a "from" and to" node, and are generally used to connect the end of the "from" node to the start of the "to" node. However, edges can connect to either the start or end of either node.

Constructor & Destructor Documentation

◆ VG() [1/7]

vg::VG::VG ( void  )

Default constructor.

◆ VG() [2/7]

vg::VG::VG ( istream &  in,
bool  showp = false,
bool  warn_on_duplicates = true 
)

Construct from Graph objects serialized in a tagged group stream.

◆ VG() [3/7]

vg::VG::VG ( const function< void(const function< void(Graph &)> &)> &  send_graphs,
bool  showp = false,
bool  warn_on_duplicates = true 
)

Construct from an arbitrary source of Graph protobuf messages, with the message source in control of execution. Takes a function that takes a callback to call with each Graph object to incorporate. The Graph object may be moved by the VG.

◆ VG() [4/7]

vg::VG::VG ( const Graph from,
bool  showp = false,
bool  warn_on_duplicates = true 
)

Construct from a single Protobuf graph. The same as making an empty VG and using extend().

◆ VG() [5/7]

vg::VG::VG ( set< Node * > &  nodes,
set< Edge * > &  edges 
)

Construct from sets of nodes and edges. For example, from a subgraph of another graph.

◆ ~VG()

vg::VG::~VG ( void  )

Destructor.

◆ VG() [6/7]

vg::VG::VG ( const VG other)

Copy constructor.

◆ VG() [7/7]

vg::VG::VG ( VG &&  other)
noexcept

Move constructor.

Member Function Documentation

◆ _for_each_kmer()

void vg::VG::_for_each_kmer ( int  kmer_size,
bool  path_only,
int  edge_max,
function< void(string &, list< NodeTraversal >::iterator, int, list< NodeTraversal > &, VG &)>  lambda,
bool  parallel,
int  stride,
bool  allow_dups,
bool  allow_negatives,
Node node = nullptr 
)
private

Call the given function on each kmer. If parallel is specified, goes through nodes one per thread. If node is not null, looks only at kmers of that specific node.

◆ add_edge()

void vg::VG::add_edge ( const Edge edge)

Add in the given edge, by value.

◆ add_edges() [1/3]

void vg::VG::add_edges ( const set< Edge * > &  edges)

Add in the given edges, by value.

◆ add_edges() [2/3]

void vg::VG::add_edges ( const vector< Edge * > &  edges)

Add in the given edges, by value.

◆ add_edges() [3/3]

void vg::VG::add_edges ( const vector< Edge > &  edges)

Add in the given edges, by value.

◆ add_node()

void vg::VG::add_node ( const Node node)

Add in the given node, by value.

◆ add_nodes() [1/2]

void vg::VG::add_nodes ( const set< Node * > &  nodes)

Add in the given nodes, by value.

◆ add_nodes() [2/2]

void vg::VG::add_nodes ( const vector< Node > &  nodes)

Add in the given nodes, by value.

◆ add_start_end_markers()

void vg::VG::add_start_end_markers ( int  length,
char  start_char,
char  end_char,
Node *&  start_node,
Node *&  end_node,
nid_t start_id,
nid_t end_id 
)

Add a start node and an end node, where all existing heads in the graph are connected to the start node, and all existing tails in the graph are connected to the end node. Any connected components in the graph which do not have either are connected to the start at an arbitrary point, and the end node from nodes going to that arbitrary point. If start_node or end_node is null, a new node will be created. Otherwise, the passed node will be used. Note that this visits every node, to make sure it is attached to all connected components. Note that if a graph has, say, heads but no tails, the start node will be attached buut the end node will be free-floating.

◆ adjacent()

bool vg::VG::adjacent ( const Position pos1,
const Position pos2 
)

Determine if pos1 occurs directly before pos2.

◆ align() [1/6]

Alignment vg::VG::align ( const Alignment alignment,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align with default Aligner. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ align() [2/6]

Alignment vg::VG::align ( const Alignment alignment,
const Aligner aligner,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

◆ align() [3/6]

Alignment vg::VG::align ( const Alignment alignment,
const Aligner aligner,
const QualAdjAligner qual_adj_aligner,
const vector< MaximalExactMatch > &  mems,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)
private

Private method to funnel other align functions into. max_span specifies the min distance to unfold the graph to, and is meant to be the longest path that the specified sequence could cover, accounting for deletions. If it's less than the sequence's length, the sequence's length is used. band_padding_override gives the band padding to use for banded global alignment. In banded global mode, if the band padding override is nonzero, permissive banding is not used, and instead the given band padding is provided. If the band padding override is not provided, the max span is used as the band padding and permissive banding is enabled.

◆ align() [4/6]

Alignment vg::VG::align ( const Alignment alignment,
const Aligner aligner,
const vector< MaximalExactMatch > &  mems,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align without base quality adjusted scores. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ align() [5/6]

Alignment vg::VG::align ( const string &  sequence,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align with default Aligner. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ align() [6/6]

Alignment vg::VG::align ( const string &  sequence,
const Aligner aligner,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align without base quality adjusted scores. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ align_qual_adjusted() [1/3]

Alignment vg::VG::align_qual_adjusted ( const Alignment alignment,
const QualAdjAligner qual_adj_aligner,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

◆ align_qual_adjusted() [2/3]

Alignment vg::VG::align_qual_adjusted ( const Alignment alignment,
const QualAdjAligner qual_adj_aligner,
const vector< MaximalExactMatch > &  mems,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align with base quality adjusted scores. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ align_qual_adjusted() [3/3]

Alignment vg::VG::align_qual_adjusted ( const string &  sequence,
const QualAdjAligner qual_adj_aligner,
bool  traceback = true,
bool  acyclic_and_sorted = false,
size_t  max_query_graph_ratio = 0,
bool  pinned_alignment = false,
bool  pin_left = false,
bool  banded_global = false,
size_t  band_padding_override = 0,
size_t  max_span = 0,
size_t  unroll_length = 0,
int  xdrop_alignment = 0 
)

Align with base quality adjusted scores. Align to the graph. May modify the graph by re-ordering the nodes. May add nodes to the graph, but cleans them up afterward.

◆ append()

void vg::VG::append ( VG g)

Add another graph into this graph, attaching tails to heads. Modify ids of the second graph to ensure we don't have conflicts. Then attach tails of this graph to the heads of the other, and extend(g).

◆ append_step()

step_handle_t vg::VG::append_step ( const path_handle_t path,
const handle_t to_append 
)
virtual

Append a visit to a node to the given path.

Implements handlegraph::MutablePathHandleGraph.

◆ apply_ordering()

bool vg::VG::apply_ordering ( const std::vector< handle_t > &  order,
bool  compact_ids = false 
)
virtual

Reorder the graph's internal structure to match that given. This sets the order that is used for iteration in functions like for_each_handle. If compact_ids is true, may (but will not necessarily) compact the id space of the graph to match the ordering, from 1->|ordering|. In other cases, node IDs will be preserved. This may be a no-op in the case of graph implementations that do not have any mechanism to maintain an ordering. This may invalidate outstanding handles. Returns true if node IDs actually were adjusted to match the given order, and false if they remain unchanged.

Implements handlegraph::MutableHandleGraph.

◆ apply_orientation()

handle_t vg::VG::apply_orientation ( const handle_t handle)
virtual

Alter the node that the given handle corresponds to so the orientation indicated by the handle becomes the node's local forward orientation. Rewrites all edges pointing to the node and the node's sequence to reflect this. Invalidates all handles to the node (including the one passed). Returns a new, valid handle to the node in its new forward orientation. Note that it is possible for the node's ID to change.

Implements handlegraph::MutableHandleGraph.

◆ break_cycles()

vector< Edge > vg::VG::break_cycles ( void  )

Use our topological sort to quickly break cycles in the graph, return the edges which are removed. Very non-optimal, but fast.

◆ build_edge_indexes()

void vg::VG::build_edge_indexes ( void  )

◆ build_edge_indexes_no_init_size()

void vg::VG::build_edge_indexes_no_init_size ( void  )

◆ build_indexes()

void vg::VG::build_indexes ( void  )

◆ build_indexes_no_init_size()

void vg::VG::build_indexes_no_init_size ( void  )

◆ build_node_indexes()

void vg::VG::build_node_indexes ( void  )

◆ build_node_indexes_no_init_size()

void vg::VG::build_node_indexes_no_init_size ( void  )

◆ circularize() [1/2]

void vg::VG::circularize ( nid_t  head,
nid_t  tail 
)

Circularize a subgraph / path using the head / tail nodes.

◆ circularize() [2/2]

void vg::VG::circularize ( vector< string >  pathnames)

◆ clear()

void vg::VG::clear ( )
virtual

Remove all nodes and edges. Does not update any stored paths.

Implements handlegraph::DeletableHandleGraph.

◆ clear_edge_indexes()

void vg::VG::clear_edge_indexes ( void  )

◆ clear_edge_indexes_no_resize()

void vg::VG::clear_edge_indexes_no_resize ( void  )

◆ clear_indexes()

void vg::VG::clear_indexes ( void  )

◆ clear_indexes_no_resize()

void vg::VG::clear_indexes_no_resize ( void  )

◆ clear_node_indexes()

void vg::VG::clear_node_indexes ( void  )

◆ clear_node_indexes_no_resize()

void vg::VG::clear_node_indexes_no_resize ( void  )

◆ clear_paths()

void vg::VG::clear_paths ( void  )

Clear the paths object (which indexes the graph.paths) and the graph paths themselves.

◆ collect_subgraph()

void vg::VG::collect_subgraph ( Node node,
set< Node * > &  subgraph 
)

Collect the subgraph of a Node. TODO: what does that mean?

◆ combine()

void vg::VG::combine ( VG g)

Add another graph into this graph. Don't append or join the nodes in the graphs; just ensure that ids are unique, then apply extend.

◆ common_ancestor_next()

nid_t vg::VG::common_ancestor_next ( nid_t  id1,
nid_t  id2,
size_t  steps = 64 
)

Try to find a common ancestor by walking forward up to steps from the first node.

◆ common_ancestor_prev()

nid_t vg::VG::common_ancestor_prev ( nid_t  id1,
nid_t  id2,
size_t  steps = 64 
)

Try to find a common ancestor by walking back up to steps from the first node.

◆ compact_ids() [1/2]

void vg::VG::compact_ids ( hash_map< nid_t, nid_t > &  new_id)

Squish the node IDs down into as small a space as possible. Fixes up paths itself. Record translation in provided map.

◆ compact_ids() [2/2]

void vg::VG::compact_ids ( void  )

Squish the node IDs down into as small a space as possible. Fixes up paths itself.

◆ concat_mappings_for_node_pair()

map<string, vector<mapping_t> > vg::VG::concat_mappings_for_node_pair ( nid_t  id1,
nid_t  id2 
)

Concatenate the mappings for a pair of nodes; handles multiple mappings per path.

◆ connect_node_to_nodes() [1/2]

void vg::VG::connect_node_to_nodes ( Node node,
vector< Node * > &  nodes,
bool  from_start = false 
)

Connect node -> nodes. You can optionally use the start of the first node instead of the end.

◆ connect_node_to_nodes() [2/2]

void vg::VG::connect_node_to_nodes ( NodeTraversal  node,
vector< NodeTraversal > &  nodes 
)

Connect node -> nodes. Connects from the right side of the first to the left side of the second.

◆ connect_nodes_to_node() [1/2]

void vg::VG::connect_nodes_to_node ( vector< Node * > &  nodes,
Node node,
bool  to_end = false 
)

connect nodes -> node.

◆ connect_nodes_to_node() [2/2]

void vg::VG::connect_nodes_to_node ( vector< NodeTraversal > &  nodes,
NodeTraversal  node 
)

connect nodes -> node. Connects from the right side of the first to the left side of the second.

◆ create_edge() [1/5]

void vg::VG::create_edge ( const handle_t left,
const handle_t right 
)
virtual

Create an edge connecting the given handles in the given order and orientations.

Implements handlegraph::MutableHandleGraph.

◆ create_edge() [2/5]

Edge * vg::VG::create_edge ( nid_t  from,
nid_t  to,
bool  from_start = false,
bool  to_end = false 
)

Create an edge. If the given edge cannot be created, returns null. If the given edge already exists, returns the existing edge.

◆ create_edge() [3/5]

Edge * vg::VG::create_edge ( Node from,
Node to,
bool  from_start = false,
bool  to_end = false 
)

Create an edge. If the given edge cannot be created, returns null. If the given edge already exists, returns the existing edge.

◆ create_edge() [4/5]

Edge * vg::VG::create_edge ( NodeSide  side1,
NodeSide  side2 
)

Make an edge connecting the given sides of nodes. If the given edge cannot be created, returns null. If the given edge already exists, returns the existing edge.

◆ create_edge() [5/5]

Edge * vg::VG::create_edge ( NodeTraversal  left,
NodeTraversal  right 
)

Make a left-to-right edge from the left NodeTraversal to the right one, respecting orientations. If the given edge cannot be created, returns null. If the given edge already exists, returns the existing edge.

◆ create_handle() [1/2]

handle_t vg::VG::create_handle ( const string &  sequence)
virtual

Create a new node with the given sequence and return the handle. The sequence may not be empty.

◆ create_handle() [2/2]

handle_t vg::VG::create_handle ( const string &  sequence,
const nid_t id 
)
virtual

Create a new node with the given id and sequence, then return the handle. The sequence may not be empty. The ID must be strictly greater than 0.

◆ create_node() [1/2]

Node * vg::VG::create_node ( const string &  seq)

Create a node. Use the VG class to generate ids.

◆ create_node() [2/2]

Node * vg::VG::create_node ( const string &  seq,
nid_t  id 
)

Create a node. Use a specified, nonzero node ID.

◆ create_path() [1/2]

Path vg::VG::create_path ( const list< NodeTraversal > &  nodes)

Create a path.

◆ create_path() [2/2]

Path vg::VG::create_path ( const vector< NodeTraversal > &  nodes)

Create a path.

◆ create_path_handle()

path_handle_t vg::VG::create_path_handle ( const string &  name,
bool  is_circular = false 
)
virtual

Create a path with the given name.

◆ dagify()

VG vg::VG::dagify ( uint32_t  expand_scc_steps,
unordered_map< nid_t, pair< nid_t, bool > > &  node_translation,
size_t  target_min_walk_length = 0,
size_t  component_length_max = 0 
)

Turn the graph into a dag by copying strongly connected components expand_scc_steps times and translating the edges in the component to flow through the copies in one direction. Assumes that all nodes in the graph are articulated on one consistent strand. Tolerates doubly-reversing edges in the input graph.

◆ decrement_node_ids()

void vg::VG::decrement_node_ids ( nid_t  decrement)

Subtract the given value from all the node IDs. Must not create a node with 0 or negative IDs. Invalidates the paths.

◆ deserialize()

void vg::VG::deserialize ( istream &  in)
virtual

Sets the contents of this graph to the contents of a serialized graph from an istream. The serialized graph must be from the same implementation of the HandleGraph interface as is calling deserialize(). Can only be called by an empty graph.

◆ destroy_edge() [1/4]

void vg::VG::destroy_edge ( const handle_t left,
const handle_t right 
)
virtual

Remove the edge connecting the given handles in the given order and orientations.

Implements handlegraph::DeletableHandleGraph.

◆ destroy_edge() [2/4]

void vg::VG::destroy_edge ( const NodeSide side1,
const NodeSide side2 
)

Destroy the edge between the given sides of nodes. These can be in either order.

◆ destroy_edge() [3/4]

void vg::VG::destroy_edge ( const pair< NodeSide, NodeSide > &  sides)

Destroy the edge between the given sides of nodes. This can take sides in any order.

◆ destroy_edge() [4/4]

void vg::VG::destroy_edge ( Edge edge)

Destroy the edge at the given pointer. This pointer must point to an edge owned by the graph.

◆ destroy_handle()

void vg::VG::destroy_handle ( const handle_t handle)
virtual

Remove the node belonging to the given handle and all of its edges. Destroys any paths in which the node participates. Invalidates the destroyed handle. May be called during serial for_each_handle iteration ONLY on the node being iterated. May NOT be called during parallel for_each_handle iteration. May NOT be called on the node from which edges are being followed during follow_edges. May NOT be called during iteration over paths, if it would destroy a path. May NOT be called during iteration along a path, if it would destroy that path.

Implements handlegraph::DeletableHandleGraph.

◆ destroy_node() [1/2]

void vg::VG::destroy_node ( nid_t  id)

Destroy the node with the given ID.

◆ destroy_node() [2/2]

void vg::VG::destroy_node ( Node node)

Destroy the node at the given pointer. This pointer must point to a Node owned by the graph.

◆ destroy_path()

void vg::VG::destroy_path ( const path_handle_t path)
virtual

Destroy the given path. Invalidates handles to the path and its node steps.

Implements handlegraph::MutablePathHandleGraph.

◆ dfs() [1/3]

void vg::VG::dfs ( const function< void(NodeTraversal)> &  node_begin_fn,
const function< void(NodeTraversal)> &  node_end_fn,
const function< bool(void)> &  break_fn 
)

Specialization of dfs for only handling nodes + break function.

◆ dfs() [2/3]

void vg::VG::dfs ( const function< void(NodeTraversal)> &  node_begin_fn,
const function< void(NodeTraversal)> &  node_end_fn,
const function< bool(void)> &  break_fn,
const function< void(Edge *)> &  edge_fn,
const function< void(Edge *)> &  tree_fn,
const function< void(Edge *)> &  edge_curr_fn,
const function< void(Edge *)> &  edge_cross_fn,
const vector< NodeTraversal > *  sources,
const unordered_set< NodeTraversal > *  sinks 
)

Do a DFS search of the bidirected graph. A bidirected DFS starts at some root node, and traverses first all the nodes found reading out the right of that node in their appropriate relative orientations (including the root), and then all the nodes found reading left out of that node in their appropriate orientations (including the root). If any unvisited nodes are left in other connected components, the process will repeat from one such node, until all nodes have been visited in each orientation.

Parameters
node_begin_fnCalled when node orientattion is first encountered.
node_end_fnCalled when node orientation goes out of scope.
break_fnCalled to check if we should stop the DFS.
edge_fnCalled when an edge is encountered.
tree_fnCalled when an edge forms part of the DFS spanning tree.
edge_curr_fnCalled when we meet an edge in the current tree component.
edge_cross_fnCalled when we meet an edge in an already-traversed tree component.
sourcesStart only at these node traversals.
sinksWhen hitting a sink, don't keep walking.

◆ dfs() [3/3]

void vg::VG::dfs ( const function< void(NodeTraversal)> &  node_begin_fn,
const function< void(NodeTraversal)> &  node_end_fn,
const vector< NodeTraversal > *  sources = NULL,
const unordered_set< NodeTraversal > *  sinks = NULL 
)

Specialization of dfs for only handling nodes.

◆ divide_handle()

vector< handle_t > vg::VG::divide_handle ( const handle_t handle,
const vector< size_t > &  offsets 
)
virtual

Split a handle's underlying node at the given offsets in the handle's orientation. Returns all of the handles to the parts. Other handles to the node being split may be invalidated. The split pieces stay in the same local forward orientation as the original node, but the returned handles come in the order and orientation appropriate for the handle passed in.

◆ divide_node() [1/2]

void vg::VG::divide_node ( Node node,
int  pos,
Node *&  left,
Node *&  right 
)

Divide a node at a given internal position. Inserts the new nodes in the correct paths, but can't update the ranks, so they need to be cleared and re-calculated by the caller.

◆ divide_node() [2/2]

void vg::VG::divide_node ( Node node,
vector< int > &  positions,
vector< Node * > &  parts 
)

Divide a node at a given internal position. This version works on a collection of internal positions, in linear time.

◆ divide_path()

void vg::VG::divide_path ( map< long, nid_t > &  path,
long  pos,
Node *&  left,
Node *&  right 
)

Divide a path at a position. Also invalidates stored rank information.

◆ edge_count()

size_t vg::VG::edge_count ( void  ) const

Count the number of edges in the graph.

◆ edges_end() [1/2]

vector< pair< nid_t, bool > > & vg::VG::edges_end ( nid_t  id)

Get nodes and backward flags following edges that attach to this node's end.

◆ edges_end() [2/2]

vector< pair< nid_t, bool > > & vg::VG::edges_end ( Node node)

Get nodes and backward flags following edges that attach to this node's end.

◆ edges_from()

vector< Edge * > vg::VG::edges_from ( Node node)

Get the edges from the specified node.

◆ edges_of()

vector< Edge * > vg::VG::edges_of ( Node node)

Get the edges of the specified node.

◆ edges_of_node()

void vg::VG::edges_of_node ( Node node,
vector< Edge * > &  edges 
)

Get the edges of the specified node, and add them to the given vector. Guaranteed to add each edge only once per call.

◆ edges_of_nodes()

void vg::VG::edges_of_nodes ( set< Node * > &  nodes,
set< Edge * > &  edges 
)

Get the edges of the specified set of nodes, and add them to the given set of edge pointers.

◆ edges_start() [1/2]

vector< pair< nid_t, bool > > & vg::VG::edges_start ( nid_t  id)

Get nodes and backward flags following edges that attach to this node's start.

◆ edges_start() [2/2]

vector< pair< nid_t, bool > > & vg::VG::edges_start ( Node node)

Get nodes and backward flags following edges that attach to this node's start.

◆ edges_to()

vector< Edge * > vg::VG::edges_to ( Node node)

Get the edges to the specified node.

◆ edit() [1/2]

void vg::VG::edit ( const string &  paths_to_add_path,
vector< Translation > *  out_translations = nullptr,
bool  save_paths = false,
const string &  out_gam_path = "",
bool  break_at_ends = false,
bool  remove_softclips = false 
)

Streaming version of above. Instead of reading a list of paths into memory all at once, a file stream is opened from the given path and used to go one-by-one. Instead of an option to updtate the in-memory list, an optional output path for the paths is used

todo: duplicate less code between the two versions.

◆ edit() [2/2]

void vg::VG::edit ( vector< Path > &  paths_to_add,
vector< Translation > *  out_translations = nullptr,
bool  save_paths = false,
bool  update_paths = false,
bool  break_at_ends = false 
)

Edit the graph to include all the sequence and edges added by the given paths. Can handle paths that visit nodes in any orientation. If out_translations is given, a vector of Translations will be written to it, one per node existing after the edit, describing how each new or conserved node is embedded in the old graph. Note that this method sorts the graph and rebuilds the path index, so it should not be called in a loop.

If update_paths is true, the paths will be modified to reflect their embedding in the modified graph. If save_paths is true, the paths as embedded in the graph will be added to the graph's set of paths. If break_at_ends is true (or save_paths is true), nodes will be broken at the ends of paths that start/end woth perfect matches, so the paths can be added to the vg graph's paths object.

◆ edit_fast()

vector< Translation > vg::VG::edit_fast ( const Path path,
set< NodeSide > &  dangling,
size_t  max_node_size = 1024 
)

Edit the graph to include all the sequences and edges added by the given path. Returns a vector of Translations, one per original-node fragment. Completely novel nodes are not mentioned, and nodes with no Translations are assumed to be carried through unchanged. Invalidates the rank-based Paths index. Does not sort the graph. Suitable for calling in a loop.

Can attach newly created nodes on the left of the path to the given set of dangling NodeSides, and populates the set at the end with the NodeSide corresponding to the end of the path. This mechanism allows edits that hit the end of a node to be attached to what comes before/after the node by the caller, as this function doesn't handle that.

◆ empty()

bool vg::VG::empty ( void  ) const

Is the graph empty?

◆ end_degree()

int vg::VG::end_degree ( Node node)

Get the number of edges attached to the end of a node.

◆ expand_context()

void vg::VG::expand_context ( VG g,
size_t  distance,
bool  add_paths = true,
bool  use_steps = true 
)

Expand the context of what's already in the given graph by the given distance, either in nodes or in bases. Pulls material from this graph.

◆ expand_context_by_length()

void vg::VG::expand_context_by_length ( VG g,
size_t  length,
bool  add_paths = true,
bool  reflect = false,
const set< NodeSide > &  barriers = set<NodeSide>() 
)

Expand the context of the given graph by the given number of bases. If reflect is true, bounce off the ends of nodes to get siblings of nodes you came from. Can take a set of NodeSides not to look out from, that act as barriers to context expansion. These barriers will have no edges attached to them in the final graph.

◆ expand_context_by_steps()

void vg::VG::expand_context_by_steps ( VG g,
size_t  steps,
bool  add_paths = true 
)

Expand the context of the given graph by the given number of steps.

◆ expand_path() [1/2]

void vg::VG::expand_path ( const list< NodeTraversal > &  path,
vector< NodeTraversal > &  expanded 
)

Expand a path. TODO: what does that mean?

◆ expand_path() [2/2]

void vg::VG::expand_path ( list< NodeTraversal > &  path,
vector< list< NodeTraversal >::iterator > &  expanded 
)

Expand a path. TODO: what does that mean? These versions handle paths in which nodes can be traversed multiple times. Unfortunately since we're throwing non-const iterators around, we can't take the input path as const.

◆ extend() [1/2]

void vg::VG::extend ( const Graph graph,
bool  warn_on_duplicates = false 
)

This version does not sort path mappings by rank. In order to preserve paths, call Paths::sort_by_mapping_rank() and Paths::rebuild_mapping_aux() after you are done adding in graphs to this graph.

◆ extend() [2/2]

void vg::VG::extend ( const VG g,
bool  warn_on_duplicates = false 
)

Iteratively add when nodes and edges are novel. Good when there are very many overlaps. TODO: If you are using this with warn on duplicates on, and you know there shouldn't be any duplicates, maybe you should use merge instead. This version sorts paths on rank after adding in the path mappings from the other graph.

◆ find_node_by_name_or_add_new()

Node * vg::VG::find_node_by_name_or_add_new ( string  name)

Find a node with the given name, or create a new one if none is found.

◆ flip()

handle_t vg::VG::flip ( const handle_t handle) const
virtual

Invert the orientation of a handle (potentially without getting its ID)

Implements handlegraph::HandleGraph.

◆ flip_doubly_reversed_edges()

void vg::VG::flip_doubly_reversed_edges ( void  )

Convert edges that are both from_start and to_end to "regular" ones from end to start.

◆ follow_edges_impl()

bool vg::VG::follow_edges_impl ( const handle_t handle,
bool  go_left,
const function< bool(const handle_t &)> &  iteratee 
) const
virtual

Loop over all the handles to next/previous (right/left) nodes. Passes them to a callback which returns false to stop iterating and true to continue. Returns true if we finished and false if we stopped early.

◆ for_each_connected_node()

void vg::VG::for_each_connected_node ( Node node,
function< void(Node *)>  lambda 
)

Go through all the nodes in the same connected component as the given node. Ignores relative orientation.

◆ for_each_edge() [1/2]

void vg::VG::for_each_edge ( function< void(const Edge *)>  lambda) const

◆ for_each_edge() [2/2]

void vg::VG::for_each_edge ( function< void(Edge *)>  lambda)

Run the given function for each edge.

◆ for_each_edge_parallel()

void vg::VG::for_each_edge_parallel ( function< void(Edge *)>  lambda)

Run the given function for each edge, in parallel.

◆ for_each_handle_impl()

bool vg::VG::for_each_handle_impl ( const function< bool(const handle_t &)> &  iteratee,
bool  parallel = false 
) const
virtual

Loop over all the nodes in the graph in their local forward orientations, in their internal stored order. Stop if the iteratee returns false.

◆ for_each_node() [1/2]

void vg::VG::for_each_node ( function< void(const Node *)>  lambda) const

◆ for_each_node() [2/2]

void vg::VG::for_each_node ( function< void(Node *)>  lambda)

Run the given function on every node.

◆ for_each_node_parallel()

void vg::VG::for_each_node_parallel ( function< void(Node *)>  lambda)

Run the given function on every node in parallel.

◆ for_each_path_handle_impl()

bool vg::VG::for_each_path_handle_impl ( const function< bool(const path_handle_t &)> &  iteratee) const
virtual

Execute a function on each path in the graph.

◆ for_each_step_on_handle_impl()

bool vg::VG::for_each_step_on_handle_impl ( const handle_t handle,
const function< bool(const step_handle_t &)> &  iteratee 
) const
virtual

Loop over the steps of a handle in paths.

◆ from_istream()

void vg::VG::from_istream ( istream &  in,
bool  showp = false,
bool  warn_on_duplicates = true 
)

◆ from_turtle()

void vg::VG::from_turtle ( string  filename,
string  baseuri,
bool  showp = false 
)

Build a graph from a Turtle stream.

Add the paths that we parsed into the vg object

◆ get_base()

char vg::VG::get_base ( const handle_t handle,
size_t  index 
) const
virtual

Returns one base of a handle's sequence, in the orientation of the handle.

Reimplemented from handlegraph::HandleGraph.

◆ get_degree()

size_t vg::VG::get_degree ( const handle_t handle,
bool  go_left 
) const
virtual

Efficiently get the number of edges attached to one side of a handle. Uses the VG graph's internal degree index.

Reimplemented from handlegraph::HandleGraph.

◆ get_edge() [1/3]

Edge * vg::VG::get_edge ( const NodeSide side1,
const NodeSide side2 
)

Get a pointer to the specified edge. This can take sides in any order.

◆ get_edge() [2/3]

Edge * vg::VG::get_edge ( const NodeTraversal left,
const NodeTraversal right 
)

Get the edge connecting the given oriented nodes in the given order.

◆ get_edge() [3/3]

Edge * vg::VG::get_edge ( const pair< NodeSide, NodeSide > &  sides)

Get a pointer to the specified edge. This can take sides in any order.

◆ get_edge_count()

size_t vg::VG::get_edge_count ( ) const
virtual

Return the total number of edges in the graph.

Reimplemented from handlegraph::HandleGraph.

◆ get_handle()

handle_t vg::VG::get_handle ( const nid_t node_id,
bool  is_reverse = false 
) const
virtual

Look up the handle for the node with the given ID in the given orientation.

Implements handlegraph::HandleGraph.

◆ get_handle_of_step()

handle_t vg::VG::get_handle_of_step ( const step_handle_t step_handle) const
virtual

Get a node handle (node ID and orientation) from a handle to an step on a path.

Implements handlegraph::PathHandleGraph.

◆ get_id()

nid_t vg::VG::get_id ( const handle_t handle) const
virtual

Get the ID from a handle.

Implements handlegraph::HandleGraph.

◆ get_is_circular()

bool vg::VG::get_is_circular ( const path_handle_t path_handle) const
virtual

Look up whether a path is circular.

Implements handlegraph::PathHandleGraph.

◆ get_is_reverse()

bool vg::VG::get_is_reverse ( const handle_t handle) const
virtual

Get the orientation of a handle.

Implements handlegraph::HandleGraph.

◆ get_length()

size_t vg::VG::get_length ( const handle_t handle) const
virtual

Get the length of a node.

Implements handlegraph::HandleGraph.

◆ get_next_step()

step_handle_t vg::VG::get_next_step ( const step_handle_t step_handle) const
virtual

Returns a handle to the next step on the path. If the given step is the final step of a non-circular path, returns the past-the-last step that is also returned by path_end. In a circular path, the "last" step will loop around to the "first" (i.e. the one returned by path_begin). Note: to iterate over each step one time, even in a circular path, consider for_each_step_in_path.

Implements handlegraph::PathHandleGraph.

◆ get_node() [1/2]

Node * vg::VG::get_node ( nid_t  id)

Find a particular node.

◆ get_node() [2/2]

const Node * vg::VG::get_node ( nid_t  id) const

◆ get_node_at_nucleotide()

nid_t vg::VG::get_node_at_nucleotide ( string  pathname,
int  nuc 
)

Takes in a pathname and the nucleotide position (like from a vcf) and returns the node id which contains that position.

◆ get_node_count()

size_t vg::VG::get_node_count ( ) const
virtual

Return the number of nodes in the graph.

Implements handlegraph::HandleGraph.

◆ get_node_nid_to_variant()

map< nid_t, vcflib::Variant > vg::VG::get_node_nid_to_variant ( vcflib::VariantCallFile  vfile)

Takes in a VCF file and returns a map [node] = vcflib::variant. Unfortunately this is specific to a given graph and VCF.

It will need to throw warnings if the node or variant is not in the graph.

This is useful for VCF masking:

if map.find(node) then mask variant

It's also useful for calling known variants

for m in alignment.mappings:
   node = m.Pos.nodeID
   if node in node_to_vcf:
       return (alignment supports variant)

It would be nice if this also supported edges (e.g. for inversions/transversions/breakpoints?).

◆ get_path_count()

size_t vg::VG::get_path_count ( ) const
virtual

Returns the number of paths stored in the graph.

Implements handlegraph::PathHandleGraph.

◆ get_path_edges()

set< Edge * > vg::VG::get_path_edges ( void  )

Get all of the edges that are on any path.

◆ get_path_handle()

path_handle_t vg::VG::get_path_handle ( const string &  path_name) const
virtual

Look up the path handle for the given path name.

◆ get_path_handle_of_step()

path_handle_t vg::VG::get_path_handle_of_step ( const step_handle_t step_handle) const
virtual

Returns a handle to the path that an step is on.

Implements handlegraph::PathHandleGraph.

◆ get_path_name()

string vg::VG::get_path_name ( const path_handle_t path_handle) const
virtual

Look up the name of a path from a handle to it.

Implements handlegraph::PathHandleGraph.

◆ get_previous_step()

step_handle_t vg::VG::get_previous_step ( const step_handle_t step_handle) const
virtual

Returns a handle to the previous step on the path. If the given step is the first step of a non-circular path, this method has undefined behavior. In a circular path, it will loop around from the "first" step (i.e. the one returned by path_begin) to the "last" step. Note: to iterate over each step one time, even in a circular path, consider for_each_step_in_path.

Implements handlegraph::PathHandleGraph.

◆ get_sequence()

string vg::VG::get_sequence ( const handle_t handle) const
virtual

Get the sequence of a node, presented in the handle's local forward orientation.

Implements handlegraph::HandleGraph.

◆ get_step_count()

size_t vg::VG::get_step_count ( const path_handle_t path_handle) const
virtual

Returns the number of node steps in the path.

Implements handlegraph::PathHandleGraph.

◆ get_subsequence()

string vg::VG::get_subsequence ( const handle_t handle,
size_t  index,
size_t  size 
) const
virtual

Returns a substring of a handle's sequence, in the orientation of the handle. If the indicated substring would extend beyond the end of the handle's sequence, the return value is truncated to the sequence's end.

Reimplemented from handlegraph::HandleGraph.

◆ has_edge() [1/5]

bool vg::VG::has_edge ( const Edge edge) const

Determine if the graph has an edge. This can take sides in any order.

◆ has_edge() [2/5]

bool vg::VG::has_edge ( const handle_t left,
const handle_t right 
) const
virtual

Efficiently check for the existence of an edge using VG graph's internal index of node sides.

Reimplemented from handlegraph::HandleGraph.

◆ has_edge() [3/5]

bool vg::VG::has_edge ( const NodeSide side1,
const NodeSide side2 
) const

Get the edge between the given node sides, which can be in either order.

◆ has_edge() [4/5]

bool vg::VG::has_edge ( const pair< NodeSide, NodeSide > &  sides) const

Determine if the graph has an edge. This can take sides in any order.

◆ has_edge() [5/5]

bool vg::VG::has_edge ( Edge edge) const

Determine if the graph has an edge. This can take sides in any order.

◆ has_inverting_edge()

bool vg::VG::has_inverting_edge ( Node n)

Determine if the graph has an inverting edge on the given node.

◆ has_inverting_edge_from()

bool vg::VG::has_inverting_edge_from ( Node n)

Determine if the graph has an inverting edge from the given node.

◆ has_inverting_edge_to()

bool vg::VG::has_inverting_edge_to ( Node n)

Determine if the graph has an inverting edge to the given node.

◆ has_inverting_edges()

bool vg::VG::has_inverting_edges ( void  )

Determine if the graph has inversions.

◆ has_next_step()

bool vg::VG::has_next_step ( const step_handle_t step_handle) const
virtual

Returns true if the step is not the last step in a non-circular path.

Implements handlegraph::PathHandleGraph.

◆ has_node() [1/3]

bool vg::VG::has_node ( const Node node) const

Determine if the graph contains the given node.

◆ has_node() [2/3]

bool vg::VG::has_node ( const Node node) const

Determine if the graph contains the given node.

◆ has_node() [3/3]

bool vg::VG::has_node ( nid_t  id) const
virtual

Determine if the graph has a node with the given ID.

Implements handlegraph::HandleGraph.

◆ has_path()

bool vg::VG::has_path ( const string &  path_name) const
virtual

Determine if a path name exists and is legal to get a path handle for.

◆ has_previous_step()

bool vg::VG::has_previous_step ( const step_handle_t step_handle) const
virtual

Returns true if the step is not the first step in a non-circular path.

Implements handlegraph::PathHandleGraph.

◆ hash()

const string vg::VG::hash ( void  )

Generate a digest of the serialized graph.

◆ head_nodes() [1/2]

void vg::VG::head_nodes ( vector< Node * > &  nodes)

Get the head nodes (nodes with edges only to their right sides). These are required to be oriented forward.

◆ head_nodes() [2/2]

vector< Node * > vg::VG::head_nodes ( void  )

Get the head nodes (nodes with edges only to their right sides). These are required to be oriented forward.

◆ id_sort()

void vg::VG::id_sort ( )

Order the backing graph data structure by node ID.

◆ identity_translation()

void vg::VG::identity_translation ( unordered_map< nid_t, pair< nid_t, bool >> &  node_translation)

Record the translation of this graph into itself in the provided map.

◆ include()

void vg::VG::include ( const Path path)

Edit the graph to include the path.

◆ increment_node_ids()

void vg::VG::increment_node_ids ( nid_t  increment)
virtual

Add the given value to all node IDs. Preserves the paths.

Reimplemented from handlegraph::MutableHandleGraph.

◆ index_edge_by_node_sides()

void vg::VG::index_edge_by_node_sides ( Edge edge)

Add an edge to the node side indexes. Doesn't touch the index of edges by node pairs or the graph; those must be updated seperately.

◆ init()

void vg::VG::init ( void  )
private

setup, ensures that gssw == NULL on startup

◆ is_ancestor_next() [1/2]

bool vg::VG::is_ancestor_next ( nid_t  node_id,
nid_t  candidate_id 
)

Determine if the node is a next ancestor of this one.

◆ is_ancestor_next() [2/2]

bool vg::VG::is_ancestor_next ( nid_t  node_id,
nid_t  candidate_id,
set< nid_t > &  seen,
size_t  steps = 64 
)

Determine if the node is a next ancestor of this one by trying to find it in a given number of steps.

◆ is_ancestor_prev() [1/2]

bool vg::VG::is_ancestor_prev ( nid_t  node_id,
nid_t  candidate_id 
)

Determine if the node is a prev ancestor of this one.

◆ is_ancestor_prev() [2/2]

bool vg::VG::is_ancestor_prev ( nid_t  node_id,
nid_t  candidate_id,
set< nid_t > &  seen,
size_t  steps = 64 
)

Determine if the node is a prev ancestor of this one by trying to find it in a given number of steps.

◆ is_head_node() [1/2]

bool vg::VG::is_head_node ( nid_t  id)

Determine if a node is a head node.

◆ is_head_node() [2/2]

bool vg::VG::is_head_node ( Node node)

Determine if a node is a head node.

◆ is_self_looping()

bool vg::VG::is_self_looping ( Node node)
private

Does the specified node have any self-loops?

◆ is_tail_node() [1/2]

bool vg::VG::is_tail_node ( nid_t  id)

Determine if a node is a tail node.

◆ is_tail_node() [2/2]

bool vg::VG::is_tail_node ( Node node)

Determine if a node is a tail node.

◆ is_valid()

bool vg::VG::is_valid ( bool  check_nodes = true,
bool  check_edges = true,
bool  check_paths = true,
bool  check_orphans = true 
)

Determine if the graph is valid or not, according to the specified criteria.

◆ join_heads() [1/2]

void vg::VG::join_heads ( Node node,
bool  from_start = false 
)

Join head nodes of graph to specified node. Optionally from the start/to the end of the new node.

◆ join_heads() [2/2]

Node * vg::VG::join_heads ( void  )

Join head nodes of graph to common null node, creating a new single head.

◆ join_tails()

void vg::VG::join_tails ( Node node,
bool  to_end = false 
)

Join tail nodes of graph to specified node. Optionally from the start/to the end of the new node.

◆ keep_path()

void vg::VG::keep_path ( const string &  path_name)

◆ keep_paths()

void vg::VG::keep_paths ( const set< string > &  path_names,
set< string > &  kept_names 
)

Keep paths in the given set of path names. Populates kept_names with the names of the paths it actually found to keep. The paths specified may not overlap. Removes all nodes and edges not used by one of the specified paths.

◆ left_degree()

int vg::VG::left_degree ( NodeTraversal  node)

Get the number of edges attached to the left side of a NodeTraversal.

◆ length()

size_t vg::VG::length ( void  )

Total sequence length.

◆ likelihoods()

void vg::VG::likelihoods ( vector< Alignment > &  alignments,
vector< Path > &  paths,
vector< long double > &  likelihoods 
)

◆ mapping_is_total_match()

bool vg::VG::mapping_is_total_match ( const Mapping m)

Return true if the mapping completely covers the node it maps to and is a perfect match.

◆ max_node_id()

nid_t vg::VG::max_node_id ( ) const
virtual

Get the maximum node ID used in the graph, if any are used.

Implements handlegraph::HandleGraph.

◆ merge() [1/2]

void vg::VG::merge ( Graph g)

Literally merge protobufs.

◆ merge() [2/2]

void vg::VG::merge ( VG g)

Literally merge protobufs.

◆ merge_nodes()

Node* vg::VG::merge_nodes ( const list< Node * > &  nodes)
private

Use the orientation of the first node as the basis.

◆ merge_union()

void vg::VG::merge_union ( VG g)

Merge protobufs after removing overlaps. Good when there aren't many overlaps.

◆ min_node_id()

nid_t vg::VG::min_node_id ( ) const
virtual

Get the minimum node ID used in the graph, if any are used.

Implements handlegraph::HandleGraph.

◆ node_count()

size_t vg::VG::node_count ( void  ) const

Return the number of nodes in the graph.

◆ node_count_next()

int vg::VG::node_count_next ( NodeTraversal  n)

Count the nodes attached to the right side of the given NodeTraversal.

◆ node_count_prev()

int vg::VG::node_count_prev ( NodeTraversal  n)

Count the nodes attached to the left side of the given NodeTraversal.

◆ node_rank() [1/2]

int vg::VG::node_rank ( nid_t  id)

Get the rank of the node in the protobuf array that backs the graph.

◆ node_rank() [2/2]

int vg::VG::node_rank ( Node node)

Get the rank of the node in the protobuf array that backs the graph.

◆ node_starts_in_path() [1/2]

void vg::VG::node_starts_in_path ( const list< NodeTraversal > &  path,
map< Node *, int > &  node_start 
)

Fill in the node_start map with the first index along the path at which each node appears. Caller is responsible for dealing with orientations.

◆ node_starts_in_path() [2/2]

void vg::VG::node_starts_in_path ( list< NodeTraversal > &  path,
map< NodeTraversal *, int > &  node_start 
)

Find node starts in a path. TODO: what does that mean? To get the starts out of the map this produces, you need to dereference the iterator and then get the address of the NodeTraversal (stored in the list) that you are talking about.

◆ nodes_next() [1/2]

vector< NodeTraversal > vg::VG::nodes_next ( NodeTraversal  n)

Get the nodes attached to the right side of the given NodeTraversal, in their proper orientations.

◆ nodes_next() [2/2]

void vg::VG::nodes_next ( NodeTraversal  n,
vector< NodeTraversal > &  nodes 
)

Get the nodes attached to the right side of the given NodeTraversal, in their proper orientations.

◆ nodes_prev() [1/2]

vector< NodeTraversal > vg::VG::nodes_prev ( NodeTraversal  n)

Get the nodes attached to the left side of the given NodeTraversal, in their proper orientations.

◆ nodes_prev() [2/2]

void vg::VG::nodes_prev ( NodeTraversal  n,
vector< NodeTraversal > &  nodes 
)

Get the nodes attached to the left side of the given NodeTraversal, in their proper orientations.

◆ nonoverlapping_node_context_without_paths()

void vg::VG::nonoverlapping_node_context_without_paths ( Node node,
VG g 
)

Get the subgraph of a node and all the edges it is responsible for (where it has the minimal ID) and add it into the given VG.

◆ operator=() [1/2]

VG & vg::VG::operator= ( const VG other)

Copy assignment operator.

◆ operator=() [2/2]

VG & vg::VG::operator= ( VG &&  other)
noexcept

Move assignment operator.

◆ optimize()

void vg::VG::optimize ( bool  allow_id_reassignment = true)
virtual

Adjust the representation of the graph in memory to improve performance. Optionally, allow the node IDs to be reassigned to further improve performance. Note: Ideally, this method is called one time once there is expected to be few graph modifications in the future.

Implements handlegraph::MutableHandleGraph.

◆ overlay_node_translations()

unordered_map< nid_t, pair< nid_t, bool > > vg::VG::overlay_node_translations ( const unordered_map< nid_t, pair< nid_t, bool > > &  over,
const unordered_map< nid_t, pair< nid_t, bool > > &  under 
)

Assume two node translations, the over is based on the under; merge them.

◆ path_back()

step_handle_t vg::VG::path_back ( const path_handle_t path_handle) const
virtual

Get a handle to the last step, which will be an arbitrary step in a circular path that we consider "last" based on our construction of the path. If the path is empty then the implementation must return the same value as path_front_end().

Implements handlegraph::PathHandleGraph.

◆ path_begin()

step_handle_t vg::VG::path_begin ( const path_handle_t path_handle) const
virtual

Get a handle to the first step, or in a circular path to an arbitrary step considered "first". If the path is empty, returns the past-the-last step returned by path_end.

Implements handlegraph::PathHandleGraph.

◆ path_edge_count()

int vg::VG::path_edge_count ( list< NodeTraversal > &  path,
int32_t  offset,
int  path_length 
)

Path stats. Starting from offset in the first node, how many edges do we cross? path must be nonempty and longer than the given length. offset is interpreted as relative to the first node in its on-path orientation, and is inclusive.

◆ path_end()

step_handle_t vg::VG::path_end ( const path_handle_t path_handle) const
virtual

Get a handle to a fictitious position past the end of a path. This position is return by get_next_step for the final step in a path in a non-circular path. Note that get_next_step will NEVER return this value for a circular path.

Implements handlegraph::PathHandleGraph.

◆ path_end_node_offset()

int vg::VG::path_end_node_offset ( list< NodeTraversal > &  path,
int32_t  offset,
int  path_length 
)

Determine the offset in its last node at which the path starting at this offset in its first node ends. path must be nonempty and longer than the given length. offset is interpreted as relative to the first node in its on-path orientation, and is inclusive. Returned offset is remaining unused length in the last node touched.

◆ path_front_end()

step_handle_t vg::VG::path_front_end ( const path_handle_t path_handle) const
virtual

Get a handle to a fictitious position before the beginning of a path. This position is return by get_previous_step for the first step in a path in a non-circular path. Note: get_previous_step will NEVER return this value for a circular path.

Implements handlegraph::PathHandleGraph.

◆ path_identity()

double vg::VG::path_identity ( const Path path1,
const Path path2 
)

Return percent identity between two paths (# matches / (#matches + #mismatches)). Note: uses ssw aligner, so will only work on small paths.

◆ path_sequence()

const string vg::VG::path_sequence ( const Path path)

Return sequence string of path.

◆ paths_as_alignments()

const vector< Alignment > vg::VG::paths_as_alignments ( void  )

Convert the stored paths in this graph to alignments.

◆ paths_between() [1/2]

void vg::VG::paths_between ( nid_t  from,
nid_t  to,
vector< Path > &  paths 
)

◆ paths_between() [2/2]

void vg::VG::paths_between ( Node from,
Node to,
vector< Path > &  paths 
)

◆ prepend_step()

step_handle_t vg::VG::prepend_step ( const path_handle_t path,
const handle_t to_prepend 
)
virtual

Append a visit to a node to the given path.

Implements handlegraph::MutablePathHandleGraph.

◆ print_edges()

void vg::VG::print_edges ( void  )

◆ random_read()

Alignment vg::VG::random_read ( size_t  read_len,
mt19937 &  rng,
nid_t  min_id,
nid_t  max_id,
bool  either_strand 
)

Generate random reads. Note that even if either_strand is false, having backward nodes in the graph will result in some reads from the global reverse strand.

◆ reassign_node_ids()

void vg::VG::reassign_node_ids ( const std::function< nid_t(const nid_t &)> &  get_new_id)
virtual

Reassign all node IDs as specified by the old->new mapping function.

Implements handlegraph::MutableHandleGraph.

◆ rebuild_edge_indexes()

void vg::VG::rebuild_edge_indexes ( void  )

◆ rebuild_indexes()

void vg::VG::rebuild_indexes ( void  )

◆ remove_duplicated_in()

void vg::VG::remove_duplicated_in ( VG g)

Helper to merge_union.

◆ remove_duplicates()

void vg::VG::remove_duplicates ( void  )

Remove duplicated nodes and edges.

◆ remove_inverting_edges()

void vg::VG::remove_inverting_edges ( void  )

Remove edges representing an inversion and edges on the reverse complement.

◆ remove_node_forwarding_edges()

void vg::VG::remove_node_forwarding_edges ( Node node)

Remove a node but connect all of its predecessor and successor nodes with new edges.

◆ remove_non_path()

void vg::VG::remove_non_path ( void  )

Remove pieces of the graph which are not part of any path.

◆ remove_null_nodes()

void vg::VG::remove_null_nodes ( void  )

Remove nodes with no sequence. These are created in some cases during the process of graph construction.

◆ remove_null_nodes_forwarding_edges()

void vg::VG::remove_null_nodes_forwarding_edges ( void  )

Remove null nodes but connect predecessors and successors, preserving structure.

◆ remove_orphan_edges()

void vg::VG::remove_orphan_edges ( void  )

Remove edges for which one of the nodes is not present.

◆ remove_path()

void vg::VG::remove_path ( void  )

Remove pieces of the graph which are part of some path.

◆ resize_indexes()

void vg::VG::resize_indexes ( void  )

◆ reverse_complement_graph()

VG vg::VG::reverse_complement_graph ( unordered_map< nid_t, pair< nid_t, bool >> &  node_translation)

Create the reverse complemented graph with topology preserved. Record translation in provided map.

◆ rewrite_segment()

pair< step_handle_t, step_handle_t > vg::VG::rewrite_segment ( const step_handle_t segment_begin,
const step_handle_t segment_end,
const vector< handle_t > &  new_segment 
)
virtual

Delete a segment of a path and rewrite it as some other sequence of steps. Returns a pair of step_handle_t's that indicate the range of the new segment in the path.

◆ right_degree()

int vg::VG::right_degree ( NodeTraversal  node)

Get the number of edges attached to the right side of a NodeTraversal.

◆ same_context()

bool vg::VG::same_context ( nid_t  id1,
nid_t  id2 
)

Use sides_from an sides_to to determine if both nodes have the same context.

◆ serialize()

void vg::VG::serialize ( ostream &  out) const
virtual

Write the contents of this graph to an ostream.

◆ serialize_to_emitter()

void vg::VG::serialize_to_emitter ( vg::io::ProtobufEmitter< Graph > &  emitter,
nid_t  chunk_size = 1000 
)

Write chunked graphs to a ProtobufEmitter that will write them to a stream. Use when combining multiple VG objects in a stream. Graph will be serialized in internal storage order.

◆ serialize_to_file()

void vg::VG::serialize_to_file ( const string &  file_name,
nid_t  chunk_size = 1000 
)

Write the graph to a file, with an EOF marker. Graph will be serialized in internal storage order.

◆ serialize_to_function()

void vg::VG::serialize_to_function ( const function< void(Graph &)> &  emit,
nid_t  chunk_size = 1000 
)

Send chunked graphs to a function that will write them somewhere. Used to internally implement saving to many destinations. Graph will be serialized in internal storage order. This is NOT const because it synchronizes path ranks before saving! We allow the emitted Graph to move.

◆ serialize_to_ostream()

void vg::VG::serialize_to_ostream ( ostream &  out,
nid_t  chunk_size = 1000 
)

Write to a stream in chunked graphs. Adds an EOF marker. Use when this VG will be the only thing in the stream. Graph will be serialized in internal storage order.

◆ set_circularity()

void vg::VG::set_circularity ( const path_handle_t path,
bool  circular 
)
virtual

Make a path circular or non-circular. If the path is becoming circular, the last step is joined to the first step. If the path is becoming linear, the step considered "last" is unjoined from the step considered "first" according to the method path_begin.

Implements handlegraph::MutablePathHandleGraph.

◆ set_edge()

void vg::VG::set_edge ( Edge edge)

Set the edge indexes through this function. Picks up the sides being connected by the edge automatically, and silently drops the edge if they are already connected.

◆ set_id_increment()

void vg::VG::set_id_increment ( const nid_t min_id)
virtual

No-op function (required by MutableHandleGraph interface)

Implements handlegraph::MutableHandleGraph.

◆ sides_context()

set< pair< NodeSide, bool > > vg::VG::sides_context ( nid_t  node_id)

Get all sides connecting to this node.

◆ sides_from() [1/2]

set< NodeSide > vg::VG::sides_from ( nid_t  id)

Get the sides from both sides of the node.

◆ sides_from() [2/2]

set< NodeSide > vg::VG::sides_from ( NodeSide  side)

Get the sides on the other side of edges from this side of the node.

◆ sides_of()

set< NodeSide > vg::VG::sides_of ( NodeSide  side)

Union of sides_to and sides_from.

◆ sides_to() [1/2]

set< NodeSide > vg::VG::sides_to ( nid_t  id)

Get the sides to both sides of the node.

◆ sides_to() [2/2]

set< NodeSide > vg::VG::sides_to ( NodeSide  side)

Get the sides on the other side of edges to this side of the node.

◆ size()

size_t vg::VG::size ( void  )

Number of nodes.

◆ sort()

void vg::VG::sort ( )

Topologically sort the graph, and then apply that sort to re- order the nodes in the backing data structure. The sort is guaranteed to be stable. This sort is well-defined on graphs that are not DAGs, but instead of finding a topological sort it does a heuristic sort to minimize a feedback arc set.

◆ start_degree()

int vg::VG::start_degree ( Node node)

Get the number of edges attached to the start of a node.

◆ swap_handles()

void vg::VG::swap_handles ( const handle_t a,
const handle_t b 
)
virtual

Swap the nodes corresponding to the given handles, in the ordering used by for_each_handle when looping over the graph. Other handles to the nodes being swapped must not be invalidated.

◆ swap_node_id() [1/2]

void vg::VG::swap_node_id ( nid_t  node_id,
nid_t  new_id 
)

Change the ID of the node with the first id to the second, new ID not used by any node. Invalidates any paths containing the node, since they are not updated.

◆ swap_node_id() [2/2]

void vg::VG::swap_node_id ( Node node,
nid_t  new_id 
)

Change the ID of the given node to the second, new ID not used by any node. Invalidates the paths. Invalidates any paths containing the node, since they are not updated.

◆ swap_nodes()

void vg::VG::swap_nodes ( Node a,
Node b 
)

Swap the given nodes. TODO: what does that mean?

◆ sync_paths()

void vg::VG::sync_paths ( void  )

Synchronize in-memory indexes and protobuf graph.

◆ tail_nodes() [1/2]

void vg::VG::tail_nodes ( vector< Node * > &  nodes)

Get the tail nodes (nodes with edges only to their left sides). These are required to be oriented forward.

◆ tail_nodes() [2/2]

vector< Node * > vg::VG::tail_nodes ( void  )

Get the tail nodes (nodes with edges only to their left sides). These are required to be oriented forward.

◆ to_dot()

void vg::VG::to_dot ( ostream &  out,
vector< Alignment alignments = {},
vector< Locus loci = {},
bool  show_paths = false,
bool  walk_paths = false,
bool  annotate_paths = false,
bool  show_mappings = false,
bool  simple_mode = false,
bool  noseq_mode = false,
bool  invert_edge_ports = false,
bool  color_variants = false,
bool  ultrabubble_labeling = false,
bool  skip_missing_nodes = false,
bool  ascii_labels = false,
int  random_seed = 0 
)

Convert the graph to Dot format.

◆ to_turtle()

void vg::VG::to_turtle ( ostream &  out,
const string &  rdf_base_uri,
bool  precompress 
)

Convert the graph to Turtle format.

◆ trav_sequence()

string vg::VG::trav_sequence ( const NodeTraversal trav)

Get the sequence of a NodeTraversal.

◆ travs_from()

set< NodeTraversal > vg::VG::travs_from ( NodeTraversal  node)

Get traversals after this node on the same strand. Same as nodes_next but using set.

◆ travs_of()

set< NodeTraversal > vg::VG::travs_of ( NodeTraversal  node)

Get traversals either before or after this node on the same strand.

◆ travs_to()

set< NodeTraversal > vg::VG::travs_to ( NodeTraversal  node)

Get traversals before this node on the same strand. Same as nodes_prev but using set.

◆ unfold()

VG vg::VG::unfold ( uint32_t  max_length,
unordered_map< nid_t, pair< nid_t, bool > > &  node_translation 
)

Ensure that all traversals up to max_length are represented as a path on one strand or the other without taking an inverting edge. All inverting edges are converted to non-inverting edges to reverse complement nodes. If no inverting edges are present, the strandedness of all nodes is the same as the input graph. If inverting edges are present, node strandedness is arbitrary.

◆ unindex_edge_by_node_sides() [1/2]

void vg::VG::unindex_edge_by_node_sides ( const NodeSide side1,
const NodeSide side2 
)

Remove an edge from the node side indexes, so it doesn't show up when you ask for the edges connected to the side of a node. Makes the edge untraversable until the indexes are rebuilt.

◆ unindex_edge_by_node_sides() [2/2]

void vg::VG::unindex_edge_by_node_sides ( Edge edge)

Remove an edge from the node side indexes, so it doesn't show up when you ask for the edges connected to the side of a node. Makes the edge untraversable until the indexes are rebuilt.

◆ wrap_with_null_nodes()

void vg::VG::wrap_with_null_nodes ( void  )

Add singular head and tail null nodes to graph.

Member Data Documentation

◆ current_id

nid_t vg::VG::current_id

Current id for Node to be added next.

◆ edge_by_sides

pair_hash_map<pair<NodeSide, NodeSide>, Edge*> vg::VG::edge_by_sides

Edges by sides of Nodes they connect. Since duplicate edges are not permitted, two edges cannot connect the same pair of node sides. Each edge is indexed here with the smaller NodeSide first. The actual node order is recorded in the Edge object.

◆ edge_index

hash_map<Edge*, int> vg::VG::edge_index

◆ edges_on_end

hash_map<nid_t, vector<pair<nid_t, bool> > > vg::VG::edges_on_end

Stores the destinations and backward flags for edges attached to the ends of nodes (whether that node is "from" or "to").

◆ edges_on_start

hash_map<nid_t, vector<pair<nid_t, bool> > > vg::VG::edges_on_start

Stores the destinations and backward flags for edges attached to the starts of nodes (whether that node is "from" or "to").

◆ empty_edge_ends

vector<pair<nid_t, bool> > vg::VG::empty_edge_ends
private

Placeholder for functions that sometimes need to be passed an empty vector.

◆ empty_ids

vector<nid_t> vg::VG::empty_ids
private

Placeholder for functions that sometimes need to be passed an empty vector.

◆ graph

Graph vg::VG::graph

Protobuf-based representation.

◆ name

string vg::VG::name

Name of the graph.

◆ node_by_id

hash_map<nid_t, Node*> vg::VG::node_by_id

Nodes by id.

◆ node_index

hash_map<Node*, int> vg::VG::node_index

nodes by position in nodes repeated field. this is critical to allow fast deletion of nodes

◆ paths

Paths vg::VG::paths

Manages paths of the graph. Initialized by setting paths._paths = graph.paths.

◆ variant_to_traversal

map<string, SnarlTraversal> vg::VG::variant_to_traversal

◆ warned_about_rewrites

bool vg::VG::warned_about_rewrites = false
private

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