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

#include <path.hpp>

Public Member Functions

 Paths (void)
 
 Paths (const Paths &other)
 
 Paths (Paths &&other) noexcept
 
Pathsoperator= (const Paths &other)
 
Pathsoperator= (Paths &&other) noexcept
 
int64_t get_path_id (const string &name) const
 Get the lazily assigned numeric ID for a path, by name. More...
 
const string & get_path_name (int64_t id) const
 Get the name of a path, by numeric ID. More...
 
void sort_by_mapping_rank (void)
 
void rebuild_mapping_aux (void)
 Reassign ranks and rebuild indexes, treating the mapping lists in _paths as the truth. More...
 
bool is_head_or_tail_node (id_t)
 
vector< string > all_path_names (void)
 
void make_circular (const string &name)
 
void make_linear (const string &name)
 
void rebuild_node_mapping (void)
 
list< mapping_t >::iterator find_mapping (mapping_t *m)
 
list< mapping_t >::iterator remove_mapping (mapping_t *m)
 
list< mapping_t >::iterator insert_mapping (list< mapping_t >::iterator w, const string &path_name, const mapping_t &m)
 
pair< mapping_t *, mapping_t * > divide_mapping (mapping_t *m, const Position &pos)
 
pair< mapping_t *, mapping_t * > divide_mapping (mapping_t *m, size_t offset)
 
pair< mapping_t *, mapping_t * > replace_mapping (mapping_t *m, pair< mapping_t, mapping_t > n)
 
void remove_paths (const set< string > &names)
 
void remove_path (const string &name)
 
void keep_paths (const set< string > &name)
 
void remove_node (id_t id)
 
bool has_path (const string &name) const
 
void to_json (ostream &out)
 
list< mapping_t > & get_path (const string &name)
 
list< mapping_t > & get_create_path (const string &name)
 
list< mapping_t > & create_path (const string &name)
 
bool has_mapping (const string &name, int32_t rank)
 
bool has_node_mapping (id_t id) const
 
bool has_node_mapping (Node *n) const
 
map< int64_t, set< mapping_t * > > & get_node_mapping (Node *n)
 
map< int64_t, set< mapping_t * > > & get_node_mapping (id_t id)
 
const map< int64_t, set< mapping_t * > > & get_node_mapping (id_t id) const
 
map< string, set< mapping_t * > > get_node_mapping_by_path_name (Node *n)
 
map< string, set< mapping_t * > > get_node_mapping_by_path_name (id_t id)
 
map< string, map< int, mapping_t * > > get_node_mappings_by_rank (id_t id)
 
map< string, map< int, mapping_t > > get_node_mapping_copies_by_rank (id_t id)
 
mapping_ttraverse_left (mapping_t *mapping)
 
mapping_ttraverse_right (mapping_t *mapping)
 
const string mapping_path_name (mapping_t *m)
 
int64_t mapping_path_id (mapping_t *m)
 
set< string > of_node (id_t id)
 
map< string, int > node_path_traversal_counts (id_t id, bool rev=false)
 
vector< string > node_path_traversals (id_t id, bool rev=false)
 
bool are_consecutive_nodes_in_path (id_t id1, id_t id2, const string &path_name)
 
vector< string > over_edge (id_t id1, bool rev1, id_t id2, bool rev2, vector< string > following)
 
vector< string > over_directed_edge (id_t id1, bool rev1, id_t id2, bool rev2, vector< string > following)
 
size_t size (void) const
 
bool empty (void) const
 
void clear (void)
 
void clear_mapping_ranks (void)
 
void compact_ranks (void)
 
void load (istream &in)
 
void write (ostream &out)
 Write paths to the given stream, ending with an EOF marker. More...
 
void to_graph (Graph &g)
 Add all paths into the given Protobuf graph. Creates a new path for every path. More...
 
Path path (const string &name)
 
void append_mapping (const string &name, const mapping_t &m, bool warn_on_duplicates=false)
 
void append_mapping (const string &name, id_t id, bool is_reverse, size_t length, size_t rank=0, bool warn_on_duplicates=false)
 
void prepend_mapping (const string &name, const Mapping &m, bool warn_on_duplicates=false)
 
void prepend_mapping (const string &name, id_t id, bool is_reverse, size_t length, size_t rank=0, bool warn_on_duplicates=false)
 
size_t get_next_rank (const string &name)
 
void append (const Paths &paths, bool warn_on_duplicates=false, bool rebuild_indexes=true)
 
void append (const Graph &g, bool warn_on_duplicates=false, bool rebuild_indexes=true)
 
void extend (const Paths &paths, bool warn_on_duplicates=false, bool rebuild_indexes=true)
 
void extend (const Path &p, bool warn_on_duplicates=false, bool rebuild_indexes=true)
 
void extend (const vector< Path > &paths, bool warn_on_duplicates=false, bool rebuild_indexes=true)
 
void for_each (const function< void(const Path &)> &lambda)
 
void for_each_name (const function< void(const string &)> &lambda) const
 
bool for_each_name_stoppable (const function< bool(const string &)> &lambda) const
 
void for_each_stream (istream &in, const function< void(Path &)> &lambda)
 
void increment_node_ids (id_t inc)
 
void swap_node_ids (const std::function< nid_t(const nid_t &)> &get_new_id)
 
void swap_node_ids (hash_map< id_t, id_t > &id_mapping)
 
void reassign_node (id_t new_id, mapping_t *m)
 
void for_each_mapping (const function< void(mapping_t &)> &lambda)
 

Static Public Member Functions

static string strip_subrange (const string &path_name, subrange_t *subrange=nullptr)
 

Public Attributes

map< string, list< mapping_t > > _paths
 
hash_map< const mapping_t *, pair< list< mapping_t >::iterator, int64_t > > mapping_itr
 
map< string, hash_map< int32_t, mapping_t * > > mappings_by_rank
 
hash_map< id_t, map< int64_t, set< mapping_t * > > > node_mapping
 
set< id_thead_tail_nodes
 
set< string > circular
 

Static Public Attributes

const static function< bool(const string &)> is_alt
 

Private Attributes

int64_t max_path_id
 
map< string, int64_t > name_to_id
 
map< int64_t, string > id_to_name
 

Constructor & Destructor Documentation

◆ Paths() [1/3]

vg::Paths::Paths ( void  )

◆ Paths() [2/3]

vg::Paths::Paths ( const Paths other)
inline

◆ Paths() [3/3]

vg::Paths::Paths ( Paths &&  other)
inlinenoexcept

Member Function Documentation

◆ all_path_names()

vector< string > vg::Paths::all_path_names ( void  )

◆ append() [1/2]

void vg::Paths::append ( const Graph g,
bool  warn_on_duplicates = false,
bool  rebuild_indexes = true 
)

◆ append() [2/2]

void vg::Paths::append ( const Paths paths,
bool  warn_on_duplicates = false,
bool  rebuild_indexes = true 
)

◆ append_mapping() [1/2]

void vg::Paths::append_mapping ( const string &  name,
const mapping_t m,
bool  warn_on_duplicates = false 
)

◆ append_mapping() [2/2]

void vg::Paths::append_mapping ( const string &  name,
id_t  id,
bool  is_reverse,
size_t  length,
size_t  rank = 0,
bool  warn_on_duplicates = false 
)

◆ are_consecutive_nodes_in_path()

bool vg::Paths::are_consecutive_nodes_in_path ( id_t  id1,
id_t  id2,
const string &  path_name 
)

◆ clear()

void vg::Paths::clear ( void  )

◆ clear_mapping_ranks()

void vg::Paths::clear_mapping_ranks ( void  )

◆ compact_ranks()

void vg::Paths::compact_ranks ( void  )

◆ create_path()

list< mapping_t > & vg::Paths::create_path ( const string &  name)

◆ divide_mapping() [1/2]

pair< mapping_t *, mapping_t * > vg::Paths::divide_mapping ( mapping_t m,
const Position pos 
)

◆ divide_mapping() [2/2]

pair< mapping_t *, mapping_t * > vg::Paths::divide_mapping ( mapping_t m,
size_t  offset 
)

◆ empty()

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

◆ extend() [1/3]

void vg::Paths::extend ( const Path p,
bool  warn_on_duplicates = false,
bool  rebuild_indexes = true 
)

◆ extend() [2/3]

void vg::Paths::extend ( const Paths paths,
bool  warn_on_duplicates = false,
bool  rebuild_indexes = true 
)

◆ extend() [3/3]

void vg::Paths::extend ( const vector< Path > &  paths,
bool  warn_on_duplicates = false,
bool  rebuild_indexes = true 
)

◆ find_mapping()

list< mapping_t >::iterator vg::Paths::find_mapping ( mapping_t m)

◆ for_each()

void vg::Paths::for_each ( const function< void(const Path &)> &  lambda)

◆ for_each_mapping()

void vg::Paths::for_each_mapping ( const function< void(mapping_t &)> &  lambda)

◆ for_each_name()

void vg::Paths::for_each_name ( const function< void(const string &)> &  lambda) const

◆ for_each_name_stoppable()

bool vg::Paths::for_each_name_stoppable ( const function< bool(const string &)> &  lambda) const

◆ for_each_stream()

void vg::Paths::for_each_stream ( istream &  in,
const function< void(Path &)> &  lambda 
)

◆ get_create_path()

list< mapping_t > & vg::Paths::get_create_path ( const string &  name)

◆ get_next_rank()

size_t vg::Paths::get_next_rank ( const string &  name)

◆ get_node_mapping() [1/3]

map< int64_t, set< mapping_t * > > & vg::Paths::get_node_mapping ( id_t  id)

◆ get_node_mapping() [2/3]

const map< int64_t, set< mapping_t * > > & vg::Paths::get_node_mapping ( id_t  id) const

◆ get_node_mapping() [3/3]

map< int64_t, set< mapping_t * > > & vg::Paths::get_node_mapping ( Node n)

◆ get_node_mapping_by_path_name() [1/2]

map< string, set< mapping_t * > > vg::Paths::get_node_mapping_by_path_name ( id_t  id)

◆ get_node_mapping_by_path_name() [2/2]

map< string, set< mapping_t * > > vg::Paths::get_node_mapping_by_path_name ( Node n)

◆ get_node_mapping_copies_by_rank()

map< string, map< int, mapping_t > > vg::Paths::get_node_mapping_copies_by_rank ( id_t  id)

◆ get_node_mappings_by_rank()

map< string, map< int, mapping_t * > > vg::Paths::get_node_mappings_by_rank ( id_t  id)

◆ get_path()

list< mapping_t > & vg::Paths::get_path ( const string &  name)

◆ get_path_id()

int64_t vg::Paths::get_path_id ( const string &  name) const

Get the lazily assigned numeric ID for a path, by name.

◆ get_path_name()

const string & vg::Paths::get_path_name ( int64_t  id) const

Get the name of a path, by numeric ID.

◆ has_mapping()

bool vg::Paths::has_mapping ( const string &  name,
int32_t  rank 
)

◆ has_node_mapping() [1/2]

bool vg::Paths::has_node_mapping ( id_t  id) const

◆ has_node_mapping() [2/2]

bool vg::Paths::has_node_mapping ( Node n) const

◆ has_path()

bool vg::Paths::has_path ( const string &  name) const

◆ increment_node_ids()

void vg::Paths::increment_node_ids ( id_t  inc)

◆ insert_mapping()

list< mapping_t >::iterator vg::Paths::insert_mapping ( list< mapping_t >::iterator  w,
const string &  path_name,
const mapping_t m 
)

◆ is_head_or_tail_node()

bool vg::Paths::is_head_or_tail_node ( id_t  id)

◆ keep_paths()

void vg::Paths::keep_paths ( const set< string > &  name)

◆ load()

void vg::Paths::load ( istream &  in)

◆ make_circular()

void vg::Paths::make_circular ( const string &  name)

◆ make_linear()

void vg::Paths::make_linear ( const string &  name)

◆ mapping_path_id()

int64_t vg::Paths::mapping_path_id ( mapping_t m)

◆ mapping_path_name()

const string vg::Paths::mapping_path_name ( mapping_t m)

◆ node_path_traversal_counts()

map< string, int > vg::Paths::node_path_traversal_counts ( id_t  id,
bool  rev = false 
)

◆ node_path_traversals()

vector< string > vg::Paths::node_path_traversals ( id_t  id,
bool  rev = false 
)

◆ of_node()

set< string > vg::Paths::of_node ( id_t  id)

◆ operator=() [1/2]

Paths& vg::Paths::operator= ( const Paths other)
inline

◆ operator=() [2/2]

Paths& vg::Paths::operator= ( Paths &&  other)
inlinenoexcept

◆ over_directed_edge()

vector< string > vg::Paths::over_directed_edge ( id_t  id1,
bool  rev1,
id_t  id2,
bool  rev2,
vector< string >  following 
)

◆ over_edge()

vector< string > vg::Paths::over_edge ( id_t  id1,
bool  rev1,
id_t  id2,
bool  rev2,
vector< string >  following 
)

◆ path()

Path vg::Paths::path ( const string &  name)

◆ prepend_mapping() [1/2]

void vg::Paths::prepend_mapping ( const string &  name,
const Mapping m,
bool  warn_on_duplicates = false 
)

◆ prepend_mapping() [2/2]

void vg::Paths::prepend_mapping ( const string &  name,
id_t  id,
bool  is_reverse,
size_t  length,
size_t  rank = 0,
bool  warn_on_duplicates = false 
)

◆ reassign_node()

void vg::Paths::reassign_node ( id_t  new_id,
mapping_t m 
)

◆ rebuild_mapping_aux()

void vg::Paths::rebuild_mapping_aux ( void  )

Reassign ranks and rebuild indexes, treating the mapping lists in _paths as the truth.

◆ rebuild_node_mapping()

void vg::Paths::rebuild_node_mapping ( void  )

◆ remove_mapping()

list< mapping_t >::iterator vg::Paths::remove_mapping ( mapping_t m)

◆ remove_node()

void vg::Paths::remove_node ( id_t  id)

◆ remove_path()

void vg::Paths::remove_path ( const string &  name)

◆ remove_paths()

void vg::Paths::remove_paths ( const set< string > &  names)

◆ replace_mapping()

pair< mapping_t *, mapping_t * > vg::Paths::replace_mapping ( mapping_t m,
pair< mapping_t, mapping_t n 
)

◆ size()

size_t vg::Paths::size ( void  ) const

◆ sort_by_mapping_rank()

void vg::Paths::sort_by_mapping_rank ( void  )

◆ strip_subrange()

string vg::Paths::strip_subrange ( const string &  path_name,
subrange_t subrange = nullptr 
)
static

◆ swap_node_ids() [1/2]

void vg::Paths::swap_node_ids ( const std::function< nid_t(const nid_t &)> &  get_new_id)

◆ swap_node_ids() [2/2]

void vg::Paths::swap_node_ids ( hash_map< id_t, id_t > &  id_mapping)

◆ to_graph()

void vg::Paths::to_graph ( Graph g)

Add all paths into the given Protobuf graph. Creates a new path for every path.

◆ to_json()

void vg::Paths::to_json ( ostream &  out)

◆ traverse_left()

mapping_t * vg::Paths::traverse_left ( mapping_t mapping)

◆ traverse_right()

mapping_t * vg::Paths::traverse_right ( mapping_t mapping)

◆ write()

void vg::Paths::write ( ostream &  out)

Write paths to the given stream, ending with an EOF marker.

Member Data Documentation

◆ _paths

map<string, list<mapping_t> > vg::Paths::_paths

◆ circular

set<string> vg::Paths::circular

◆ head_tail_nodes

set<id_t> vg::Paths::head_tail_nodes

◆ id_to_name

map<int64_t, string> vg::Paths::id_to_name
mutableprivate

◆ is_alt

const std::function< bool(const string &)> vg::Paths::is_alt
static
Initial value:
= [](const string& path_name) {
string prefix("_alt_");
if (path_name.length() < prefix.length() || !std::equal(prefix.begin(), prefix.end(), path_name.begin())) {
return false;
}
size_t found_digits = 0;
for (auto it = path_name.rbegin(); it != path_name.rend() && *it != '_'; ++it) {
if (*it < '0' || *it > '9') {
return false;
}
found_digits++;
}
return (found_digits > 0);
}

◆ mapping_itr

hash_map<const mapping_t*, pair<list<mapping_t>::iterator, int64_t> > vg::Paths::mapping_itr

◆ mappings_by_rank

map<string, hash_map<int32_t, mapping_t*> > vg::Paths::mappings_by_rank

◆ max_path_id

int64_t vg::Paths::max_path_id
mutableprivate

◆ name_to_id

map<string, int64_t> vg::Paths::name_to_id
mutableprivate

◆ node_mapping

hash_map<id_t, map<int64_t, set<mapping_t*> > > vg::Paths::node_mapping

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