gatb.core-API-0.0.0
IntegerTemplate< IntegerList > Class Template Reference

Class for large integers calculus. More...

#include <Integer.hpp>

Public Types

typedef boost::make_variant_over< transfolist >::type Type
 

Public Member Functions

 IntegerTemplate (int64_t n=0)
 
template<typename T >
 IntegerTemplate (const T &t)
 
template<typename T >
IntegerTemplateoperator= (const T &t)
 
const char * getName ()
 
size_t getSize ()
 
hid_t hdf5 (bool &isCompound)
 
void operator+= (const IntegerTemplate &a)
 
void operator^= (const IntegerTemplate &a)
 
u_int8_t operator[] (size_t idx) const
 
std::string toString (size_t sizeKmer) const
 
template<typename U >
const U & get () const
 

Static Public Member Functions

template<template< size_t > class Functor, typename Parameter >
static void apply (size_t kmerSize, Parameter params)
 

Friends

IntegerTemplate operator+ (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator- (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator| (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator^ (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator& (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator~ (const IntegerTemplate &a)
 
bool operator== (const IntegerTemplate &a, const IntegerTemplate &b)
 
bool operator!= (const IntegerTemplate &a, const IntegerTemplate &b)
 
bool operator< (const IntegerTemplate &a, const IntegerTemplate &b)
 
bool operator<= (const IntegerTemplate &a, const IntegerTemplate &b)
 
IntegerTemplate operator* (const IntegerTemplate &a, const int &c)
 
IntegerTemplate operator/ (const IntegerTemplate &a, const u_int32_t &c)
 
u_int32_t operator% (const IntegerTemplate &a, const u_int32_t &c)
 
IntegerTemplate operator>> (const IntegerTemplate &a, const int &c)
 
IntegerTemplate operator<< (const IntegerTemplate &a, const int &c)
 
IntegerTemplate revcomp (const IntegerTemplate &a, size_t sizeKmer)
 
u_int64_t hash1 (const IntegerTemplate &a, u_int64_t seed)
 
u_int64_t oahash (const IntegerTemplate &a)
 
u_int64_t simplehash16 (const IntegerTemplate &a, int shift)
 
u_int32_t fastLexiMinimizer (const IntegerTemplate &a, int _nbMinimizers, bool &validResult)
 
std::ostream & operator<< (std::ostream &s, const IntegerTemplate &a)
 

Detailed Description

template<typename IntegerList>
class gatb::core::tools::math::IntegerTemplate< IntegerList >

Class for large integers calculus.

The IntegerTemplate is implemented as a boost variant, which means that it can act like T1, T2, T3 or T4, etc.. type according to the configuration.

All the methods are implemented through a boost variant visitor.

Note that we have 2 possible native implementations (NativeInt64 and NativeInt128) that rely on native types uint64_t and __uint128_t.

For larger integer, a multi-precision LargeInt is used.

From the user point of view, [s]he has just to include this file and use the Integer class.

Member Typedef Documentation

typedef boost::make_variant_over<transfolist>::type Type

We define a boost variant from this type list.

Constructor & Destructor Documentation

IntegerTemplate ( int64_t  n = 0)
inline

Constructor. Note that the type (see getType and setType) has to be first initialized otherwise no instance can be created (exception thrown).

Parameters
[in]n: value for initialization of the integer.
IntegerTemplate ( const T &  t)
inlineexplicit

Copy constructor. Relies on the copy constructor of boost variant

Parameters
[in]t: the object to be used for initialization

Member Function Documentation

static void apply ( size_t  kmerSize,
Parameter  params 
)
inlinestatic

Apply a functor with the best template specialization according to the provided kmer size.

const U& get ( ) const
inline

Get the value of the IntegerTemplate object as a U type, U being one of the T1,T2,T3,T4 template class parameters. This method can be seen as a converter from the IntegerTemplate class to a specific U type (given as a template parameter of this method).

Returns
the converted value as a U type.
const char* getName ( )
inline

Get the name of the class used by the variant (ie. one of the Ti template class parameters)

Returns
the class name.
size_t getSize ( )
inline

Get the size of an instance of the class used by the variant (ie. one of the Ti template class parameters)

Returns
the size of an object (in bits).
hid_t hdf5 ( bool &  isCompound)
inline

Get the HDF5 type for the the class used by the variant (ie. one of the Ti template class parameters)

Parameters
[in]isCompound: tells whether the type is composed or not
Returns
a HDF5 identifier for the type.
void operator+= ( const IntegerTemplate< IntegerList > &  a)
inline

Operator +=

Parameters
[in]a: first operand
Returns
addition and affectation.
IntegerTemplate& operator= ( const T &  t)
inline

Affectation operator. Relies on the affectation operator of boost variant

Parameters
[in]t: object to be copied
Returns
the current object.
u_int8_t operator[] ( size_t  idx) const
inline

Operator[] access the ith nucleotide in the given integer. For instance a[4] get the 5th nucleotide of a kmer encoded as an Integer object.

Parameters
[in]idx: index of the nucleotide to be retrieved
Returns
the nucleotide value as follow: A=0, C=1, T=2 and G=3
void operator^= ( const IntegerTemplate< IntegerList > &  a)
inline

Operator ^=

Parameters
[in]a: first operand
Returns
xor and affectation.
std::string toString ( size_t  sizeKmer) const
inline

Get an ASCII string representation of a kmer encoded as a IntegerTemplate object

Parameters
[in]sizeKmer: size of the kmer
Returns
the ASCII representation of the kmer.

Friends And Related Function Documentation

u_int32_t fastLexiMinimizer ( const IntegerTemplate< IntegerList > &  a,
int  _nbMinimizers,
bool &  validResult 
)
friend

Get the lexicographical minimizer of the k-mer, quickly, using bit tricks. minimizers containing 'AA' are forbidden. might not return a valid result sometimes.

Parameters
[in]nbminimizersnumber of minimizers inside this kmer
[in]&validResultwhether the returned result should be considered valid (if not, compute minimizer with another approach please)
Returns
the reverse complement kmer as a IntegerTemplate value
u_int64_t hash1 ( const IntegerTemplate< IntegerList > &  a,
u_int64_t  seed 
)
friend

Get a hash value on 64 bits for a given IntegerTemplate object.

Parameters
[in]a: the integer value
[in]seed: some seed value used for the hash computation.
Returns
the hash value on 64 bits.
u_int64_t oahash ( const IntegerTemplate< IntegerList > &  a)
friend

Get a hash value on 64 bits for a given IntegerTemplate object.

Parameters
[in]a: the integer value
Returns
the hash value on 64 bits.
bool operator!= ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator !=

Parameters
[in]a: first operand
[in]b: second operand
Returns
inequality of the two operands.
u_int32_t operator% ( const IntegerTemplate< IntegerList > &  a,
const u_int32_t &  c 
)
friend

Operator %

Parameters
[in]a: first operand
[in]c: second operand
Returns
modulo of the two operands.
IntegerTemplate operator& ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator &

Parameters
[in]a: first operand
[in]b: second operand
Returns
'and' of the two operands.
IntegerTemplate operator* ( const IntegerTemplate< IntegerList > &  a,
const int &  c 
)
friend

Operator *

Parameters
[in]a: first operand
[in]c: second operand
Returns
multiplication of the two operands.
IntegerTemplate operator+ ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator +

Parameters
[in]a: first operand
[in]b: second operand
Returns
sum of the two operands.
IntegerTemplate operator- ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator -

Parameters
[in]a: first operand
[in]b: second operand
Returns
substraction of the two operands.
IntegerTemplate operator/ ( const IntegerTemplate< IntegerList > &  a,
const u_int32_t &  c 
)
friend

Operator /

Parameters
[in]a: first operand
[in]c: second operand
Returns
division of the two operands.
bool operator< ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator <

Parameters
[in]a: first operand
[in]b: second operand
Returns
'<' of the two operands.
IntegerTemplate operator<< ( const IntegerTemplate< IntegerList > &  a,
const int &  c 
)
friend

Operator <<

Parameters
[in]a: first operand
[in]c: second operand
Returns
left shift of the two operands.
std::ostream& operator<< ( std::ostream &  s,
const IntegerTemplate< IntegerList > &  a 
)
friend

Output stream operator for the IntegerTemplate class

Parameters
[in]s: the output stream to be used.
[in]a: the object to output
Returns
the modified output stream.
bool operator<= ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator <=

Parameters
[in]a: first operand
[in]b: second operand
Returns
'<=' of the two operands.
bool operator== ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator ==

Parameters
[in]a: first operand
[in]b: second operand
Returns
equality of the two operands.
IntegerTemplate operator>> ( const IntegerTemplate< IntegerList > &  a,
const int &  c 
)
friend

Operator >>

Parameters
[in]a: first operand
[in]c: second operand
Returns
right shift of the two operands.
IntegerTemplate operator^ ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator ^

Parameters
[in]a: first operand
[in]b: second operand
Returns
'xor' of the two operands.
IntegerTemplate operator| ( const IntegerTemplate< IntegerList > &  a,
const IntegerTemplate< IntegerList > &  b 
)
friend

Operator |

Parameters
[in]a: first operand
[in]b: second operand
Returns
'or' of the two operands.
IntegerTemplate operator~ ( const IntegerTemplate< IntegerList > &  a)
friend

Operator ~

Parameters
[in]a: operand
Returns
negation of the operand
IntegerTemplate revcomp ( const IntegerTemplate< IntegerList > &  a,
size_t  sizeKmer 
)
friend

Get the reverse complement of a kmer encoded as an IntegerTemplate object. Note that the kmer size must be known.

Parameters
[in]a: kmer value to be reversed-complemented
[in]sizeKmer: size of the kmer
Returns
the reverse complement kmer as a IntegerTemplate value
u_int64_t simplehash16 ( const IntegerTemplate< IntegerList > &  a,
int  shift 
)
friend

Get a hash value on 64 bits for a given IntegerTemplate object. Note: although we return 64 bits, only the first 16 bits are set

Parameters
[in]a: the integer value
[in]shift: some value used for the hash computation.
Returns
the hash value on 64 bits.

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