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

#include <sampler.hpp>

Inheritance diagram for vg::Sampler:
vg::AbstractReadSampler

Public Member Functions

 Sampler (PathPositionHandleGraph *x, int seed=0, bool forward_only=false, bool allow_Ns=false, const vector< string > &source_paths={}, const vector< double > &source_path_ploidies={}, const vector< pair< string, double >> &transcript_expressions={}, const vector< tuple< string, string, size_t >> &haplotype_transcripts={})
 
Alignment sample_read ()
 
pair< Alignment, Alignmentsample_read_pair ()
 
void set_source_paths (const vector< string > &source_paths, const vector< double > &source_path_ploidies, const vector< pair< string, double >> &transcript_expressions, const vector< tuple< string, string, size_t >> &haplotype_transcripts)
 
pos_t position (void)
 
string sequence (size_t length)
 
Alignment alignment (size_t length)
 
Alignment alignment_to_graph (size_t length)
 Get an alignment against the whole graph. More...
 
Alignment alignment_to_path (const string &source_path, size_t length)
 Get an alignment against the currently set source_path. More...
 
Alignment alignment_with_error (size_t length, double base_error, double indel_error)
 
vector< Alignmentalignment_pair (size_t read_length, size_t fragment_length, double fragment_std_dev, double base_error, double indel_error)
 
size_t node_length (id_t id)
 
char pos_char (pos_t pos)
 
map< pos_t, char > next_pos_chars (pos_t pos)
 
Alignment mutate (const Alignment &aln, double base_error, double indel_error)
 
vector< Editmutate_edit (const Edit &edit, const pos_t &position, double base_error, double indel_error, const string &bases, vg::uniform_real_distribution< double > &rprob, vg::uniform_int_distribution< int > &rbase)
 
string alignment_seq (const Alignment &aln)
 
bool is_valid (const Alignment &aln)
 
- Public Member Functions inherited from vg::AbstractReadSampler
virtual ~AbstractReadSampler ()=default
 
 AbstractReadSampler (PathPositionHandleGraph &graph)
 Make a new sampler using the given graph. More...
 

Public Attributes

LRUCache< id_t, Nodenode_cache
 
LRUCache< id_t, vector< Edge > > edge_cache
 
mt19937 rng
 
int64_t nonce
 
bool forward_only
 
bool no_Ns
 
vector< string > source_paths
 
vg::discrete_distribution path_sampler
 
size_t total_seq_length = 0
 
- Public Attributes inherited from vg::AbstractReadSampler
bool multi_position_annotations = false
 
size_t max_tries = 100
 What limit should we use for retry loops before giving up or failing? More...
 
std::unique_ptr< std::function< bool(const path_handle_t &)> > annotation_path_filter
 

Additional Inherited Members

- Protected Member Functions inherited from vg::AbstractReadSampler
void annotate_with_path_positions (Alignment &aln)
 
- Protected Attributes inherited from vg::AbstractReadSampler
PathPositionHandleGraphgraph
 The graph being simulated against. More...
 

Detailed Description

Generate Alignments (with or without mutations, and in pairs or alone) from an PathPositionHandleGraph index.

Constructor & Destructor Documentation

◆ Sampler()

vg::Sampler::Sampler ( PathPositionHandleGraph x,
int  seed = 0,
bool  forward_only = false,
bool  allow_Ns = false,
const vector< string > &  source_paths = {},
const vector< double > &  source_path_ploidies = {},
const vector< pair< string, double >> &  transcript_expressions = {},
const vector< tuple< string, string, size_t >> &  haplotype_transcripts = {} 
)
inline

Make a Sampler to sample from the given graph. If sampling from particular paths, source_paths should contain their names, and source_path_ploidies should either be empty or contain a ploidy value for each source path.

Member Function Documentation

◆ alignment()

Alignment vg::Sampler::alignment ( size_t  length)

Get an alignment against the whole graph, or against the source path if one is selected.

◆ alignment_pair()

vector< Alignment > vg::Sampler::alignment_pair ( size_t  read_length,
size_t  fragment_length,
double  fragment_std_dev,
double  base_error,
double  indel_error 
)

◆ alignment_seq()

string vg::Sampler::alignment_seq ( const Alignment aln)

◆ alignment_to_graph()

Alignment vg::Sampler::alignment_to_graph ( size_t  length)

Get an alignment against the whole graph.

◆ alignment_to_path()

Alignment vg::Sampler::alignment_to_path ( const string &  source_path,
size_t  length 
)

Get an alignment against the currently set source_path.

◆ alignment_with_error()

Alignment vg::Sampler::alignment_with_error ( size_t  length,
double  base_error,
double  indel_error 
)

◆ is_valid()

bool vg::Sampler::is_valid ( const Alignment aln)

Return true if the alignment is semantically valid against the PathPositionHandleGraph index we wrap, and false otherwise. Checks from_lengths on mappings to make sure all node bases are accounted for. Won't accept alignments with internal jumps between graph locations or regions; all skipped bases need to be accounted for by deletions.

◆ mutate()

Alignment vg::Sampler::mutate ( const Alignment aln,
double  base_error,
double  indel_error 
)

◆ mutate_edit()

vector< Edit > vg::Sampler::mutate_edit ( const Edit edit,
const pos_t position,
double  base_error,
double  indel_error,
const string &  bases,
vg::uniform_real_distribution< double > &  rprob,
vg::uniform_int_distribution< int > &  rbase 
)

Mutate the given edit, producing a vector of edits that should replace it. Position is the position of the start of the edit, and is updated to point to the next base after the mutated edit.

◆ next_pos_chars()

map< pos_t, char > vg::Sampler::next_pos_chars ( pos_t  pos)

◆ node_length()

size_t vg::Sampler::node_length ( id_t  id)

◆ pos_char()

char vg::Sampler::pos_char ( pos_t  pos)

◆ position()

pos_t vg::Sampler::position ( void  )

◆ sample_read()

Alignment vg::Sampler::sample_read ( )

◆ sample_read_pair()

pair<Alignment, Alignment> vg::Sampler::sample_read_pair ( )

◆ sequence()

string vg::Sampler::sequence ( size_t  length)

◆ set_source_paths()

void vg::Sampler::set_source_paths ( const vector< string > &  source_paths,
const vector< double > &  source_path_ploidies,
const vector< pair< string, double >> &  transcript_expressions,
const vector< tuple< string, string, size_t >> &  haplotype_transcripts 
)

Make a path sampling distribution based on relative lengths (weighted by ploidy) or on transcript expressions. (At most one of source_paths and expressions should be non-empty.) If providing a transcript expression profile, can optionally provide a non-empty vector of haplotype transcripts to translate between the embedded path names and the transcript names in the expression profile.

Member Data Documentation

◆ edge_cache

LRUCache<id_t, vector<Edge> > vg::Sampler::edge_cache

◆ forward_only

bool vg::Sampler::forward_only

◆ no_Ns

bool vg::Sampler::no_Ns

◆ node_cache

LRUCache<id_t, Node> vg::Sampler::node_cache

◆ nonce

int64_t vg::Sampler::nonce

◆ path_sampler

vg::discrete_distribution vg::Sampler::path_sampler

◆ rng

mt19937 vg::Sampler::rng

◆ source_paths

vector<string> vg::Sampler::source_paths

◆ total_seq_length

size_t vg::Sampler::total_seq_length = 0

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