vg
tools for working with variation graphs
|
#include <path_metadata.hpp>
Public Member Functions | |
virtual | ~PathMetadata ()=default |
virtual PathSense | get_sense (const path_handle_t &handle) const |
What is the given path meant to be representing? More... | |
virtual std::string | get_sample_name (const path_handle_t &handle) const |
virtual std::string | get_locus_name (const path_handle_t &handle) const |
virtual size_t | get_haplotype (const path_handle_t &handle) const |
virtual size_t | get_phase_block (const path_handle_t &handle) const |
virtual subrange_t | get_subrange (const path_handle_t &handle) const |
template<typename Iteratee > | |
bool | for_each_path_of_sense (const PathSense &sense, const Iteratee &iteratee) const |
template<typename Iteratee > | |
bool | for_each_path_of_sample (const std::string &sample, const Iteratee &iteratee) const |
template<typename Iteratee > | |
bool | for_each_path_matching (const std::unordered_set< PathSense > *senses, const std::unordered_set< std::string > *samples, const std::unordered_set< std::string > *loci, const Iteratee &iteratee) const |
template<typename Iteratee > | |
bool | for_each_path_matching (const std::unordered_set< PathSense > &senses, const std::unordered_set< std::string > &samples, const std::unordered_set< std::string > &loci, const Iteratee &iteratee) const |
template<typename Iteratee > | |
bool | for_each_step_of_sense (const handle_t &visited, const PathSense &sense, const Iteratee &iteratee) const |
Static Public Member Functions | |
static PathSense | parse_sense (const std::string &path_name) |
static std::string | parse_sample_name (const std::string &path_name) |
static std::string | parse_locus_name (const std::string &path_name) |
static size_t | parse_haplotype (const std::string &path_name) |
static size_t | parse_phase_block (const std::string &path_name) |
static subrange_t | parse_subrange (const std::string &path_name) |
static void | parse_path_name (const std::string &path_name, PathSense &sense, std::string &sample, std::string &locus, size_t &haplotype, size_t &phase_block, subrange_t &subrange) |
Decompose a formatted path name into metadata. More... | |
static std::string | create_path_name (const PathSense &sense, const std::string &sample, const std::string &locus, const size_t &haplotype, const size_t &phase_block, const subrange_t &subrange) |
Static Public Attributes | |
static const std::string | NO_SAMPLE_NAME = "" |
static const std::string | NO_LOCUS_NAME = "" |
static const size_t | NO_HAPLOTYPE = std::numeric_limits<size_t>::max() |
static const size_t | NO_PHASE_BLOCK = std::numeric_limits<size_t>::max() |
static const subrange_t | NO_SUBRANGE {PathMetadata::NO_END_POSITION, PathMetadata::NO_END_POSITION} |
static const offset_t | NO_END_POSITION = std::numeric_limits<offset_t>::max() |
Protected Member Functions | |
virtual bool | for_each_path_matching_impl (const std::unordered_set< PathSense > *senses, const std::unordered_set< std::string > *samples, const std::unordered_set< std::string > *loci, const std::function< bool(const path_handle_t &)> &iteratee) const |
virtual bool | for_each_step_of_sense_impl (const handle_t &visited, const PathSense &sense, const std::function< bool(const step_handle_t &)> &iteratee) const |
virtual std::string | get_path_name (const path_handle_t &path_handle) const =0 |
Look up the name of a path from a handle to it. More... | |
virtual path_handle_t | get_path_handle_of_step (const step_handle_t &step_handle) const =0 |
Returns a handle to the path that an step is on. More... | |
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 |
Static Private Attributes | |
static const std::regex | FORMAT |
static const size_t | ASSEMBLY_OR_NAME_MATCH = 1 |
static const size_t | LOCUS_MATCH_NUMERICAL_WITHOUT_HAPLOTYPE = 2 |
static const size_t | HAPLOTYPE_MATCH = 2 |
static const size_t | LOCUS_MATCH_ANY = 3 |
static const size_t | PHASE_BLOCK_MATCH = 4 |
static const size_t | RANGE_START_MATCH = 5 |
static const size_t | RANGE_END_MATCH = 6 |
static const char | SEPARATOR = '#' |
Separator used to separate path name components. More... | |
static const char | RANGE_START_SEPARATOR = '[' |
static const char | RANGE_END_SEPARATOR = '-' |
static const char | RANGE_TERMINATOR = ']' |
This is the interface for embedded path and haplotype thread metadata.
Comes with a default implementation of this interface, based on a get_path_name() and special path name formatting.
Our model is that paths come in different "senses":
Paths of all sneses can represent subpaths, with bounds.
Depending on sense, a path might have:
|
virtualdefault |
|
static |
Compose a formatted path name for the given metadata. Any item can be the corresponding unset sentinel (PathMetadata::NO_LOCUS_NAME, PathMetadata::NO_PHASE_BLOCK, etc.).
|
protectedpure virtual |
Execute a function on each path in the graph. If it returns false, stop iteration. Returns true if we finished and false if we stopped early.
If the graph contains compressed haplotype paths and properly implements for_each_path_of_sense to retrieve them, they should not be visible here. Only reference or generic named paths should be visible.
Implemented in handlegraph::PathHandleGraph, xg::XG, vg::PathSubgraphOverlay, and vg::MemoizingGraph.
bool handlegraph::PathMetadata::for_each_path_matching | ( | const std::unordered_set< PathSense > & | senses, |
const std::unordered_set< std::string > & | samples, | ||
const std::unordered_set< std::string > & | loci, | ||
const Iteratee & | iteratee | ||
) | const |
Loop through all the paths matching the given query. Query elements which are empty match everything. Returns false and stops if the iteratee returns false.
bool handlegraph::PathMetadata::for_each_path_matching | ( | const std::unordered_set< PathSense > * | senses, |
const std::unordered_set< std::string > * | samples, | ||
const std::unordered_set< std::string > * | loci, | ||
const Iteratee & | iteratee | ||
) | const |
Loop through all the paths matching the given query. Query elements which are null match everything. Returns false and stops if the iteratee returns false.
|
protectedvirtual |
Loop through all the paths matching the given query. Query elements which are null match everything. Returns false and stops if the iteratee returns false.
bool handlegraph::PathMetadata::for_each_path_of_sample | ( | const std::string & | sample, |
const Iteratee & | iteratee | ||
) | const |
Loop through all the paths with the given sample name. Returns false and stops if the iteratee returns false.
bool handlegraph::PathMetadata::for_each_path_of_sense | ( | const PathSense & | sense, |
const Iteratee & | iteratee | ||
) | const |
Loop through all the paths with the given sense. Returns false and stops if the iteratee returns false.
bool handlegraph::PathMetadata::for_each_step_of_sense | ( | const handle_t & | visited, |
const PathSense & | sense, | ||
const Iteratee & | iteratee | ||
) | const |
Loop through all steps on the given handle for paths with the given sense. Returns false and stops if the iteratee returns false. TODO: Take the opportunity to make steps track orientation better?
|
protectedvirtual |
Loop through all steps on the given handle for paths with the given sense. Returns false and stops if the iteratee returns false.
|
protectedpure virtual |
Execute a function on each step of a handle in any path. If it returns false, stop iteration. Returns true if we finished and false if we stopped early.
If the graph contains compressed haplotype paths and properly implements for_each_step_of_sense to find them, they should not be visible here. Only reference or generic named paths should be visible.
Implemented in handlegraph::PathHandleGraph, xg::XG, vg::PathSubgraphOverlay, and vg::MemoizingGraph.
|
virtual |
Get the haplotype number (0 or 1, for diploid) of the path-or-thread, or NO_HAPLOTYPE if it does not belong to one.
|
virtual |
Get the name of the contig or gene asociated with the path-or-thread, or NO_LOCUS_NAME if it does not belong to one.
|
protectedpure virtual |
Returns a handle to the path that an step is on.
Implemented in handlegraph::PathHandleGraph, xg::XG, vg::VG, vg::PathSubgraphOverlay, and vg::MemoizingGraph.
|
protectedpure virtual |
Look up the name of a path from a handle to it.
Implemented in handlegraph::PathHandleGraph, xg::XG, vg::VG, vg::PathSubgraphOverlay, and vg::MemoizingGraph.
|
virtual |
Get the phase block number (contiguously phased region of a sample, contig, and haplotype) of the path-or-thread, or NO_PHASE_BLOCK if it does not belong to one.
|
virtual |
Get the name of the sample or assembly asociated with the path-or-thread, or NO_SAMPLE_NAME if it does not belong to one.
|
virtual |
What is the given path meant to be representing?
|
virtual |
Get the bounds of the path-or-thread that are actually represented here. Should be NO_SUBRANGE if the entirety is represented here, and 0-based inclusive start and exclusive end positions of the stored region on the full path-or-thread if a subregion is stored.
If no end position is stored, NO_END_POSITION may be returned for the end position.
|
static |
Get the haplotype number (0 or 1, for diploid) embedded in the given formatted path name, or NO_HAPLOTYPE if it does not belong to one.
|
static |
Get the name of the contig or gene embedded in the given formatted path name, or NO_LOCUS_NAME if it does not belong to one.
|
static |
Decompose a formatted path name into metadata.
|
static |
Get the phase block number (contiguously phased region of a sample, contig, and haplotype) embedded in the given formatted path name, or NO_PHASE_BLOCK if it does not belong to one.
|
static |
Get the name of the sample or assembly embedded in the given formatted path name, or NO_SAMPLE_NAME if it does not belong to one.
|
static |
Extract the sense of a path from the given formatted path name, if possible. If not possible, return SENSE_GENERIC.
|
static |
Get the bounds embedded in the given formatted path name, or NO_SUBRANGE if they are absent. If no end position is stored, NO_END_POSITION may be returned for the end position.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
Separator used to separate path name components.