A library for working with phylogenetic and population genetic data.
v0.32.0
SequenceDict Class Reference

#include <genesis/sequence/sequence_dict.hpp>

Detailed Description

Store dictionary/index data on sequence files, such as coming from .fai or .dict files.

See DictReader and FaiReader for the input format readers. Furthermore, FastaReader also offers a mode to read a fasta file, and just retaining the dict/index information. Lastly, see sequence_set_to_dict() for a function to get this information from a given SequenceSet.

Currently, we only store the sequence names and their lengths, in the order as provided in the input file. We might add further information such as offset in the fasta file in the future, once we offer to read with jumps in fasta files.

See also
ReferenceGenome

Definition at line 63 of file sequence_dict.hpp.

Public Member Functions

 SequenceDict ()=default
 
 SequenceDict (SequenceDict &&)=default
 
 SequenceDict (SequenceDict const &)=default
 
 ~SequenceDict ()=default
 
void add (Entry &&entry, bool also_look_up_first_word=true)
 Add an entry to the dictionary. More...
 
void add (Entry const &entry, bool also_look_up_first_word=true)
 Add an entry to the dictionary. More...
 
void add (Sequence const &sequence, bool also_look_up_first_word=true)
 Add a Sequence to the dictionary. More...
 
void add (std::string const &name, size_t length, bool also_look_up_first_word=true)
 Add an entry to the dictionary, given its name and length. More...
 
Entry const & at (size_t index) const
 
const_iterator begin () const
 
void clear ()
 
bool contains (std::string const &name) const
 
const_iterator end () const
 
const_iterator find (std::string const &name) const
 
Entry const & get (std::string const &name) const
 
size_t index_of (std::string const &name) const
 
SequenceDictoperator= (SequenceDict &&)=default
 
SequenceDictoperator= (SequenceDict const &)=default
 
Entry const & operator[] (size_t index) const
 
size_t size () const
 

Public Types

using const_iterator = std::vector< Entry >::const_iterator
 

Classes

struct  Entry
 

Constructor & Destructor Documentation

◆ SequenceDict() [1/3]

SequenceDict ( )
default

◆ ~SequenceDict()

~SequenceDict ( )
default

◆ SequenceDict() [2/3]

SequenceDict ( SequenceDict const &  )
default

◆ SequenceDict() [3/3]

SequenceDict ( SequenceDict &&  )
default

Member Function Documentation

◆ add() [1/4]

void add ( Entry &&  entry,
bool  also_look_up_first_word = true 
)
inline

Add an entry to the dictionary.

If also_look_up_first_word is set (true by default), we add an additional look up name for the added sequence: In addition to its full name, it can also be looked up with just the first word, that is, until the first tab or space character, in case there are any, as this is what typical fasta indexing tools also seem to do. The sequence is still stored with its original name though, and just that additional lookup is added for using find() or get().

Definition at line 171 of file sequence_dict.hpp.

◆ add() [2/4]

void add ( Entry const &  entry,
bool  also_look_up_first_word = true 
)
inline

Add an entry to the dictionary.

If also_look_up_first_word is set (true by default), we add an additional look up name for the added sequence: In addition to its full name, it can also be looked up with just the first word, that is, until the first tab or space character, in case there are any, as this is what typical fasta indexing tools also seem to do. The sequence is still stored with its original name though, and just that additional lookup is added for using find() or get().

Definition at line 156 of file sequence_dict.hpp.

◆ add() [3/4]

void add ( Sequence const &  sequence,
bool  also_look_up_first_word = true 
)
inline

Add a Sequence to the dictionary.

If also_look_up_first_word is set (true by default), we add an additional look up name for the added sequence: In addition to its full name, it can also be looked up with just the first word, that is, until the first tab or space character, in case there are any, as this is what typical fasta indexing tools also seem to do. The sequence is still stored with its original name though, and just that additional lookup is added for using find() or get().

Definition at line 133 of file sequence_dict.hpp.

◆ add() [4/4]

void add ( std::string const &  name,
size_t  length,
bool  also_look_up_first_word = true 
)
inline

Add an entry to the dictionary, given its name and length.

If also_look_up_first_word is set (true by default), we add an additional look up name for the added sequence: In addition to its full name, it can also be looked up with just the first word, that is, until the first tab or space character, in case there are any, as this is what typical fasta indexing tools also seem to do. The sequence is still stored with its original name though, and just that additional lookup is added for using find() or get().

Definition at line 143 of file sequence_dict.hpp.

◆ at()

Entry const& at ( size_t  index) const
inline

Definition at line 228 of file sequence_dict.hpp.

◆ begin()

const_iterator begin ( ) const
inline

Definition at line 271 of file sequence_dict.hpp.

◆ clear()

void clear ( )
inline

Definition at line 208 of file sequence_dict.hpp.

◆ contains()

bool contains ( std::string const &  name) const
inline

Definition at line 252 of file sequence_dict.hpp.

◆ end()

const_iterator end ( ) const
inline

Definition at line 276 of file sequence_dict.hpp.

◆ find()

const_iterator find ( std::string const &  name) const
inline

Definition at line 257 of file sequence_dict.hpp.

◆ get()

Entry const& get ( std::string const &  name) const
inline

Definition at line 233 of file sequence_dict.hpp.

◆ index_of()

size_t index_of ( std::string const &  name) const
inline

Definition at line 240 of file sequence_dict.hpp.

◆ operator=() [1/2]

SequenceDict& operator= ( SequenceDict &&  )
default

◆ operator=() [2/2]

SequenceDict& operator= ( SequenceDict const &  )
default

◆ operator[]()

Entry const& operator[] ( size_t  index) const
inline

Definition at line 223 of file sequence_dict.hpp.

◆ size()

size_t size ( ) const
inline

Definition at line 218 of file sequence_dict.hpp.

Member Typedef Documentation

◆ const_iterator

using const_iterator = std::vector<Entry>::const_iterator

Definition at line 109 of file sequence_dict.hpp.


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