vg
tools for working with variation graphs
Public Types | Public Member Functions | Public Attributes | List of all members
vg::Haplotypes::Subchain Struct Reference

#include <recombinator_haplotypes.hpp>

Public Types

enum  subchain_t : std::uint64_t { normal = 0 , prefix = 1 , suffix = 2 , full_haplotype = 3 }
 Subchain types. More...
 
typedef gbwtgraph::Key64::value_type kmer_type
 An encoded kmer. More...
 

Public Member Functions

void for_each_kmer (size_t sequence, const std::function< void(size_t, bool)> &callback) const
 
void score_sequences (const std::vector< std::pair< KmerPresenceMatrix::kmer_classification, double >> &kmers, const std::function< void(size_t, double)> &haplotype_score) const
 
std::int64_t diploid_score (size_t first, size_t second, const std::vector< std::pair< KmerPresenceMatrix::kmer_classification, double >> &kmers) const
 
size_t num_sequences () const
 Returns the number of haplotype sequences in the subchain. More...
 
size_t num_kmers () const
 Returns the number of kmers in the subchain. More...
 
size_t num_present (size_t i) const
 Returns the number of kmers present in the given sequence. More...
 
size_t total_kmers () const
 Returns the size of the kmer presence matrix. More...
 
size_t total_present () const
 Returns the total number of kmers present in the sequences. More...
 
handle_t start_handle () const
 Returns the start node as a GBWTGraph handle. More...
 
handle_t end_handle () const
 Returns the end node as a GBWTGraph handle. More...
 
bool has_start () const
 Returns true if the subchain has a start node. More...
 
bool has_end () const
 Returns true if the subchain has an end node. More...
 
std::string to_string () const
 Returns a string representation of the type and the boundary nodes. More...
 
sequence_type get_sequence (size_t i) const
 Returns (sequence identifier, offset in a node) for the given sequence. More...
 
size_t distance (const gbwtgraph::GBZ &gbz, size_t i) const
 
double badness (const gbwtgraph::GBZ &gbz) const
 
void simple_sds_serialize (std::ostream &out) const
 Serializes the object to a stream in the Simple-SDS format. More...
 
void simple_sds_load (std::istream &in, std::uint32_t version=Header::VERSION)
 
size_t simple_sds_size () const
 Returns the size of the object in elements. More...
 

Public Attributes

subchain_t type
 The type of this subchain. More...
 
gbwt::node_type start
 Boundary nodes, or gbwt::ENDMARKER if not present. More...
 
gbwt::node_type end
 
size_t placeholder
 Placeholder for a scoring model override. More...
 
std::vector< kmer_type > kmers
 
sdsl::int_vector< 0 > kmer_counts
 Number of sequences each kmer appears in. More...
 
std::vector< compact_sequence_type > sequences
 Sequences as (GBWT sequence id, offset in the relevant node). More...
 
KmerPresenceMatrix kmers_present
 A matrix indicating which kmers are present in which sequences. More...
 

Detailed Description

Representation of a subchain. The subchain contains num_sequences() haplotype sequences and num_kmers() kmers.

Member Typedef Documentation

◆ kmer_type

typedef gbwtgraph::Key64::value_type vg::Haplotypes::Subchain::kmer_type

An encoded kmer.

Member Enumeration Documentation

◆ subchain_t

Subchain types.

Enumerator
normal 

Normal subchain with two boundary nodes.

prefix 

A prefix with only an end node.

suffix 

A suffix with only a start node.

full_haplotype 

A full haplotype with no boundary nodes.

Member Function Documentation

◆ badness()

double vg::Haplotypes::Subchain::badness ( const gbwtgraph::GBZ &  gbz) const

Returns an estimate of the badness of the subchain. The ideal value is 0.0, and higher values indicate worse subchains. The estimate is based on the following factors:

  • Length of the subchain.
  • Number of haplotypes relative to the expected number.
  • Information content of the kmers (disabled).

◆ diploid_score()

std::int64_t vg::Haplotypes::Subchain::diploid_score ( size_t  first,
size_t  second,
const std::vector< std::pair< KmerPresenceMatrix::kmer_classification, double >> &  kmers 
) const
inline

Scores a pair of sequences in the subchain. The score is the sum of 1 - abs(expected - observed) over the kmers.

◆ distance()

size_t vg::Haplotypes::Subchain::distance ( const gbwtgraph::GBZ &  gbz,
size_t  i 
) const

Returns the distance from the last base of start to the first base of end over the given sequence. Returns 0 if the subchain is not normal or if the sequence does not exist.

◆ end_handle()

handle_t vg::Haplotypes::Subchain::end_handle ( ) const
inline

Returns the end node as a GBWTGraph handle.

◆ for_each_kmer()

void vg::Haplotypes::Subchain::for_each_kmer ( size_t  sequence,
const std::function< void(size_t, bool)> &  callback 
) const
inline

Calls callback(kmer_id, is_present) for each kmer in the given sequence, ordered by their indices.

◆ get_sequence()

sequence_type vg::Haplotypes::Subchain::get_sequence ( size_t  i) const
inline

Returns (sequence identifier, offset in a node) for the given sequence.

◆ has_end()

bool vg::Haplotypes::Subchain::has_end ( ) const
inline

Returns true if the subchain has an end node.

◆ has_start()

bool vg::Haplotypes::Subchain::has_start ( ) const
inline

Returns true if the subchain has a start node.

◆ num_kmers()

size_t vg::Haplotypes::Subchain::num_kmers ( ) const
inline

Returns the number of kmers in the subchain.

◆ num_present()

size_t vg::Haplotypes::Subchain::num_present ( size_t  i) const
inline

Returns the number of kmers present in the given sequence.

◆ num_sequences()

size_t vg::Haplotypes::Subchain::num_sequences ( ) const
inline

Returns the number of haplotype sequences in the subchain.

◆ score_sequences()

void vg::Haplotypes::Subchain::score_sequences ( const std::vector< std::pair< KmerPresenceMatrix::kmer_classification, double >> &  kmers,
const std::function< void(size_t, double)> &  haplotype_score 
) const
inline

Scores every sequence in the subchain. The score of a sequence is the sum of (present : 1 : -1) * kmer.second over kmers. It is reported by calling sequence_score(sequence, score) in an arbitrary order.

◆ simple_sds_load()

void vg::Haplotypes::Subchain::simple_sds_load ( std::istream &  in,
std::uint32_t  version = Header::VERSION 
)

Loads the object from a stream in the Simple-SDS format. As there is no header, the expected version must be provided.

◆ simple_sds_serialize()

void vg::Haplotypes::Subchain::simple_sds_serialize ( std::ostream &  out) const

Serializes the object to a stream in the Simple-SDS format.

◆ simple_sds_size()

size_t vg::Haplotypes::Subchain::simple_sds_size ( ) const

Returns the size of the object in elements.

◆ start_handle()

handle_t vg::Haplotypes::Subchain::start_handle ( ) const
inline

Returns the start node as a GBWTGraph handle.

◆ to_string()

std::string vg::Haplotypes::Subchain::to_string ( ) const

Returns a string representation of the type and the boundary nodes.

◆ total_kmers()

size_t vg::Haplotypes::Subchain::total_kmers ( ) const
inline

Returns the size of the kmer presence matrix.

◆ total_present()

size_t vg::Haplotypes::Subchain::total_present ( ) const
inline

Returns the total number of kmers present in the sequences.

Member Data Documentation

◆ end

gbwt::node_type vg::Haplotypes::Subchain::end

◆ kmer_counts

sdsl::int_vector<0> vg::Haplotypes::Subchain::kmer_counts

Number of sequences each kmer appears in.

◆ kmers

std::vector<kmer_type> vg::Haplotypes::Subchain::kmers

A vector of distinct kmers. For each kmer, list the kmer itself and the number of sequences it appears in.

◆ kmers_present

KmerPresenceMatrix vg::Haplotypes::Subchain::kmers_present

A matrix indicating which kmers are present in which sequences.

◆ placeholder

size_t vg::Haplotypes::Subchain::placeholder

Placeholder for a scoring model override.

◆ sequences

std::vector<compact_sequence_type> vg::Haplotypes::Subchain::sequences

Sequences as (GBWT sequence id, offset in the relevant node).

◆ start

gbwt::node_type vg::Haplotypes::Subchain::start

Boundary nodes, or gbwt::ENDMARKER if not present.

◆ type

subchain_t vg::Haplotypes::Subchain::type

The type of this subchain.


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