|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_SEQUENCE_KMER_FUNCTION_H_
2 #define GENESIS_SEQUENCE_KMER_FUNCTION_H_
41 #include <type_traits>
61 for(
size_t i = 0; i < k; ++i ) {
71 template<
typename Tag>
77 template<
typename Tag>
83 template<
typename Tag>
89 template<
typename Tag>
95 template<
typename Tag>
101 template<
typename Tag>
107 template<
typename Tag>
110 auto result = std::string( kmer.
k(),
'X' );
111 for(
size_t i = 0; i < kmer.
k(); ++i ) {
134 template<
typename Tag>
145 template<
typename Tag>
151 "Kmer::WordType != uint64_t"
160 auto value = kmer.
value();
161 value = (( value & 0xCCCCCCCCCCCCCCCCUL ) >> 2) | (( value & 0x3333333333333333UL ) << 2 );
162 value = (( value & 0xF0F0F0F0F0F0F0F0UL ) >> 4) | (( value & 0x0F0F0F0F0F0F0F0FUL ) << 4 );
163 value = (( value & 0xFF00FF00FF00FF00UL ) >> 8) | (( value & 0x00FF00FF00FF00FFUL ) << 8 );
164 value = (( value & 0xFFFF0000FFFF0000UL ) >> 16) | (( value & 0x0000FFFF0000FFFFUL ) << 16 );
165 value = ( value >> 32 ) | ( value << 32);
171 template<
typename Tag>
175 return kmer < rev_comp ? kmer : rev_comp;
181 #endif // include guard
bool operator!=(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)
bool operator>(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)
Kmer class template for representing k-mers of various sizes, currently up to k-32.
bool operator<(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)
std::ostream & operator<<(std::ostream &out, Sequence const &seq)
Print a Sequence to an ostream in the form "label: sites".
size_t number_of_kmers(size_t k, size_t alphabet_size=4)
Compute the total number of possible k-mers for a given k and alphabet_size.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool operator<=(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)
Kmer< Tag > canonical_representation(Kmer< Tag > const &kmer)
std::string to_string(Kmer< Tag > const &kmer)
std::string reverse_complement(std::string const &sequence, bool accept_degenerated)
Get the reverse complement of a nucleic acid sequence.
uint64_t WordType
Underlying integer type used to store the k-mer.
WordType const & value() const
bool operator>=(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)
bool operator==(Kmer< Tag > const &lhs, Kmer< Tag > const &rhs)