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

#include <flow_caller.hpp>

Inheritance diagram for vg::FlowCaller:
vg::GraphCaller vg::GAFOutputCaller

Public Member Functions

 FlowCaller (const PathPositionHandleGraph &graph, SupportBasedSnarlCaller &snarl_caller, SnarlManager &snarl_manager, const string &sample_name, TraversalFinder &traversal_finder, const vector< string > &ref_paths, const vector< size_t > &ref_path_offsets, const vector< int > &ref_path_ploidies, AlignmentEmitter *aln_emitter, bool traversals_only, bool gaf_output, size_t trav_padding, bool genotype_snarls, const pair< size_t, size_t > &allele_length_range)
 Original constructor for non-nested mode. More...
 
 FlowCaller (const PathPositionHandleGraph &graph, SupportBasedSnarlCaller &snarl_caller, SnarlManager &snarl_manager, const string &sample_name, TraversalFinder &traversal_finder, const vector< string > &ref_paths, const vector< size_t > &ref_path_offsets, const vector< int > &ref_path_ploidies, AlignmentEmitter *aln_emitter, bool traversals_only, bool gaf_output, size_t trav_padding, bool genotype_snarls, const pair< size_t, size_t > &allele_length_range, bool nested, bool star_allele)
 Extended constructor for nested mode with star alleles. More...
 
virtual ~FlowCaller ()
 
bool call_snarl (const Snarl &snarl) override
 Call a given snarl, and print the output to out_stream. More...
 
void set_max_snarl_edges (size_t edges)
 
- Public Member Functions inherited from vg::GraphCaller
 GraphCaller (SnarlCaller &snarl_caller, SnarlManager &snarl_manager)
 
virtual ~GraphCaller ()
 
virtual void call_top_level_snarls (const HandleGraph &graph, RecurseType recurse_type=RecurseOnFail)
 
virtual void call_top_level_chains (const HandleGraph &graph, size_t max_edges, size_t max_trivial, RecurseType recurise_type=RecurseOnFail)
 
void set_show_progress (bool show_progress)
 toggle progress messages More...
 
void set_snarl_batching (size_t window_size)
 
void set_ploidy_regions (PloidyRegions regions)
 
- Public Member Functions inherited from vg::GAFOutputCaller
 GAFOutputCaller (AlignmentEmitter *emitter, const string &sample_name, const vector< string > &ref_paths, size_t trav_padding)
 The emitter object is created and owned by external forces. More...
 
virtual ~GAFOutputCaller ()
 
void emit_gaf_traversals (const PathHandleGraph &graph, const string &snarl_name, const vector< SnarlTraversal > &travs, int64_t ref_trav_idx, const string &ref_path_name, int64_t ref_path_position, const TraversalSupportFinder *support_finder=nullptr)
 print the GAF traversals More...
 
void emit_gaf_variant (const PathHandleGraph &graph, const string &snarl_name, const vector< SnarlTraversal > &travs, const vector< int > &genotype, int64_t ref_trav_idx, const string &ref_path_name, int64_t ref_path_position, const TraversalSupportFinder *support_finder=nullptr)
 print the GAF genotype More...
 
SnarlTraversal pad_traversal (const PathHandleGraph &graph, const SnarlTraversal &trav) const
 pad a traversal with (first found) reference path, adding up to trav_padding to each side More...
 

Public Attributes

SortedVCFWriter vcf_writer
 The sorted VCF the records go to. More...
 
SiteEmitter site_emitter
 Writes the record of each called site into vcf_writer. More...
 

Protected Member Functions

bool call_snarl_internal (const Snarl &snarl, const string &parent_ref_path_name, pair< size_t, size_t > parent_ref_interval, const vector< TraversalSet > *parent_child_trav_sets=nullptr)
 
vector< int > genotype_from_parent_sets (CandidateFinder::Site &site, const vector< TraversalSet > &parent_sets, unique_ptr< SnarlCaller::CallInfo > &call_info)
 
bool emit_site (const CandidateFinder::Site &site, const vector< int > &genotype, const unique_ptr< SnarlCaller::CallInfo > &call_info, int ploidy)
 
void call_children (const CandidateFinder::Site &site, const vector< int > &genotype)
 
vector< TraversalSet > child_traversal_sets (const CandidateFinder::Site &site, const vector< int > &genotype, const Snarl &child) const
 
- Protected Member Functions inherited from vg::GraphCaller
vector< Chain > break_chain (const HandleGraph &graph, const Chain &chain, size_t max_edges, size_t max_trivial) const
 Break up a chain into bits that we want to call using size heuristics. More...
 

Protected Attributes

const PathPositionHandleGraph & graph
 the graph More...
 
TraversalFinder & traversal_finder
 the traversal finder More...
 
vector< string > ref_paths
 keep track of the reference paths More...
 
unordered_set< string > ref_path_set
 
map< string, size_t > ref_offsets
 keep track of offsets in the reference paths More...
 
map< string, int > ref_ploidies
 keep traco of the ploidies (todo: just one map for all path stuff!!) More...
 
AlignmentEmitter * alignment_emitter
 
bool traversals_only
 toggle whether to genotype or just output the traversals More...
 
bool gaf_output
 toggle whether to output vcf or gaf More...
 
bool genotype_snarls
 
pair< size_t, size_t > allele_length_range
 
bool nested = false
 — Nested mode members — More...
 
bool star_allele = false
 use * alleles for spanning haplotypes that don't traverse nested sites More...
 
CandidateFinder candidates
 
- Protected Attributes inherited from vg::GraphCaller
SnarlCaller & snarl_caller
 Our Genotyper. More...
 
SnarlManager & snarl_manager
 Our snarls. More...
 
size_t snarl_batch_window = 0
 
bool show_progress
 Toggle progress messages. More...
 
PloidyRegions ploidy_regions
 The ploidy of regions of the reference, which overrides the ploidy of their paths. More...
 
- Protected Attributes inherited from vg::GAFOutputCaller
AlignmentEmitter * emitter
 
string gaf_sample_name
 Sample name. More...
 
size_t trav_padding = 0
 
unordered_set< string > ref_paths
 Reference paths are used to pad out traversals. If there are none, then first path found is used. More...
 

Additional Inherited Members

- Public Types inherited from vg::GraphCaller
using RecurseType = vg::RecurseType
 
- Static Public Attributes inherited from vg::GraphCaller
static constexpr RecurseType RecurseOnFail = RecurseType::OnFail
 
static constexpr RecurseType RecurseAlways = RecurseType::Always
 
static constexpr RecurseType RecurseNever = RecurseType::Never
 

Detailed Description

FlowCaller : Uses any traversals finder (ex, FlowTraversalFinder) to find traversals, and calls those based on how much support they have. Should work on any graph but will not report cyclic traversals. Supports nested calling when enabled with the nested flag, recursively processing child snarls. Designed to replace LegacyCaller, as it should miss fewer obviously good traversals, and is not dependent on old protobuf-based structures.

Constructor & Destructor Documentation

◆ FlowCaller() [1/2]

vg::FlowCaller::FlowCaller ( const PathPositionHandleGraph &  graph,
SupportBasedSnarlCaller &  snarl_caller,
SnarlManager &  snarl_manager,
const string &  sample_name,
TraversalFinder &  traversal_finder,
const vector< string > &  ref_paths,
const vector< size_t > &  ref_path_offsets,
const vector< int > &  ref_path_ploidies,
AlignmentEmitter *  aln_emitter,
bool  traversals_only,
bool  gaf_output,
size_t  trav_padding,
bool  genotype_snarls,
const pair< size_t, size_t > &  allele_length_range 
)

Original constructor for non-nested mode.

◆ FlowCaller() [2/2]

vg::FlowCaller::FlowCaller ( const PathPositionHandleGraph &  graph,
SupportBasedSnarlCaller &  snarl_caller,
SnarlManager &  snarl_manager,
const string &  sample_name,
TraversalFinder &  traversal_finder,
const vector< string > &  ref_paths,
const vector< size_t > &  ref_path_offsets,
const vector< int > &  ref_path_ploidies,
AlignmentEmitter *  aln_emitter,
bool  traversals_only,
bool  gaf_output,
size_t  trav_padding,
bool  genotype_snarls,
const pair< size_t, size_t > &  allele_length_range,
bool  nested,
bool  star_allele 
)

Extended constructor for nested mode with star alleles.

◆ ~FlowCaller()

vg::FlowCaller::~FlowCaller ( )
virtual

Member Function Documentation

◆ call_children()

void vg::FlowCaller::call_children ( const CandidateFinder::Site &  site,
const vector< int > &  genotype 
)
protected

Call each child of a genotyped site that an allele of the genotype visits, from the traversals of the alleles.

◆ call_snarl()

bool vg::FlowCaller::call_snarl ( const Snarl &  snarl)
overridevirtual

Call a given snarl, and print the output to out_stream.

Implements vg::GraphCaller.

◆ call_snarl_internal()

bool vg::FlowCaller::call_snarl_internal ( const Snarl &  snarl,
const string &  parent_ref_path_name,
pair< size_t, size_t >  parent_ref_interval,
const vector< TraversalSet > *  parent_child_trav_sets = nullptr 
)
protected

Internal implementation of call_snarl that accepts parent context for nested mode When nested=true, this recursively calls children after processing the current snarl

Parameters
parent_ref_path_nameReference path from parent (for off-reference snarls)
parent_ref_intervalReference interval from parent
parent_child_trav_setsIf non-null, contains one TraversalSet per parent allele. Each set contains all traversals through this child that are consistent with that parent allele. The child genotypes by picking the best pair (one from each set) based on read support.

◆ child_traversal_sets()

vector< TraversalSet > vg::FlowCaller::child_traversal_sets ( const CandidateFinder::Site &  site,
const vector< int > &  genotype,
const Snarl &  child 
) const
protected

Return, for each strand of the genotype of a site, the traversals of child that agree with the traversal of its allele. A star or missing allele gets an empty set.

◆ emit_site()

bool vg::FlowCaller::emit_site ( const CandidateFinder::Site &  site,
const vector< int > &  genotype,
const unique_ptr< SnarlCaller::CallInfo > &  call_info,
int  ploidy 
)
protected

Write the record of a genotyped site, as VCF or as GAF.

Returns
false only if the VCF writer refused the record.

◆ genotype_from_parent_sets()

vector< int > vg::FlowCaller::genotype_from_parent_sets ( CandidateFinder::Site &  site,
const vector< TraversalSet > &  parent_sets,
unique_ptr< SnarlCaller::CallInfo > &  call_info 
)
protected

Genotype a nested site from the traversal sets that its parent's genotype gives it.

We add the traversals of the sets to the candidates of the site, and genotype the strands whose set is not empty. The other strands get a star allele, or a missing one without star_allele.

Parameters
parent_setsOne traversal set per strand of the parent's genotype.
call_infoSet to the snarl caller's information about the call, if it was asked for one.
Returns
One allele per strand.

◆ set_max_snarl_edges()

void vg::FlowCaller::set_max_snarl_edges ( size_t  edges)

Skip snarls with more edges than this, counting those of nested snarls.

call_top_level_snarls then calls the children of a skipped snarl as if they were top-level snarls. Zero, the default, removes the limit.

Member Data Documentation

◆ alignment_emitter

AlignmentEmitter* vg::FlowCaller::alignment_emitter
protected

alignment emitter. if not null, traversals will be output here and no genotyping will be done

◆ allele_length_range

pair<size_t, size_t> vg::FlowCaller::allele_length_range
protected

clamp calling to alleles of a given length range more specifically, a snarl is only called if 1) its largest allele is >= allele_length_range.first and 2) all alleles are < allele_length_range.second

◆ candidates

CandidateFinder vg::FlowCaller::candidates
protected

Finds the reference path and candidate traversals of each site. It is declared after the members it reads, so that they are built first.

◆ gaf_output

bool vg::FlowCaller::gaf_output
protected

toggle whether to output vcf or gaf

◆ genotype_snarls

bool vg::FlowCaller::genotype_snarls
protected

toggle whether to genotype every snarl (by default, uncalled snarls are skipped, and coordinates are flattened out to minimize variant size – this turns all that off)

◆ graph

const PathPositionHandleGraph& vg::FlowCaller::graph
protected

the graph

◆ nested

bool vg::FlowCaller::nested = false
protected

— Nested mode members —

enable recursive calling of child snarls

◆ ref_offsets

map<string, size_t> vg::FlowCaller::ref_offsets
protected

keep track of offsets in the reference paths

◆ ref_path_set

unordered_set<string> vg::FlowCaller::ref_path_set
protected

◆ ref_paths

vector<string> vg::FlowCaller::ref_paths
protected

keep track of the reference paths

◆ ref_ploidies

map<string, int> vg::FlowCaller::ref_ploidies
protected

keep traco of the ploidies (todo: just one map for all path stuff!!)

◆ site_emitter

SiteEmitter vg::FlowCaller::site_emitter

Writes the record of each called site into vcf_writer.

◆ star_allele

bool vg::FlowCaller::star_allele = false
protected

use * alleles for spanning haplotypes that don't traverse nested sites

◆ traversal_finder

TraversalFinder& vg::FlowCaller::traversal_finder
protected

the traversal finder

◆ traversals_only

bool vg::FlowCaller::traversals_only
protected

toggle whether to genotype or just output the traversals

◆ vcf_writer

SortedVCFWriter vg::FlowCaller::vcf_writer

The sorted VCF the records go to.


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