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

#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 NetGraphget_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...
 
GenomeStateCommandexecute (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 *, NetGraphnet_graphs
 We precompute all the net graphs and keep them around. More...
 
unordered_map< const Snarl *, SnarlStatestate
 We have a state for every snarl, which depends on the corresponding net graph. More...
 
const HandleGraphbacking_graph
 
const SnarlManagermanager
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GenomeState()

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.

Member Function Documentation

◆ append_haplotype()

DeleteHaplotypeCommand vg::GenomeState::append_haplotype ( const AppendHaplotypeCommand c)

Create a haplotype and return a command to delete it.

◆ count_haplotypes() [1/2]

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.

◆ count_haplotypes() [2/2]

size_t vg::GenomeState::count_haplotypes ( const Snarl snarl) const

Count the number of haplotypes within a given snarl.

◆ delete_haplotype()

InsertHaplotypeCommand vg::GenomeState::delete_haplotype ( const DeleteHaplotypeCommand c)

Delete a haplotype and return a command to insert it.

◆ dump()

void vg::GenomeState::dump ( ) const

Dump internal state to cerr.

◆ execute()

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?

◆ get_net_graph()

const NetGraph * vg::GenomeState::get_net_graph ( const Snarl snarl)

◆ insert_handles()

void vg::GenomeState::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

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.

◆ insert_haplotype()

DeleteHaplotypeCommand vg::GenomeState::insert_haplotype ( const InsertHaplotypeCommand c)

Insert a haplotype and return a command to delete it.

◆ replace_local_haplotype()

ReplaceLocalHaplotypeCommand vg::GenomeState::replace_local_haplotype ( const ReplaceLocalHaplotypeCommand c)

Replace part(s) of some haplotype(s) with other material.

◆ replace_snarl_haplotype()

ReplaceLocalHaplotypeCommand vg::GenomeState::replace_snarl_haplotype ( const ReplaceSnarlHaplotypeCommand c)

Replace part(s) of some haplotype(s) with other material.

◆ swap_haplotypes()

SwapHaplotypesCommand vg::GenomeState::swap_haplotypes ( const SwapHaplotypesCommand c)

Swap two haplotypes and return a command to swap them back.

◆ trace_haplotype()

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.

Member Data Documentation

◆ backing_graph

const HandleGraph* vg::GenomeState::backing_graph
protected

We remember the backing graph, because sometimes we need to translate from backing graph handles to IDs and orientations to look up snarls.

◆ manager

const SnarlManager& vg::GenomeState::manager
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.

◆ net_graphs

unordered_map<const Snarl*, NetGraph> vg::GenomeState::net_graphs
protected

We precompute all the net graphs and keep them around.

◆ state

unordered_map<const Snarl*, SnarlState> vg::GenomeState::state
protected

We have a state for every snarl, which depends on the corresponding net graph.

◆ telomeres

unordered_set<pair<const Snarl*, const Snarl*> > vg::GenomeState::telomeres
protected

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.


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