Commit 24473c8d authored by Mathieu Giraud's avatar Mathieu Giraud

kmeraffect.{h,cpp}: inline critical functions

parent ce0e3d9b
......@@ -24,18 +24,6 @@
#include "kmeraffect.h"
#include <cassert>
int affect_strand(const affect_t &affect) {
return (affect.c & (1 << 7)) ? 1 : -1;
}
char affect_char(const affect_t &affect) {
return (affect.c & ((1 << 7)-1));
}
size_t affect_length(const affect_t &affect) {
return affect.length;
}
// KmerAffect class
bool operator==(const affect_t &a1, const affect_t &a2) {
......@@ -98,10 +86,6 @@ KmerAffect::KmerAffect(const affect_t &a) {
affect = a;
}
KmerAffect::KmerAffect(const KmerAffect &ka) {
affect = ka.affect;
}
KmerAffect::KmerAffect(const KmerAffect &ka, bool reverse) {
affect = ka.affect;
if (reverse)
......@@ -146,43 +130,14 @@ KmerAffect KmerAffect::getAmbiguous() {
return AFFECT_AMBIGUOUS;
}
int KmerAffect::getStrand() const{
if (isUnknown() || isAmbiguous())
return 0;
return affect_strand(affect);
}
string KmerAffect::getLabel() const {
return ::toStringValues(affect);
}
unsigned char KmerAffect::getLength() const {
return affect_length(affect);
}
KmerAffect KmerAffect::getUnknown() {
return AFFECT_UNKNOWN;
}
bool KmerAffect::isAmbiguous() const {
return affect_strand(affect) == 1 && affect_char(affect) == AFFECT_AMBIGUOUS_CHAR;
}
bool KmerAffect::isNull() const {
return isUnknown();
}
bool KmerAffect::isUnknown() const {
return affect.c == (int) AFFECT_UNKNOWN_CHAR;
}
bool KmerAffect::isGeneric() const {
return !(isUnknown() || isAmbiguous());
}
string KmerAffect::toString() const {
return ::toString(affect);
}
string KmerAffect::toStringValues() const {
return ::toStringValues(affect);
......
......@@ -29,17 +29,17 @@ struct affect_s {
/**
* @return the strand (-1 or +1) associated to the affect_t
*/
int affect_strand(const affect_t &affect);
inline int affect_strand(const affect_t &affect);
/**
* @return the character associated to the affect_t
*/
char affect_char(const affect_t &affect);
inline char affect_char(const affect_t &affect);
/**
* @return the length of the kmer associated with the affectation
*/
size_t affect_length(const affect_t &affect);
inline size_t affect_length(const affect_t &affect);
bool operator==(const affect_t &a1, const affect_t &a2);
bool operator<(const affect_t &a1, const affect_t &a2);
......@@ -72,7 +72,7 @@ public:
/**
* Copy constructor
*/
KmerAffect(const KmerAffect &ka);
inline KmerAffect(const KmerAffect &ka);
/*
* Copy constructor, possibly reversing the strand if 'reverse' is true
......@@ -114,7 +114,7 @@ public:
* 1 for forward
* 0 for unknown or ambiguous
*/
int getStrand() const;
inline int getStrand() const;
/**
* @return the label of the affectation.
......@@ -125,7 +125,7 @@ public:
/**
* @return the length of such an affectation
*/
unsigned char getLength() const;
inline unsigned char getLength() const;
/**
* @return the unknown affectation
......@@ -141,22 +141,22 @@ public:
/**
* @return true iff the affectation should be considered as ambiguous.
*/
bool isAmbiguous() const;
inline bool isAmbiguous() const;
/**
* @return true iff the affectation is unkwown yet.
*/
bool isUnknown() const;
inline bool isUnknown() const;
/**
* @return true iff the value is the same as the one given by default constructor
*/
bool isNull() const;
inline bool isNull() const;
/**
* @return true if the K-mer is not odd (ambiguous or unknown)
*/
bool isGeneric() const;
inline bool isGeneric() const;
string toString() const;
string toStringValues()const;
......@@ -227,4 +227,50 @@ const KmerAffect AFFECT_J_BWD = KmerAffect("J", -1);
////////////////////////////////////////////////////////////////////////////////////////////////////
inline KmerAffect::KmerAffect(const KmerAffect &ka) {
affect = ka.affect;
}
inline unsigned char KmerAffect::getLength() const {
return affect_length(affect);
}
inline bool KmerAffect::isAmbiguous() const {
return affect_strand(affect) == 1 && affect_char(affect) == AFFECT_AMBIGUOUS_CHAR;
}
inline bool KmerAffect::isNull() const {
return isUnknown();
}
inline bool KmerAffect::isUnknown() const {
return affect.c == (int) AFFECT_UNKNOWN_CHAR;
}
inline bool KmerAffect::isGeneric() const {
return !(isUnknown() || isAmbiguous());
}
inline string KmerAffect::toString() const {
return ::toString(affect);
}
inline int affect_strand(const affect_t &affect) {
return (affect.c & (1 << 7)) ? 1 : -1;
}
inline char affect_char(const affect_t &affect) {
return (affect.c & ((1 << 7)-1));
}
inline size_t affect_length(const affect_t &affect) {
return affect.length;
}
inline int KmerAffect::getStrand() const{
if (isUnknown() || isAmbiguous())
return 0;
return affect_strand(affect);
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment