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

#include <xg.hpp>

Inheritance diagram for xg::XG:
handlegraph::PathPositionHandleGraph handlegraph::SerializableHandleGraph handlegraph::VectorizableHandleGraph handlegraph::PathHandleGraph handlegraph::Serializable handlegraph::RankedHandleGraph handlegraph::HandleGraph handlegraph::PathMetadata handlegraph::HandleGraph

Public Member Functions

 XG (void)=default
 
 ~XG (void)
 
 XG (const XG &other)=delete
 
 XG (XG &&other)=delete
 
XGoperator= (const XG &other)=delete
 
XGoperator= (XG &&other)=delete
 
void from_handle_graph (const HandleGraph &graph)
 build the graph from another simple graph More...
 
void from_path_handle_graph (const PathHandleGraph &graph)
 build the graph from another path handle graph More...
 
void from_enumerators (const std::function< void(const std::function< void(const std::string &seq, const nid_t &node_id)> &)> &for_each_sequence, const std::function< void(const std::function< void(const nid_t &from, const bool &from_rev, const nid_t &to, const bool &to_rev)> &)> &for_each_edge, const std::function< void(const std::function< void(const std::string &path_name, const nid_t &node_id, const bool &is_rev, const std::string &cigar, const bool &is_empty, const bool &is_circular)> &)> &for_each_path_element, bool validate=false, std::string basename="")
 
void from_gfa (const std::string &gfa_filename, bool validate=false, std::string basename="")
 Use a memory-mapped GFA file to build the index in low memory. More...
 
void to_gfa (std::ostream &out) const
 
uint32_t get_magic_number (void) const
 Get the magic number used to prefix serialized streams. More...
 
size_t serialize_and_measure (std::ostream &out, sdsl::structure_tree_node *s=nullptr, std::string name="") const
 Like serialize() (inherited from SerializableHandleGraph) but logs internal member sizes and returns total size. More...
 
void dump_to_stream (std::ostream &out) const
 Dump information about the XG to the given stream for debugging. More...
 
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 has_node (nid_t node_id) const
 If the node with the given id exists. 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 std::string get_sequence (const handle_t &handle) const
 
virtual bool follow_edges_impl (const handle_t &handle, bool go_left, const std::function< bool(const handle_t &)> &iteratee) const
 
virtual bool for_each_handle_impl (const std::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 number of edges in the graph. More...
 
virtual size_t get_total_length () const
 Return the number of bases 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 char get_base (const handle_t &handle, size_t index) const
 
virtual std::string get_subsequence (const handle_t &handle, size_t index, size_t size) const
 
size_t get_path_count (void) const
 Returns the number of paths stored in the graph. More...
 
bool has_path (const std::string &path_name) const
 Determine if a path with a given name exists. More...
 
path_handle_t get_path_handle (const std::string &path_name) const
 Look up the path handle for the given path name. More...
 
std::string get_path_name (const path_handle_t &path_handle) const
 Look up the name of a path from a handle to it. More...
 
bool get_is_circular (const path_handle_t &path_handle) const
 Look up whether a path is circular. More...
 
size_t get_step_count (const path_handle_t &path_handle) const
 Returns the number of node steps in the path. More...
 
size_t get_path_length (const path_handle_t &path_handle) const
 Returns the total length of sequence in the path. More...
 
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 a step on a path. More...
 
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...
 
step_handle_t path_begin (const path_handle_t &path_handle) const
 
step_handle_t path_end (const path_handle_t &path_handle) const
 
step_handle_t path_back (const path_handle_t &path_handle) const
 
step_handle_t path_front_end (const path_handle_t &path_handle) const
 
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...
 
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...
 
step_handle_t get_next_step (const step_handle_t &step_handle) const
 
step_handle_t get_previous_step (const step_handle_t &step_handle) const
 
bool for_each_path_handle_impl (const std::function< bool(const path_handle_t &)> &iteratee) const
 Execute a function on each path in the graph. More...
 
bool for_each_step_on_handle_impl (const handle_t &handle, const std::function< bool(const step_handle_t &)> &iteratee) const
 Executes a function on each step of a handle in any path. More...
 
size_t get_position_of_step (const step_handle_t &step) const
 Gets the position of a given step in the path it's from. More...
 
step_handle_t get_step_at_position (const path_handle_t &path, const size_t &position) const
 Get the step at a given position. More...
 
size_t id_to_rank (const nid_t &id) const
 id to rank helper function More...
 
size_t handle_rank (const handle_t &handle) const
 
nid_t rank_to_id (const size_t &rank) const
 rank to id helper function More...
 
size_t max_node_rank (void) const
 
size_t node_vector_offset (const nid_t &id) const
 
nid_t node_at_vector_offset (const size_t &offset) const
 Return the node overlapping the given offset in the implicit node vector. More...
 
size_t max_path_rank (void) const
 
size_t node_graph_idx (const nid_t &id) const
 
const XGPathget_path (const std::string &name) const
 
std::string path_name (const size_t &rank) const
 
std::vector< size_t > path_ranks_by_prefix (const std::string &prefix) const
 
std::vector< std::string > path_names_by_prefix (const std::string &prefix) const
 
std::vector< path_handle_tpaths_of_handle (const handle_t &handle) const
 
bool path_contains_handle (const std::string &name, const handle_t &handle) const
 
std::pair< pos_t, int64_t > next_path_position (const pos_t &pos, const int64_t &max_search) const
 
std::pair< nid_t, std::vector< path_handle_t > > nearest_path_node (const nid_t &id, int64_t max_steps=16) const
 
int64_t min_approx_path_distance (const nid_t &id1, const nid_t &id2) const
 
std::vector< size_t > position_in_path (const handle_t &handle, const path_handle_t &path) const
 
std::unordered_map< path_handle_t, std::vector< size_t > > position_in_paths (const handle_t &handle, const size_t &offset) const
 
void for_path_range (const std::string &name, int64_t start, int64_t stop, std::function< void(const handle_t &)> lambda, bool is_rev) const
 
std::unordered_map< path_handle_t, std::vector< std::pair< size_t, bool > > > offsets_in_paths (const pos_t &gpos) const
 
std::unordered_map< path_handle_t, std::vector< std::pair< size_t, bool > > > nearest_offsets_in_paths (const pos_t &pos, int64_t max_search) const
 
handle_t handle_at_path_position (const path_handle_t &path, size_t pos) const
 
size_t node_start_at_path_position (const path_handle_t &path, size_t pos) const
 
pos_t graph_pos_at_path_position (const path_handle_t &path, size_t path_pos) const
 
pos_t graph_pos_at_path_position (const std::string &name, size_t path_pos) const
 
char pos_char (nid_t id, bool is_rev, size_t off) const
 
std::string pos_substr (nid_t id, bool is_rev, size_t off, size_t len) const
 
size_t edge_index (const edge_t &edge) const
 Return a unique index among edges in the graph. More...
 
size_t get_g_iv_size (void) const
 
- Public Member Functions inherited from handlegraph::PathPositionHandleGraph
virtual ~PathPositionHandleGraph ()=default
 
virtual bool for_each_step_position_on_handle (const handle_t &handle, const std::function< bool(const step_handle_t &, const bool &, const size_t &)> &iteratee) const
 
- Public Member Functions inherited from handlegraph::PathHandleGraph
virtual ~PathHandleGraph ()=default
 
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
 
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
 
bool has_edge (const edge_t &edge) const
 Convenient wrapper of has_edge for edge_t argument. More...
 
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::Serializable
virtual ~Serializable ()=default
 
virtual void serialize (std::ostream &out) const
 
virtual void serialize (const std::string &filename) const
 
virtual void deserialize (std::istream &in)
 
virtual void deserialize (const std::string &filename)
 
virtual void serialize (std::ostream &out)
 
virtual void serialize (const std::string &filename)
 
- Public Member Functions inherited from handlegraph::VectorizableHandleGraph
virtual ~VectorizableHandleGraph ()=default
 
- Public Member Functions inherited from handlegraph::RankedHandleGraph
virtual size_t handle_to_rank (const handle_t &handle) const
 
virtual handle_t rank_to_handle (const size_t &rank) const
 Return the handle with a given rank. More...
 

Public Attributes

size_t seq_length = 0
 
size_t node_count = 0
 
size_t edge_count = 0
 
size_t path_count = 0
 

Static Public Attributes

const static uint32_t CURRENT_VERSION = 16
 
static const char path_name_csa_delim = '$'
 
static const char old_version_path_name_start = '#'
 
static const char old_version_path_name_end = '$'
 

Protected Member Functions

void deserialize_members (std::istream &in)
 
void serialize_members (std::ostream &out) const
 Write the XG's contents to a stream aready prefixed with a magic number. More...
 
size_t serialize_members_and_measure (std::ostream &out, sdsl::structure_tree_node *s=nullptr, std::string name="") const
 Like serialize_members() but logs internal member sizes and returns total size. More...
 

Private Member Functions

void orientation_from_old_edge_type (int type, bool &from_rev, bool &to_rev) const
 
void reencode_old_g_vector (const sdsl::int_vector<> &old_g_iv, const sdsl::rank_support_v< 1 > &old_g_bv_rank)
 
void index_path_names ()
 
void index_node_to_path (const std::string &basename)
 
void print_graph () const
 

Static Private Member Functions

static bool edge_orientation (const uint64_t &raw_edge)
 
static int64_t edge_relative_offset (const uint64_t &raw_edge)
 
static uint64_t encode_edge (const size_t &offest_from, const size_t &offest_to, const bool &to_rev)
 

Private Attributes

sdsl::int_vector g_iv
 
sdsl::bit_vector g_bv
 delimit node records to allow lookup of nodes in g_civ by rank More...
 
sdsl::rank_support_v< 1 > g_bv_rank
 
sdsl::bit_vector::select_1_type g_bv_select
 
sdsl::int_vector s_iv
 
sdsl::bit_vector s_bv
 
sdsl::rank_support_v< 1 > s_bv_rank
 
sdsl::bit_vector::select_1_type s_bv_select
 
nid_t min_id = 0
 
nid_t max_id = 0
 
sdsl::int_vector r_iv
 
sdsl::int_vector pn_iv
 
sdsl::csa_wt pn_csa
 
sdsl::bit_vector pn_bv
 
sdsl::rank_support_v< 1 > pn_bv_rank
 
sdsl::bit_vector::select_1_type pn_bv_select
 
sdsl::int_vector pi_iv
 
std::vector< XGPath * > paths
 
sdsl::int_vector np_iv
 
sdsl::int_vector nr_iv
 
sdsl::int_vector nx_iv
 
sdsl::bit_vector np_bv
 
sdsl::bit_vector::select_1_type np_bv_select
 

Static Private Attributes

const static int G_NODE_ID_OFFSET = 0
 
const static int G_NODE_SEQ_START_OFFSET = 1
 
const static int G_NODE_LENGTH_OFFSET = 2
 
const static int G_NODE_LEFT_COUNT_OFFSET = 3
 
const static int G_NODE_RIGHT_COUNT_OFFSET = 4
 
const static int G_NODE_HEADER_LENGTH = 5
 
const static int OLD_G_NODE_TO_COUNT_OFFSET = 3
 
const static int OLD_G_NODE_FROM_COUNT_OFFSET = 4
 
const static int OLD_G_EDGE_OFFSET_OFFSET = 0
 
const static int OLD_G_EDGE_TYPE_OFFSET = 1
 
const static int OLD_G_EDGE_LENGTH = 2
 
const static int OLD_EDGE_TYPE_MIN = 1
 
const static int OLD_EDGE_TYPE_END_START = 1
 
const static int OLD_EDGE_TYPE_END_END = 2
 
const static int OLD_EDGE_TYPE_START_START = 3
 
const static int OLD_EDGE_TYPE_START_END = 4
 
const static int OLD_EDGE_TYPE_MAX = 4
 

Additional Inherited Members

Detailed Description

Provides succinct storage for a graph, its positional paths, and a set of embedded threads.

Constructor & Destructor Documentation

◆ XG() [1/3]

xg::XG::XG ( void  )
default

◆ ~XG()

xg::XG::~XG ( void  )

◆ XG() [2/3]

xg::XG::XG ( const XG other)
delete

◆ XG() [3/3]

xg::XG::XG ( XG &&  other)
delete

Member Function Documentation

◆ deserialize_members()

void xg::XG::deserialize_members ( std::istream &  in)
protectedvirtual

Load this XG index from a stream from which the magic number has already been read. Throw an XGFormatError if the stream does not produce a valid XG file.

Implements handlegraph::Serializable.

◆ dump_to_stream()

void xg::XG::dump_to_stream ( std::ostream &  out) const

Dump information about the XG to the given stream for debugging.

◆ edge_index()

size_t xg::XG::edge_index ( const edge_t edge) const
virtual

Return a unique index among edges in the graph.

Implements handlegraph::VectorizableHandleGraph.

◆ edge_orientation()

bool xg::XG::edge_orientation ( const uint64_t &  raw_edge)
staticprivate

◆ edge_relative_offset()

int64_t xg::XG::edge_relative_offset ( const uint64_t &  raw_edge)
staticprivate

◆ encode_edge()

uint64_t xg::XG::encode_edge ( const size_t &  offest_from,
const size_t &  offest_to,
const bool &  to_rev 
)
staticprivate

◆ flip()

handle_t xg::XG::flip ( const handle_t handle) const
virtual

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

Implements handlegraph::HandleGraph.

◆ follow_edges_impl()

bool xg::XG::follow_edges_impl ( const handle_t handle,
bool  go_left,
const std::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.

Implements handlegraph::HandleGraph.

◆ for_each_handle_impl()

bool xg::XG::for_each_handle_impl ( const std::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.

Implements handlegraph::HandleGraph.

◆ for_each_path_handle_impl()

bool xg::XG::for_each_path_handle_impl ( const std::function< bool(const path_handle_t &)> &  iteratee) const
virtual

Execute a function on each path in the graph.

Implements handlegraph::PathHandleGraph.

◆ for_each_step_on_handle_impl()

bool xg::XG::for_each_step_on_handle_impl ( const handle_t handle,
const std::function< bool(const step_handle_t &)> &  iteratee 
) const
virtual

Executes a function on each step of a handle in any path.

Implements handlegraph::PathHandleGraph.

◆ for_path_range()

void xg::XG::for_path_range ( const std::string &  name,
int64_t  start,
int64_t  stop,
std::function< void(const handle_t &)>  lambda,
bool  is_rev 
) const

◆ from_enumerators()

void xg::XG::from_enumerators ( const std::function< void(const std::function< void(const std::string &seq, const nid_t &node_id)> &)> &  for_each_sequence,
const std::function< void(const std::function< void(const nid_t &from, const bool &from_rev, const nid_t &to, const bool &to_rev)> &)> &  for_each_edge,
const std::function< void(const std::function< void(const std::string &path_name, const nid_t &node_id, const bool &is_rev, const std::string &cigar, const bool &is_empty, const bool &is_circular)> &)> &  for_each_path_element,
bool  validate = false,
std::string  basename = "" 
)

Use external enumerators to drive graph construction. The order in which nodes are enumerated becomes the XG's node order. Note that we will get the best efficiency if the graph is enumerated in topological order.

◆ from_gfa()

void xg::XG::from_gfa ( const std::string &  gfa_filename,
bool  validate = false,
std::string  basename = "" 
)

Use a memory-mapped GFA file to build the index in low memory.

◆ from_handle_graph()

void xg::XG::from_handle_graph ( const HandleGraph graph)

build the graph from another simple graph

Build the graph from another simple graph. The order in which nodes are enumerated becomes the XG's node order. Note that we will get the best efficiency if the graph enumerates itself in topological order.

◆ from_path_handle_graph()

void xg::XG::from_path_handle_graph ( const PathHandleGraph graph)

build the graph from another path handle graph

Build the graph from another path handle graph. The order in which nodes are enumerated becomes the XG's node order. Note that we will get the best efficiency if the graph enumerates itself in topological order.

◆ get_base()

char xg::XG::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_edge_count()

size_t xg::XG::get_edge_count ( ) const
virtual

Return the number of edges in the graph.

Reimplemented from handlegraph::HandleGraph.

◆ get_g_iv_size()

size_t xg::XG::get_g_iv_size ( void  ) const

◆ get_handle()

handle_t xg::XG::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 xg::XG::get_handle_of_step ( const step_handle_t step_handle) const
virtual

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

Implements handlegraph::PathHandleGraph.

◆ get_id()

nid_t xg::XG::get_id ( const handle_t handle) const
virtual

Get the ID from a handle.

Implements handlegraph::HandleGraph.

◆ get_is_circular()

bool xg::XG::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 xg::XG::get_is_reverse ( const handle_t handle) const
virtual

Get the orientation of a handle.

Implements handlegraph::HandleGraph.

◆ get_length()

size_t xg::XG::get_length ( const handle_t handle) const
virtual

Get the length of a node.

Implements handlegraph::HandleGraph.

◆ get_magic_number()

uint32_t xg::XG::get_magic_number ( void  ) const
virtual

Get the magic number used to prefix serialized streams.

Implements handlegraph::Serializable.

◆ get_next_step()

step_handle_t xg::XG::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_count()

size_t xg::XG::get_node_count ( ) const
virtual

Return the number of nodes in the graph.

Implements handlegraph::HandleGraph.

◆ get_path()

const XGPath& xg::XG::get_path ( const std::string &  name) const

◆ get_path_count()

size_t xg::XG::get_path_count ( void  ) const
virtual

Returns the number of paths stored in the graph.

Implements handlegraph::PathHandleGraph.

◆ get_path_handle()

path_handle_t xg::XG::get_path_handle ( const std::string &  path_name) const
virtual

Look up the path handle for the given path name.

Implements handlegraph::PathHandleGraph.

◆ get_path_handle_of_step()

path_handle_t xg::XG::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_length()

size_t xg::XG::get_path_length ( const path_handle_t path_handle) const
virtual

Returns the total length of sequence in the path.

Implements handlegraph::PathPositionHandleGraph.

◆ get_path_name()

std::string xg::XG::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_position_of_step()

size_t xg::XG::get_position_of_step ( const step_handle_t step) const
virtual

Gets the position of a given step in the path it's from.

Implements handlegraph::PathPositionHandleGraph.

◆ get_previous_step()

step_handle_t xg::XG::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()

std::string xg::XG::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_at_position()

step_handle_t xg::XG::get_step_at_position ( const path_handle_t path,
const size_t &  position 
) const
virtual

Get the step at a given position.

Implements handlegraph::PathPositionHandleGraph.

◆ get_step_count()

size_t xg::XG::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()

std::string xg::XG::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.

◆ get_total_length()

size_t xg::XG::get_total_length ( ) const
virtual

Return the number of bases in the graph.

Reimplemented from handlegraph::HandleGraph.

◆ graph_pos_at_path_position() [1/2]

pos_t xg::XG::graph_pos_at_path_position ( const path_handle_t path,
size_t  path_pos 
) const

◆ graph_pos_at_path_position() [2/2]

pos_t xg::XG::graph_pos_at_path_position ( const std::string &  name,
size_t  path_pos 
) const

◆ handle_at_path_position()

handle_t xg::XG::handle_at_path_position ( const path_handle_t path,
size_t  pos 
) const

◆ handle_rank()

size_t xg::XG::handle_rank ( const handle_t handle) const

◆ has_next_step()

bool xg::XG::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()

bool xg::XG::has_node ( nid_t  node_id) const
virtual

If the node with the given id exists.

Implements handlegraph::HandleGraph.

◆ has_path()

bool xg::XG::has_path ( const std::string &  path_name) const
virtual

Determine if a path with a given name exists.

Implements handlegraph::PathHandleGraph.

◆ has_previous_step()

bool xg::XG::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.

◆ id_to_rank()

size_t xg::XG::id_to_rank ( const nid_t id) const
virtual

id to rank helper function

Implements handlegraph::RankedHandleGraph.

◆ index_node_to_path()

void xg::XG::index_node_to_path ( const std::string &  basename)
private

◆ index_path_names()

void xg::XG::index_path_names ( )
private

◆ max_node_id()

nid_t xg::XG::max_node_id ( ) const
virtual

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

Implements handlegraph::HandleGraph.

◆ max_node_rank()

size_t xg::XG::max_node_rank ( void  ) const

◆ max_path_rank()

size_t xg::XG::max_path_rank ( void  ) const

◆ min_approx_path_distance()

int64_t xg::XG::min_approx_path_distance ( const nid_t id1,
const nid_t id2 
) const

◆ min_node_id()

nid_t xg::XG::min_node_id ( ) const
virtual

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

Implements handlegraph::HandleGraph.

◆ nearest_offsets_in_paths()

std::unordered_map< path_handle_t, std::vector< std::pair< size_t, bool > > > xg::XG::nearest_offsets_in_paths ( const pos_t pos,
int64_t  max_search 
) const

◆ nearest_path_node()

std::pair< nid_t, std::vector< path_handle_t > > xg::XG::nearest_path_node ( const nid_t id,
int64_t  max_steps = 16 
) const

◆ next_path_position()

std::pair< pos_t, int64_t > xg::XG::next_path_position ( const pos_t pos,
const int64_t &  max_search 
) const

◆ node_at_vector_offset()

nid_t xg::XG::node_at_vector_offset ( const size_t &  offset) const
virtual

Return the node overlapping the given offset in the implicit node vector.

Implements handlegraph::VectorizableHandleGraph.

◆ node_graph_idx()

size_t xg::XG::node_graph_idx ( const nid_t id) const

◆ node_start_at_path_position()

size_t xg::XG::node_start_at_path_position ( const path_handle_t path,
size_t  pos 
) const

◆ node_vector_offset()

size_t xg::XG::node_vector_offset ( const nid_t node_id) const
virtual

Return the start position of the node in a (possibly implict) sorted array constructed from the concatenation of the node sequences

Implements handlegraph::VectorizableHandleGraph.

◆ offsets_in_paths()

std::unordered_map< path_handle_t, std::vector< std::pair< size_t, bool > > > xg::XG::offsets_in_paths ( const pos_t gpos) const

◆ operator=() [1/2]

XG& xg::XG::operator= ( const XG other)
delete

◆ operator=() [2/2]

XG& xg::XG::operator= ( XG &&  other)
delete

◆ orientation_from_old_edge_type()

void xg::XG::orientation_from_old_edge_type ( int  type,
bool &  from_rev,
bool &  to_rev 
) const
private

◆ path_back()

step_handle_t xg::XG::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 xg::XG::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_contains_handle()

bool xg::XG::path_contains_handle ( const std::string &  name,
const handle_t handle 
) const

◆ path_end()

step_handle_t xg::XG::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_front_end()

step_handle_t xg::XG::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_name()

std::string xg::XG::path_name ( const size_t &  rank) const

◆ path_names_by_prefix()

std::vector<std::string> xg::XG::path_names_by_prefix ( const std::string &  prefix) const

◆ path_ranks_by_prefix()

std::vector<size_t> xg::XG::path_ranks_by_prefix ( const std::string &  prefix) const

◆ paths_of_handle()

std::vector< path_handle_t > xg::XG::paths_of_handle ( const handle_t handle) const

◆ pos_char()

char xg::XG::pos_char ( nid_t  id,
bool  is_rev,
size_t  off 
) const

◆ pos_substr()

std::string xg::XG::pos_substr ( nid_t  id,
bool  is_rev,
size_t  off,
size_t  len 
) const

◆ position_in_path()

std::vector< size_t > xg::XG::position_in_path ( const handle_t handle,
const path_handle_t path 
) const

◆ position_in_paths()

std::unordered_map< path_handle_t, std::vector< size_t > > xg::XG::position_in_paths ( const handle_t handle,
const size_t &  offset 
) const

◆ print_graph()

void xg::XG::print_graph ( ) const
private

◆ rank_to_id()

nid_t xg::XG::rank_to_id ( const size_t &  rank) const
virtual

rank to id helper function

Implements handlegraph::RankedHandleGraph.

◆ reencode_old_g_vector()

void xg::XG::reencode_old_g_vector ( const sdsl::int_vector<> &  old_g_iv,
const sdsl::rank_support_v< 1 > &  old_g_bv_rank 
)
private

◆ serialize_and_measure()

size_t xg::XG::serialize_and_measure ( std::ostream &  out,
sdsl::structure_tree_node *  s = nullptr,
std::string  name = "" 
) const

Like serialize() (inherited from SerializableHandleGraph) but logs internal member sizes and returns total size.

◆ serialize_members()

void xg::XG::serialize_members ( std::ostream &  out) const
protectedvirtual

Write the XG's contents to a stream aready prefixed with a magic number.

Implements handlegraph::Serializable.

◆ serialize_members_and_measure()

size_t xg::XG::serialize_members_and_measure ( std::ostream &  out,
sdsl::structure_tree_node *  s = nullptr,
std::string  name = "" 
) const
protected

Like serialize_members() but logs internal member sizes and returns total size.

◆ to_gfa()

void xg::XG::to_gfa ( std::ostream &  out) const

Member Data Documentation

◆ CURRENT_VERSION

const static uint32_t xg::XG::CURRENT_VERSION = 16
static

◆ edge_count

size_t xg::XG::edge_count = 0

◆ g_bv

sdsl::bit_vector xg::XG::g_bv
private

delimit node records to allow lookup of nodes in g_civ by rank

◆ g_bv_rank

sdsl::rank_support_v<1> xg::XG::g_bv_rank
private

◆ g_bv_select

sdsl::bit_vector::select_1_type xg::XG::g_bv_select
private

◆ g_iv

sdsl::int_vector xg::XG::g_iv
private

locally traversable graph storage

Encoding designed for efficient compression, cache locality, and relativistic traversal of the graph.

node := { header, left_side_edges, right_side_edges } header := { node_id, node_start, node_length, edges_left_count, edges_right_count } node_id := integer node_start := integer (offset in s_iv) node_length := integer edges_left_count := integer edges_right_count := integer left_side_edges := { edge, ... } right_side_edges := { edge, ... } edge := { relative_offset | target_is_rev } (bit-packed)

  • targets are considered reverse if you should end up on their reverse strand by traversing left out of left side edges or traversing right out of right side edges (starting on the forward strand).
  • relative offset is converted to positive numbers with this mapping 0 -1 1 -2 2 ... 0 1 2 3 4 ... TODO: most edges will be separated in increments of at least the header length, this could be exploited to have a more efficient encoding

◆ G_NODE_HEADER_LENGTH

const static int xg::XG::G_NODE_HEADER_LENGTH = 5
staticprivate

◆ G_NODE_ID_OFFSET

const static int xg::XG::G_NODE_ID_OFFSET = 0
staticprivate

◆ G_NODE_LEFT_COUNT_OFFSET

const static int xg::XG::G_NODE_LEFT_COUNT_OFFSET = 3
staticprivate

◆ G_NODE_LENGTH_OFFSET

const static int xg::XG::G_NODE_LENGTH_OFFSET = 2
staticprivate

◆ G_NODE_RIGHT_COUNT_OFFSET

const static int xg::XG::G_NODE_RIGHT_COUNT_OFFSET = 4
staticprivate

◆ G_NODE_SEQ_START_OFFSET

const static int xg::XG::G_NODE_SEQ_START_OFFSET = 1
staticprivate

◆ max_id

nid_t xg::XG::max_id = 0
private

◆ min_id

nid_t xg::XG::min_id = 0
private

◆ node_count

size_t xg::XG::node_count = 0

◆ np_bv

sdsl::bit_vector xg::XG::np_bv
private

◆ np_bv_select

sdsl::bit_vector::select_1_type xg::XG::np_bv_select
private

◆ np_iv

sdsl::int_vector xg::XG::np_iv
private

◆ nr_iv

sdsl::int_vector xg::XG::nr_iv
private

◆ nx_iv

sdsl::int_vector xg::XG::nx_iv
private

◆ OLD_EDGE_TYPE_END_END

const static int xg::XG::OLD_EDGE_TYPE_END_END = 2
staticprivate

◆ OLD_EDGE_TYPE_END_START

const static int xg::XG::OLD_EDGE_TYPE_END_START = 1
staticprivate

◆ OLD_EDGE_TYPE_MAX

const static int xg::XG::OLD_EDGE_TYPE_MAX = 4
staticprivate

◆ OLD_EDGE_TYPE_MIN

const static int xg::XG::OLD_EDGE_TYPE_MIN = 1
staticprivate

◆ OLD_EDGE_TYPE_START_END

const static int xg::XG::OLD_EDGE_TYPE_START_END = 4
staticprivate

◆ OLD_EDGE_TYPE_START_START

const static int xg::XG::OLD_EDGE_TYPE_START_START = 3
staticprivate

◆ OLD_G_EDGE_LENGTH

const static int xg::XG::OLD_G_EDGE_LENGTH = 2
staticprivate

◆ OLD_G_EDGE_OFFSET_OFFSET

const static int xg::XG::OLD_G_EDGE_OFFSET_OFFSET = 0
staticprivate

◆ OLD_G_EDGE_TYPE_OFFSET

const static int xg::XG::OLD_G_EDGE_TYPE_OFFSET = 1
staticprivate

◆ OLD_G_NODE_FROM_COUNT_OFFSET

const static int xg::XG::OLD_G_NODE_FROM_COUNT_OFFSET = 4
staticprivate

◆ OLD_G_NODE_TO_COUNT_OFFSET

const static int xg::XG::OLD_G_NODE_TO_COUNT_OFFSET = 3
staticprivate

◆ old_version_path_name_end

const char xg::XG::old_version_path_name_end = '$'
static

◆ old_version_path_name_start

const char xg::XG::old_version_path_name_start = '#'
static

◆ path_count

size_t xg::XG::path_count = 0

◆ path_name_csa_delim

const char xg::XG::path_name_csa_delim = '$'
static

◆ paths

std::vector<XGPath*> xg::XG::paths
private

◆ pi_iv

sdsl::int_vector xg::XG::pi_iv
private

◆ pn_bv

sdsl::bit_vector xg::XG::pn_bv
private

◆ pn_bv_rank

sdsl::rank_support_v<1> xg::XG::pn_bv_rank
private

◆ pn_bv_select

sdsl::bit_vector::select_1_type xg::XG::pn_bv_select
private

◆ pn_csa

sdsl::csa_wt xg::XG::pn_csa
private

◆ pn_iv

sdsl::int_vector xg::XG::pn_iv
private

◆ r_iv

sdsl::int_vector xg::XG::r_iv
private

◆ s_bv

sdsl::bit_vector xg::XG::s_bv
private

◆ s_bv_rank

sdsl::rank_support_v<1> xg::XG::s_bv_rank
private

◆ s_bv_select

sdsl::bit_vector::select_1_type xg::XG::s_bv_select
private

◆ s_iv

sdsl::int_vector xg::XG::s_iv
private

◆ seq_length

size_t xg::XG::seq_length = 0

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