vg
tools for working with variation graphs
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Private Attributes | List of all members
handlegraph::PathMetadata Class Referenceabstract

#include <path_metadata.hpp>

Inheritance diagram for handlegraph::PathMetadata:
handlegraph::MutablePathMetadata handlegraph::PathHandleGraph handlegraph::MutablePathHandleGraph handlegraph::MutablePathHandleGraph handlegraph::PathPositionHandleGraph vg::PathSubgraphOverlay handlegraph::MutablePathMutableHandleGraph handlegraph::MutablePathMutableHandleGraph vg::MemoizingGraph xg::XG handlegraph::MutablePathDeletableHandleGraph handlegraph::MutablePathDeletableHandleGraph vg::VG vg::VG

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_sense (const std::unordered_set< PathSense > &senses, 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_of_sample (const std::unordered_set< std::string > &samples, 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
 
template<typename Iteratee >
bool for_each_step_of_sense (const handle_t &visited, const std::unordered_set< PathSense > &senses, 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 bool for_each_step_of_sense_impl (const handle_t &visited, const std::unordered_set< PathSense > &senses, 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 = ']'
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ ~PathMetadata()

virtual handlegraph::PathMetadata::~PathMetadata ( )
virtualdefault

Member Function Documentation

◆ create_path_name()

std::string handlegraph::PathMetadata::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

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.).

◆ for_each_path_handle_impl()

virtual bool handlegraph::PathMetadata::for_each_path_handle_impl ( const std::function< bool(const path_handle_t &)> &  iteratee) const
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.

Implemented in handlegraph::PathHandleGraph, vg::PathSubgraphOverlay, vg::MemoizingGraph, and xg::XG.

◆ for_each_path_matching() [1/2]

template<typename Iteratee >
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.

◆ for_each_path_matching() [2/2]

template<typename Iteratee >
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.

◆ for_each_path_matching_impl()

bool handlegraph::PathMetadata::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
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.

◆ for_each_path_of_sample() [1/2]

template<typename Iteratee >
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.

◆ for_each_path_of_sample() [2/2]

template<typename Iteratee >
bool handlegraph::PathMetadata::for_each_path_of_sample ( const std::unordered_set< std::string > &  samples,
const Iteratee &  iteratee 
) const

Loop through all the paths with any of the given sample names. Returns false and stops if the iteratee returns false.

◆ for_each_path_of_sense() [1/2]

template<typename Iteratee >
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.

◆ for_each_path_of_sense() [2/2]

template<typename Iteratee >
bool handlegraph::PathMetadata::for_each_path_of_sense ( const std::unordered_set< PathSense > &  senses,
const Iteratee &  iteratee 
) const

Loop through all the paths with any of the given senses. Returns false and stops if the iteratee returns false.

◆ for_each_step_of_sense() [1/2]

template<typename Iteratee >
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?

◆ for_each_step_of_sense() [2/2]

template<typename Iteratee >
bool handlegraph::PathMetadata::for_each_step_of_sense ( const handle_t visited,
const std::unordered_set< PathSense > &  senses,
const Iteratee &  iteratee 
) const

Loop through all steps on the given handle for paths with any of the given senses. Returns false and stops if the iteratee returns false.

◆ for_each_step_of_sense_impl() [1/2]

bool handlegraph::PathMetadata::for_each_step_of_sense_impl ( const handle_t visited,
const PathSense sense,
const std::function< bool(const step_handle_t &)> &  iteratee 
) const
protectedvirtual

Loop through all steps on the given handle for paths with the given sense. Returns false and stops if the iteratee returns false.

◆ for_each_step_of_sense_impl() [2/2]

bool handlegraph::PathMetadata::for_each_step_of_sense_impl ( const handle_t visited,
const std::unordered_set< PathSense > &  senses,
const std::function< bool(const step_handle_t &)> &  iteratee 
) const
protectedvirtual

Loop through all steps on the given handle for paths with any of the given senses. Returns false and stops if the iteratee returns false.

◆ for_each_step_on_handle_impl()

virtual bool handlegraph::PathMetadata::for_each_step_on_handle_impl ( const handle_t handle,
const std::function< bool(const step_handle_t &)> &  iteratee 
) const
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.

Implemented in handlegraph::PathHandleGraph, vg::PathSubgraphOverlay, vg::MemoizingGraph, and xg::XG.

◆ get_haplotype()

size_t handlegraph::PathMetadata::get_haplotype ( const path_handle_t handle) const
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.

◆ get_locus_name()

std::string handlegraph::PathMetadata::get_locus_name ( const path_handle_t handle) const
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.

◆ get_path_handle_of_step()

virtual path_handle_t handlegraph::PathMetadata::get_path_handle_of_step ( const step_handle_t step_handle) const
protectedpure virtual

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

Implemented in handlegraph::PathHandleGraph, vg::VG, vg::PathSubgraphOverlay, vg::MemoizingGraph, and xg::XG.

◆ get_path_name()

virtual std::string handlegraph::PathMetadata::get_path_name ( const path_handle_t path_handle) const
protectedpure virtual

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

Implemented in handlegraph::PathHandleGraph, vg::VG, vg::PathSubgraphOverlay, vg::MemoizingGraph, and xg::XG.

◆ get_phase_block()

size_t handlegraph::PathMetadata::get_phase_block ( const path_handle_t handle) const
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.

◆ get_sample_name()

std::string handlegraph::PathMetadata::get_sample_name ( const path_handle_t handle) const
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.

◆ get_sense()

PathSense handlegraph::PathMetadata::get_sense ( const path_handle_t handle) const
virtual

What is the given path meant to be representing?

◆ get_subrange()

subrange_t handlegraph::PathMetadata::get_subrange ( const path_handle_t handle) const
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.

◆ parse_haplotype()

size_t handlegraph::PathMetadata::parse_haplotype ( const std::string &  path_name)
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.

◆ parse_locus_name()

std::string handlegraph::PathMetadata::parse_locus_name ( const std::string &  path_name)
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.

◆ parse_path_name()

void handlegraph::PathMetadata::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 
)
static

Decompose a formatted path name into metadata.

◆ parse_phase_block()

size_t handlegraph::PathMetadata::parse_phase_block ( const std::string &  path_name)
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.

◆ parse_sample_name()

std::string handlegraph::PathMetadata::parse_sample_name ( const std::string &  path_name)
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.

◆ parse_sense()

PathSense handlegraph::PathMetadata::parse_sense ( const std::string &  path_name)
static

Extract the sense of a path from the given formatted path name, if possible. If not possible, return SENSE_GENERIC.

◆ parse_subrange()

subrange_t handlegraph::PathMetadata::parse_subrange ( const std::string &  path_name)
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.

Member Data Documentation

◆ ASSEMBLY_OR_NAME_MATCH

const size_t handlegraph::PathMetadata::ASSEMBLY_OR_NAME_MATCH = 1
staticprivate

◆ FORMAT

const std::regex handlegraph::PathMetadata::FORMAT
staticprivate

◆ HAPLOTYPE_MATCH

const size_t handlegraph::PathMetadata::HAPLOTYPE_MATCH = 2
staticprivate

◆ LOCUS_MATCH_ANY

const size_t handlegraph::PathMetadata::LOCUS_MATCH_ANY = 3
staticprivate

◆ LOCUS_MATCH_NUMERICAL_WITHOUT_HAPLOTYPE

const size_t handlegraph::PathMetadata::LOCUS_MATCH_NUMERICAL_WITHOUT_HAPLOTYPE = 2
staticprivate

◆ NO_END_POSITION

const offset_t handlegraph::PathMetadata::NO_END_POSITION = std::numeric_limits<offset_t>::max()
static

◆ NO_HAPLOTYPE

const size_t handlegraph::PathMetadata::NO_HAPLOTYPE = std::numeric_limits<size_t>::max()
static

◆ NO_LOCUS_NAME

const std::string handlegraph::PathMetadata::NO_LOCUS_NAME = ""
static

◆ NO_PHASE_BLOCK

const size_t handlegraph::PathMetadata::NO_PHASE_BLOCK = std::numeric_limits<size_t>::max()
static

◆ NO_SAMPLE_NAME

const std::string handlegraph::PathMetadata::NO_SAMPLE_NAME = ""
static

◆ NO_SUBRANGE

const subrange_t handlegraph::PathMetadata::NO_SUBRANGE {PathMetadata::NO_END_POSITION, PathMetadata::NO_END_POSITION}
static

◆ PHASE_BLOCK_MATCH

const size_t handlegraph::PathMetadata::PHASE_BLOCK_MATCH = 4
staticprivate

◆ RANGE_END_MATCH

const size_t handlegraph::PathMetadata::RANGE_END_MATCH = 6
staticprivate

◆ RANGE_END_SEPARATOR

const char handlegraph::PathMetadata::RANGE_END_SEPARATOR = '-'
staticprivate

◆ RANGE_START_MATCH

const size_t handlegraph::PathMetadata::RANGE_START_MATCH = 5
staticprivate

◆ RANGE_START_SEPARATOR

const char handlegraph::PathMetadata::RANGE_START_SEPARATOR = '['
staticprivate

◆ RANGE_TERMINATOR

const char handlegraph::PathMetadata::RANGE_TERMINATOR = ']'
staticprivate

◆ SEPARATOR

const char handlegraph::PathMetadata::SEPARATOR = '#'
staticprivate

Separator used to separate path name components.


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