Commit 568f1500 authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Merge branch 'feature-a/3250-shift-kmer-ascii-value-for-ambiguous-and-unknown' into 'dev'

Feature a/3250 shift kmer ascii value for ambiguous and unknown

Closes #3250

See merge request !220
parents bc8c40e0 82e0f8fd
Pipeline #29910 passed with stages
in 51 seconds
......@@ -66,6 +66,12 @@ string toString(const affect_t &a) {
}
string toStringValues(const affect_t &a){
if(a == AFFECT_UNKNOWN.affect){
return AFFECT_UNKNOWN_TO_STRING;
}
if(a == AFFECT_AMBIGUOUS.affect){
return AFFECT_AMBIGUOUS_TO_STRING;
}
return string(1,affect_char(a));
}
......@@ -149,7 +155,7 @@ int KmerAffect::getStrand() const{
}
string KmerAffect::getLabel() const {
return string(1, affect_char(affect));
return ::toStringValues(affect);
}
unsigned char KmerAffect::getLength() const {
......
......@@ -170,11 +170,16 @@ bool operator!=(const KmerAffect &a1, const KmerAffect &a2);
ostream &operator<<(ostream &os, const KmerAffect &kmer);
#define AFFECT_NOT_UNKNOWN_SYMBOL "*"
#define AFFECT_AMBIGUOUS_SYMBOL "?"
#define AFFECT_UNKNOWN_SYMBOL "_"
#define AFFECT_AMBIGUOUS_SYMBOL "\0"
#define AFFECT_UNKNOWN_SYMBOL "\1"
#define AFFECT_AMBIGUOUS_CHAR (AFFECT_AMBIGUOUS_SYMBOL[0])
#define AFFECT_UNKNOWN_CHAR (AFFECT_UNKNOWN_SYMBOL[0])
/* Define how an ambiguous kmeraffect looks like in a string */
#define AFFECT_AMBIGUOUS_TO_STRING "?"
/* Define how an unknown kmeraffect looks like in a string */
#define AFFECT_UNKNOWN_TO_STRING "_"
/**
* Constant defining any not-unknown affectation
......
......@@ -114,7 +114,7 @@ void testGetMultiResults(){
/* Check if there is at least one Kmer unknown when no matching K-mer */
unsigned int i = 0;
for(auto const& x : results){
if(x.first.toStringValues() == AFFECT_UNKNOWN_SYMBOL){
if(x.first.toStringValues() == AFFECT_UNKNOWN_TO_STRING){
break;
}
++i;
......
......@@ -57,8 +57,8 @@ void testAffect() {
TAP_TEST_EQUAL(toString(Vminus), "-V", TEST_AFFECT_TO_STRING, toString(Vminus));
TAP_TEST_EQUAL(toString(Vplus), "+V", TEST_AFFECT_TO_STRING, toString(Vplus));
TAP_TEST_EQUAL(toString(Jplus), "+J", TEST_AFFECT_TO_STRING, toString(Jplus));
TAP_TEST_EQUAL(toString(AFFECT_UNKNOWN.affect), " " AFFECT_UNKNOWN_SYMBOL, TEST_AFFECT_TO_STRING, "");
TAP_TEST_EQUAL(toString(AFFECT_AMBIGUOUS.affect), " " AFFECT_AMBIGUOUS_SYMBOL, TEST_AFFECT_TO_STRING, "");
TAP_TEST_EQUAL(toString(AFFECT_UNKNOWN.affect), " " AFFECT_UNKNOWN_TO_STRING, TEST_AFFECT_TO_STRING, "");
TAP_TEST_EQUAL(toString(AFFECT_AMBIGUOUS.affect), " " AFFECT_AMBIGUOUS_TO_STRING, TEST_AFFECT_TO_STRING, "");
ostringstream oss;
oss << Vminus;
......@@ -104,13 +104,13 @@ void testKmerAffectClass() {
TAP_TEST(unknown == AFFECT_UNKNOWN, TEST_KMERAFFECT_CONSTRUCTOR, "");
TAP_TEST(unknown.isUnknown(), TEST_KMERAFFECT_UNKNOWN, "");
TAP_TEST_EQUAL(unknown.getStrand(), 0, TEST_KMERAFFECT_STRAND, "");
TAP_TEST_EQUAL(unknown.getLabel(), AFFECT_UNKNOWN_SYMBOL, TEST_KMERAFFECT_LABEL, "");
TAP_TEST_EQUAL(unknown.getLabel(), AFFECT_UNKNOWN_TO_STRING, TEST_KMERAFFECT_LABEL, "");
unknown += KAVm;
TAP_TEST(unknown.affect == KAVm, TEST_KMERAFFECT_ADD, "");
unknown += KAJp;
TAP_TEST(unknown == AFFECT_AMBIGUOUS, TEST_KMERAFFECT_ADD, "");
TAP_TEST(unknown.isAmbiguous(), TEST_KMERAFFECT_AMBIGUOUS, "");
TAP_TEST_EQUAL(unknown.getLabel(), AFFECT_AMBIGUOUS_SYMBOL, TEST_KMERAFFECT_LABEL, "");
TAP_TEST_EQUAL(unknown.getLabel(), AFFECT_AMBIGUOUS_TO_STRING, TEST_KMERAFFECT_LABEL, "");
TAP_TEST_EQUAL(unknown.getStrand(), 0, TEST_KMERAFFECT_STRAND, "");
TAP_TEST_EQUAL(unknown.getLength(), 4, TEST_KMERAFFECT_AMBIGUOUS, "");
......
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