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

#include <phased_genome.hpp>

Classes

class  Haplotype
 
struct  HaplotypeNode
 
class  iterator
 

Public Member Functions

 PhasedGenome (const SnarlManager &snarl_manager)
 Constructor. More...
 
 ~PhasedGenome ()
 
 PhasedGenome (PhasedGenome &phased_genome)
 overloaded constructor More...
 
 PhasedGenome (PhasedGenome &&other)=delete
 move assignment ctor More...
 
PhasedGenomeoperator= (PhasedGenome &&phased_genome)=delete
 move assignment operator More...
 
PhasedGenomeoperator= (PhasedGenome &phased_genome)
 copy assignment operator More...
 
template<typename NodeTraversalIterator >
int add_haplotype (NodeTraversalIterator first, NodeTraversalIterator last)
 
void build_indices ()
 
size_t num_haplotypes ()
 
iterator begin (int which_haplotype)
 
iterator end (int which_haplotype)
 
vector< id_tget_haplotypes_with_snarl (const Snarl *snarl_to_find)
 Check which haplotypes a snarl is found in. More...
 
void print_phased_genome ()
 Prints out the haplotypes, and node values. More...
 
void swap_alleles (const Snarl &site, int haplotype_1, int haplotype_2)
 
template<typename NodeTraversalIterator >
void set_allele (const Snarl &site, NodeTraversalIterator first, NodeTraversalIterator last, int which_haplotype)
 
vector< NodeTraversalget_allele (const Snarl &site, int which_haplotype)
 
int32_t optimal_score_on_genome (const multipath_alignment_t &multipath_aln, VG &graph)
 
double read_log_likelihood (const multipath_alignment_t &multipath_aln, double log_base)
 

Private Member Functions

void build_site_indices_internal (const Snarl *snarl)
 
void insert_left (NodeTraversal node_traversal, HaplotypeNode *haplo_node)
 Insert a node traversal to the left of this haplotype node and update indices. More...
 
void insert_right (NodeTraversal node_traversal, HaplotypeNode *haplo_node)
 Insert a node traversal to the right of this haplotype node and update indices. More...
 
void remove (HaplotypeNode *haplo_node)
 Remove this haplotype node from its haplotype and update indices. More...
 
void swap_label (const Snarl &site, Haplotype &haplotype_1, Haplotype &haplotype_2)
 Update a subsite's location in indices after swapping its parent allele. More...
 

Private Attributes

const SnarlManagersnarl_manager
 
vector< Haplotype * > haplotypes
 All haplotypes in the genome (generally 2 per chromosome) More...
 
unordered_map< int64_t, list< HaplotypeNode * > > node_locations
 Index of where nodes from the graph occur in the phased genome. More...
 
unordered_map< int64_t, const Snarl * > site_starts
 Index of which nodes are starts of Snarls. More...
 
unordered_map< int64_t, const Snarl * > site_ends
 Index of which nodes are ends of Snarls. More...
 

Detailed Description

A collection of haplotypes that represent all of the chromosomes of a genome (including phasing) as walks through a variation graph. Designed for fast editing at a site level, so it maintains indices of sites for that purpose.

Constructor & Destructor Documentation

◆ PhasedGenome() [1/3]

vg::PhasedGenome::PhasedGenome ( const SnarlManager snarl_manager)

◆ ~PhasedGenome()

vg::PhasedGenome::~PhasedGenome ( )

◆ PhasedGenome() [2/3]

vg::PhasedGenome::PhasedGenome ( PhasedGenome phased_genome)

overloaded constructor

◆ PhasedGenome() [3/3]

vg::PhasedGenome::PhasedGenome ( PhasedGenome &&  other)
delete

move assignment ctor

Member Function Documentation

◆ add_haplotype()

template<typename NodeTraversalIterator >
int vg::PhasedGenome::add_haplotype ( NodeTraversalIterator  first,
NodeTraversalIterator  last 
)

Build a haplotype in place from an iterator that returns NodeTraversal objects from its dereference operator (allows construction without instantiating the haplotype elsewhere) returns the numerical id of the new haplotype

note: the haplotype must have at least one node

◆ begin()

PhasedGenome::iterator vg::PhasedGenome::begin ( int  which_haplotype)

Unidirectional iterator starting at the left telomere and moving to the right. Requires a haplotype id as input

◆ build_indices()

void vg::PhasedGenome::build_indices ( )

Construct the site ends, node locations, and haplotype site location indices. This method is intended to be called one time after building haplotypes. After this, the are maintained automatically during edit operations.

◆ build_site_indices_internal()

void vg::PhasedGenome::build_site_indices_internal ( const Snarl snarl)
private

◆ end()

PhasedGenome::iterator vg::PhasedGenome::end ( int  which_haplotype)

Iterator representing the past-the-last position of the given haplotype, with the last position being the right telomere node.

◆ get_allele()

vector< NodeTraversal > vg::PhasedGenome::get_allele ( const Snarl site,
int  which_haplotype 
)

Returns a vector of node traversals representing the allele at the indicated site on the indicated haplotype. The allele is returned in the orientation of the Snarl (start to end), not necessarily the orientation on the haplotype. The start and end nodes of the Snarl are not included in the allele.

◆ get_haplotypes_with_snarl()

vector< id_t > vg::PhasedGenome::get_haplotypes_with_snarl ( const Snarl snarl_to_find)

Check which haplotypes a snarl is found in.

◆ insert_left()

void vg::PhasedGenome::insert_left ( NodeTraversal  node_traversal,
HaplotypeNode haplo_node 
)
inlineprivate

Insert a node traversal to the left of this haplotype node and update indices.

◆ insert_right()

void vg::PhasedGenome::insert_right ( NodeTraversal  node_traversal,
HaplotypeNode haplo_node 
)
inlineprivate

Insert a node traversal to the right of this haplotype node and update indices.

◆ num_haplotypes()

size_t vg::PhasedGenome::num_haplotypes ( )

◆ operator=() [1/2]

PhasedGenome& vg::PhasedGenome::operator= ( PhasedGenome &&  phased_genome)
delete

move assignment operator

◆ operator=() [2/2]

PhasedGenome & vg::PhasedGenome::operator= ( PhasedGenome phased_genome)

copy assignment operator

◆ optimal_score_on_genome()

int32_t vg::PhasedGenome::optimal_score_on_genome ( const multipath_alignment_t multipath_aln,
VG graph 
)

Returns the score of the highest scoring alignment contained in the multipath alignment that is restricted to the phased genome's paths through the variation graph.

Note: assumes that multipath_alignment_t has 'start' field filled in

◆ print_phased_genome()

void vg::PhasedGenome::print_phased_genome ( )

Prints out the haplotypes, and node values.

◆ read_log_likelihood()

double vg::PhasedGenome::read_log_likelihood ( const multipath_alignment_t multipath_aln,
double  log_base 
)

Returns the sum of the log-likelihoods of all of the alignments expressed in a multipath alignment, given a

◆ remove()

void vg::PhasedGenome::remove ( HaplotypeNode haplo_node)
inlineprivate

Remove this haplotype node from its haplotype and update indices.

◆ set_allele()

template<typename NodeTraversalIterator >
void vg::PhasedGenome::set_allele ( const Snarl site,
NodeTraversalIterator  first,
NodeTraversalIterator  last,
int  which_haplotype 
)

Set the allele at a site with an iterator that yields its node sequence. The allele should be provided in the order indicated by the Snarl (i.e. from start to end) and it should not include the boundary nodes of the Snarl.

Note: This method does not check that the allele path takes only edges that are actually included in the graph, so client must ensure this itself.

◆ swap_alleles()

void vg::PhasedGenome::swap_alleles ( const Snarl site,
int  haplotype_1,
int  haplotype_2 
)

Swap the allele from between two haplotypes, maintaining all indices. If a nested site is being swapped, this method should be called only once for the top-most site. Child sites are swapped along with the top-most site automatically.

◆ swap_label()

void vg::PhasedGenome::swap_label ( const Snarl site,
Haplotype haplotype_1,
Haplotype haplotype_2 
)
private

Update a subsite's location in indices after swapping its parent allele.

Member Data Documentation

◆ haplotypes

vector<Haplotype*> vg::PhasedGenome::haplotypes
private

All haplotypes in the genome (generally 2 per chromosome)

◆ node_locations

unordered_map<int64_t, list<HaplotypeNode*> > vg::PhasedGenome::node_locations
private

Index of where nodes from the graph occur in the phased genome.

◆ site_ends

unordered_map<int64_t, const Snarl*> vg::PhasedGenome::site_ends
private

Index of which nodes are ends of Snarls.

◆ site_starts

unordered_map<int64_t, const Snarl*> vg::PhasedGenome::site_starts
private

Index of which nodes are starts of Snarls.

◆ snarl_manager

const SnarlManager* vg::PhasedGenome::snarl_manager
private

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