gatb.core-API-0.0.0
Kmer< span >::ModelMinimizer< ModelType, Comparator > Class Template Reference

Model that handles kmers of the Model type + a minimizer. More...

#include <Model.hpp>

Inheritance diagram for Kmer< span >::ModelMinimizer< ModelType, Comparator >:
Inheritance graph

Public Types

typedef ModelType Model
 
typedef KmerMinimizer< ModelType, Comparator > Kmer
 
- Public Types inherited from Kmer< span >::ModelAbstract< ModelMinimizer< ModelType, Comparator >, KmerMinimizer< ModelType, Comparator > >
typedef KmerMinimizer< ModelType, Comparator > Kmer
 

Public Member Functions

const ModelType & getMmersModel () const
 
 ModelMinimizer (size_t kmerSize, size_t minimizerSize, Comparator cmp=Comparator(), uint32_t *freq_order=NULL)
 
 ~ModelMinimizer ()
 
template<class Convert >
int first (const char *seq, Kmer &kmer, size_t startIndex) const
 
template<class Convert >
void next (char c, Kmer &kmer, bool isValid) const
 
u_int64_t getMinimizerValue (const Type &k, bool fastMethod=true) const
 
std::string getMinimizerString (const Type &k, bool fastMethod=true) const
 
int getMinimizerPosition (const Type &k, bool fastMethod=true) const
 
- Public Member Functions inherited from Kmer< span >::ModelAbstract< ModelMinimizer< ModelType, Comparator >, KmerMinimizer< ModelType, Comparator > >
 ModelAbstract (size_t sizeKmer=span-1)
 
size_t getSpan () const
 
size_t getMemorySize () const
 
size_t getKmerSize () const
 
const TypegetKmerMax () const
 
std::string toString (const Type &kmer) const
 
Type reverse (const Type &kmer) const
 
Kmer getKmer (const tools::misc::Data &data, size_t startIndex=0) const
 
bool iterate (tools::misc::Data &data, Callback callback) const
 
Kmer codeSeed (const char *seq, tools::misc::Data::Encoding_e encoding, size_t startIndex=0) const
 
Kmer codeSeedRight (const Kmer &kmer, char nucl, tools::misc::Data::Encoding_e encoding) const
 
bool build (tools::misc::Data &data, std::vector< Kmer > &kmersBuffer) const
 
void iterateNeighbors (const Type &source, const Functor &fct, const std::bitset< 8 > &mask=0xFF) const
 
void iterateOutgoingNeighbors (const Type &source, Functor &fct, const std::bitset< 4 > &mask=0x0F) const
 
void iterateIncomingNeighbors (const Type &source, Functor &fct, const std::bitset< 4 > &mask=0x0F) const
 
- Public Member Functions inherited from SmartPointer
void use ()
 
void forget ()
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 

Additional Inherited Members

- Protected Member Functions inherited from Kmer< span >::ModelAbstract< ModelMinimizer< ModelType, Comparator >, KmerMinimizer< ModelType, Comparator > >
bool iterate (const char *seq, size_t length, Callback callback) const
 
- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
 
virtual ~SmartPointer ()
 

Detailed Description

template<size_t span = KMER_DEFAULT_SPAN>
template<class ModelType, class Comparator = Kmer<span>::ComparatorMinimizerFrequencyOrLex>
class gatb::core::kmer::impl::Kmer< span >::ModelMinimizer< ModelType, Comparator >

Model that handles kmers of the Model type + a minimizer.

This model supports the concept of minimizer. It acts as a Model instance (given as a template class) and add minimizer information to the Kmer type.

Example of use:

// We declare a kmer model with kmer size big enough to represent our sequence.
// Note that we give a second size, which is the size of the minimizers
ModelMinimizer model (kmerSize, 8);
// We get a reference on the minimizer model, which will be useful for dumping
// string value of a minimizer. Recall that 'model' is a model configured with
// 'kmerSize' but has also to deal with mmers of size kmerSize/2. The 'getMmersModel'
// method just provides access to this inner model.
const ModelCanonical& modelMinimizer = model.getMmersModel();
// We compute the kmer for a given sequence
ModelMinimizer::Kmer kmer = model.codeSeed (seq, Data::ASCII);
std::cout << std::endl;
std::cout << "-------------------- MINIMIZER --------------------" << std::endl;
std::cout << "kmer value is: " << kmer.value() << std::endl;
std::cout << "kmer string is: " << model.toString(kmer.value()) << std::endl;
// With this model, we have extra information.
std::cout << "forward value is: " << kmer.forward() << std::endl;
std::cout << "forward string is: " << model.toString(kmer.forward()) << std::endl;
std::cout << "revcomp value is: " << kmer.revcomp() << std::endl;
std::cout << "revcomp string is: " << model.toString(kmer.revcomp()) << std::endl;
std::cout << "used strand is : " << toString(kmer.strand()) << std::endl;
// We can also have information about minimizers.
// Note : kmer.minimizer() is of type ModelCanonical, ie the type provided as
// template argument of the ModelMinimizer class.
std::cout << "minimizer model size : " << modelMinimizer.getKmerSize() << std::endl;
std::cout << "minimizer value is : " << kmer.minimizer().value() << std::endl;
std::cout << "minimizer string is : " << modelMinimizer.toString(kmer.minimizer().value()) << std::endl;
std::cout << "minimizer position in kmer : " << kmer.position() << std::endl;
std::cout << "minimizer changed : " << kmer.hasChanged() << std::endl;

Member Typedef Documentation

typedef KmerMinimizer<ModelType,Comparator> Kmer

Kmer type for this kind of model.

typedef ModelType Model

Type of the model for kmer and mmers.

Constructor & Destructor Documentation

ModelMinimizer ( size_t  kmerSize,
size_t  minimizerSize,
Comparator  cmp = Comparator(),
uint32_t *  freq_order = NULL 
)
inline

Constructor.

Parameters
[in]kmerSize: size of the kmers handled by the model.
[in]minimizerSize: size of the mmers handled by the model.
[in]cmp: functor that compares two minizers
[in]freq_order: a 4^m table containing the frequency of each minimizer
~ModelMinimizer ( )
inline

Destructor

Member Function Documentation

int first ( const char *  seq,
Kmer kmer,
size_t  startIndex 
) const
inline

Computes a kmer from a buffer holding nucleotides encoded in some format. The way to interpret the buffer is done through the provided Convert template class.

Parameters
[in]seq: holds the nucleotides sequence from which the kmer has to be computed
[out]kmer: kmer as a result
[in]startIndex: index of the first nucleotide of the kmer to retrieve in the buffer
int getMinimizerPosition ( const Type k,
bool  fastMethod = true 
) const
inline

Get the minimizer position of the provided kmer. (used for debugging purposes only)

Returns
the miminizer position
std::string getMinimizerString ( const Type k,
bool  fastMethod = true 
) const
inline

Get the minimizer string of the provided kmer. (used for debugging purposes only)

Returns
the miminizer as a nucleotide string.
u_int64_t getMinimizerValue ( const Type k,
bool  fastMethod = true 
) const
inline

Get the minimizer value of the provided kmer. Note that minimizers are supposed to be of small sizes, so their values can fit a u_int64_t type.

Returns
the miminizer value as an integer.
const ModelType& getMmersModel ( ) const
inline

Return a reference on the model used for managing mmers.

Returns
the minimizer model.
void next ( char  c,
Kmer kmer,
bool  isValid 
) const
inline

Computes a kmer in a recursive way, ie. from a kmer and the next nucleotide. The next nucleotide is computed from a buffer and the index of the nucleotide within the buffer. The way to interpret the buffer is done through the provided Convert template class.

Parameters
[in]c: next nucleotide
[out]kmer: kmer to be updated with the provided next nucleotide
[in]isValid: tells whether the updated kmer is valid or not

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