vg
tools for working with variation graphs
|
#include <genome_state.hpp>
Public Member Functions | |
void | dump () const |
Dump internal state to cerr. More... | |
GenomeState (const SnarlManager &manager, const HandleGraph *graph, const unordered_set< pair< const Snarl *, const Snarl * >> telomeres) | |
const NetGraph * | get_net_graph (const Snarl *snarl) |
DeleteHaplotypeCommand | append_haplotype (const AppendHaplotypeCommand &c) |
Create a haplotype and return a command to delete it. More... | |
SwapHaplotypesCommand | swap_haplotypes (const SwapHaplotypesCommand &c) |
Swap two haplotypes and return a command to swap them back. More... | |
ReplaceLocalHaplotypeCommand | replace_snarl_haplotype (const ReplaceSnarlHaplotypeCommand &c) |
Replace part(s) of some haplotype(s) with other material. More... | |
DeleteHaplotypeCommand | insert_haplotype (const InsertHaplotypeCommand &c) |
Insert a haplotype and return a command to delete it. More... | |
InsertHaplotypeCommand | delete_haplotype (const DeleteHaplotypeCommand &c) |
Delete a haplotype and return a command to insert it. More... | |
ReplaceLocalHaplotypeCommand | replace_local_haplotype (const ReplaceLocalHaplotypeCommand &c) |
Replace part(s) of some haplotype(s) with other material. More... | |
GenomeStateCommand * | execute (GenomeStateCommand *command) |
size_t | count_haplotypes (const pair< const Snarl *, const Snarl * > &telomere_pair) const |
size_t | count_haplotypes (const Snarl *snarl) const |
Count the number of haplotypes within a given snarl. More... | |
void | trace_haplotype (const pair< const Snarl *, const Snarl * > &telomere_pair, size_t overall_lane, const function< void(const handle_t &)> &iteratee) const |
Protected Member Functions | |
void | insert_handles (const vector< handle_t > &to_add, unordered_map< const Snarl *, vector< size_t >> &lanes_added, size_t top_lane=numeric_limits< size_t >::max()) |
Protected Attributes | |
unordered_set< pair< const Snarl *, const Snarl * > > | telomeres |
unordered_map< const Snarl *, NetGraph > | net_graphs |
We precompute all the net graphs and keep them around. More... | |
unordered_map< const Snarl *, SnarlState > | state |
We have a state for every snarl, which depends on the corresponding net graph. More... | |
const HandleGraph * | backing_graph |
const SnarlManager & | manager |
Define a way to represent a phased set of haplotypes on a graph that is under consideration as a variant calling solution.
There should only be one of these for any genotyping run; operations all mutate the single copy and, if you don't like the result, can be rolled back by doing the reverse mutation.
vg::GenomeState::GenomeState | ( | const SnarlManager & | manager, |
const HandleGraph * | graph, | ||
const unordered_set< pair< const Snarl *, const Snarl * >> | telomeres | ||
) |
Make a new GenomeState on the given SnarlManager, manageing snarls in the given graph, with the given telomere pairs. Each telomere can appear in only one pair.
DeleteHaplotypeCommand vg::GenomeState::append_haplotype | ( | const AppendHaplotypeCommand & | c | ) |
Create a haplotype and return a command to delete it.
size_t vg::GenomeState::count_haplotypes | ( | const pair< const Snarl *, const Snarl * > & | telomere_pair | ) | const |
Count the number of haplotypes connecting the given pair of telomeres. It must be a pair of telomeres actually passed during construction.
size_t vg::GenomeState::count_haplotypes | ( | const Snarl * | snarl | ) | const |
Count the number of haplotypes within a given snarl.
InsertHaplotypeCommand vg::GenomeState::delete_haplotype | ( | const DeleteHaplotypeCommand & | c | ) |
Delete a haplotype and return a command to insert it.
void vg::GenomeState::dump | ( | ) | const |
Dump internal state to cerr.
GenomeStateCommand * vg::GenomeState::execute | ( | GenomeStateCommand * | command | ) |
Execute a command. Return a new heap-allocated command that undoes the command being executed. Frees the passed command. TODO: does that make sense?
|
protected |
We have a generic stack-based handle-vector-to-per-snarl-haplotypes insertion walker function. The handles to add have to span one or more entire snarls, and we specify the lane in the spanned snarls to put them in.
DeleteHaplotypeCommand vg::GenomeState::insert_haplotype | ( | const InsertHaplotypeCommand & | c | ) |
Insert a haplotype and return a command to delete it.
ReplaceLocalHaplotypeCommand vg::GenomeState::replace_local_haplotype | ( | const ReplaceLocalHaplotypeCommand & | c | ) |
Replace part(s) of some haplotype(s) with other material.
ReplaceLocalHaplotypeCommand vg::GenomeState::replace_snarl_haplotype | ( | const ReplaceSnarlHaplotypeCommand & | c | ) |
Replace part(s) of some haplotype(s) with other material.
SwapHaplotypesCommand vg::GenomeState::swap_haplotypes | ( | const SwapHaplotypesCommand & | c | ) |
Swap two haplotypes and return a command to swap them back.
void vg::GenomeState::trace_haplotype | ( | const pair< const Snarl *, const Snarl * > & | telomere_pair, |
size_t | overall_lane, | ||
const function< void(const handle_t &)> & | iteratee | ||
) | const |
Trace the haplotype starting at the given start telomere snarl with the given overall lane. Calls the callback with each backing HandleGraph handle.
|
protected |
We remember the backing graph, because sometimes we need to translate from backing graph handles to IDs and orientations to look up snarls.
|
protected |
We keep a reference to the SnarlManager that knows what children are where and which snarl we should look at next after leaving a previous snarl.
We precompute all the net graphs and keep them around.
|
protected |
We have a state for every snarl, which depends on the corresponding net graph.
We keep track of pairs of telomere snarls. The haplotypes we work on connect a left telomere and its corresponding right telomere. We can traverse the snarl decomposition from one telomere to the other either following chains or pollowing paths inside of some snarl we are in. The start snarl of a pair must be in its local forward orientation.