Commit 5bccc98d authored by Mikaël Salson's avatar Mikaël Salson

Tests: test getSequence() in AffectAnalyser

A hard-coded sequence should not be given to the constructor, instead it must be stored into a variable.
parent 4d3ec619
...@@ -9,14 +9,17 @@ void testAffectAnalyser1() { ...@@ -9,14 +9,17 @@ void testAffectAnalyser1() {
const bool revcomp = false; const bool revcomp = false;
T<KAffect> *index = createIndex<T<KAffect> >(k, revcomp); T<KAffect> *index = createIndex<T<KAffect> >(k, revcomp);
KmerAffectAnalyser<KAffect> kaa(*index, "AAAACCCCCGGGGG"); string sequence = "AAAACCCCCGGGGG";
CountKmerAffectAnalyser<KAffect> ckaa(*index, "AAAACCCCCGGGGG"); KmerAffectAnalyser<KAffect> kaa(*index, sequence);
CountKmerAffectAnalyser<KAffect> ckaa(*index, sequence);
ckaa.setAllowedOverlap(k-1); ckaa.setAllowedOverlap(k-1);
set<KAffect> forbidden; set<KAffect> forbidden;
forbidden.insert(KAffect::getAmbiguous()); forbidden.insert(KAffect::getAmbiguous());
forbidden.insert(KAffect::getUnknown()); forbidden.insert(KAffect::getUnknown());
TAP_TEST(ckaa.getSequence() == "AAAACCCCCGGGGG", TEST_AA_GET_SEQUENCE, "actual: " << ckaa.getSequence());
for (int i = 2; i < nb_seq-1; i++) { for (int i = 2; i < nb_seq-1; i++) {
// i starts at 2 because AAAA is not found: there is an ambiguity with // i starts at 2 because AAAA is not found: there is an ambiguity with
// AAAA coming from AAAACAAAACAAAAC or AAAAAAAAAAAAAAA // AAAA coming from AAAACAAAACAAAAC or AAAAAAAAAAAAAAA
...@@ -100,15 +103,18 @@ void testAffectAnalyser2() { ...@@ -100,15 +103,18 @@ void testAffectAnalyser2() {
const int k = 5; const int k = 5;
const bool revcomp = true; const bool revcomp = true;
T<KAffect> *index = createIndex<T<KAffect> >(k, revcomp); T<KAffect> *index = createIndex<T<KAffect> >(k, revcomp);
string sequence = "TTTTTGGGGG";
KmerAffectAnalyser<KAffect> kaa(*index, "TTTTTGGGGG"); KmerAffectAnalyser<KAffect> kaa(*index, sequence);
CountKmerAffectAnalyser<KAffect> ckaa(*index, "TTTTTGGGGG"); CountKmerAffectAnalyser<KAffect> ckaa(*index, sequence);
ckaa.setAllowedOverlap(k-1); ckaa.setAllowedOverlap(k-1);
set<KAffect> forbidden; set<KAffect> forbidden;
forbidden.insert(KAffect::getAmbiguous()); forbidden.insert(KAffect::getAmbiguous());
forbidden.insert(KAffect::getUnknown()); forbidden.insert(KAffect::getUnknown());
TAP_TEST(kaa.getSequence() == "TTTTTGGGGG", TEST_AA_GET_SEQUENCE, "actual: ");
TAP_TEST(ckaa.getSequence() == "TTTTTGGGGG", TEST_AA_GET_SEQUENCE, "actual: " << ckaa.getSequence());
TAP_TEST(kaa.getAffectation(1) == KAffect(seq[2*(nb_seq-1)+1], -1), TEST_AA_GET_AFFECT, ""); TAP_TEST(kaa.getAffectation(1) == KAffect(seq[2*(nb_seq-1)+1], -1), TEST_AA_GET_AFFECT, "");
TAP_TEST(kaa.count(kaa.getAffectation(1)) == 1, TEST_AA_GET_AFFECT, ""); TAP_TEST(kaa.count(kaa.getAffectation(1)) == 1, TEST_AA_GET_AFFECT, "");
TAP_TEST(ckaa.count(kaa.getAffectation(1)) == 1, TEST_COUNT_AA_COUNT, ""); TAP_TEST(ckaa.count(kaa.getAffectation(1)) == 1, TEST_COUNT_AA_COUNT, "");
...@@ -150,6 +156,8 @@ void testGetMaximum() { ...@@ -150,6 +156,8 @@ void testGetMaximum() {
vector<KmerAffect> affectations(a, a+sizeof(a)/sizeof(KmerAffect)); vector<KmerAffect> affectations(a, a+sizeof(a)/sizeof(KmerAffect));
KmerAffectAnalyser<KmerAffect> kaa(*index, "", affectations); KmerAffectAnalyser<KmerAffect> kaa(*index, "", affectations);
TAP_TEST(kaa.getSequence() == "", TEST_AA_GET_SEQUENCE, "");
affect_infos results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 2., 0); affect_infos results = kaa.getMaximum(AFFECT_J_BWD, AFFECT_V_BWD, 2., 0);
TAP_TEST(! results.max_found, TEST_AA_GET_MAXIMUM_MAX_FOUND, TAP_TEST(! results.max_found, TEST_AA_GET_MAXIMUM_MAX_FOUND,
"(" << results.first_pos_max "(" << results.first_pos_max
...@@ -272,6 +280,9 @@ void testBugAffectAnalyser() { ...@@ -272,6 +280,9 @@ void testBugAffectAnalyser() {
int total = fwdAffect.count(); int total = fwdAffect.count();
TAP_TEST(fwdAffect.getSequence() == data.read(0).sequence, TEST_AA_GET_SEQUENCE, "actual: " << fwdAffect.getSequence() << ", expected: " << data.read(0).sequence);
TAP_TEST(bwdAffect.getSequence() == data.read(1).sequence, TEST_AA_GET_SEQUENCE, "actual: " << bwdAffect.getSequence() << ", expected: " << data.read(1).sequence);
TAP_TEST(fwdAffect.count() == bwdAffect.count(), TAP_TEST(fwdAffect.count() == bwdAffect.count(),
TEST_AA_COUNT, TEST_AA_COUNT,
"Both sequences should have the same amount of affectations. " "Both sequences should have the same amount of affectations. "
......
...@@ -41,6 +41,7 @@ enum { ...@@ -41,6 +41,7 @@ enum {
TEST_AA_GET_MAXIMUM_POSITIONS, TEST_AA_GET_MAXIMUM_POSITIONS,
TEST_AA_GET_MAXIMUM_COUNTS, TEST_AA_GET_MAXIMUM_COUNTS,
TEST_AA_GET_MAXIMUM_VALUE, TEST_AA_GET_MAXIMUM_VALUE,
TEST_AA_GET_SEQUENCE,
TEST_COUNT_AA_COUNT, TEST_COUNT_AA_COUNT,
TEST_COUNT_AA_COUNT_BEFORE, TEST_COUNT_AA_COUNT_BEFORE,
TEST_COUNT_AA_COUNT_AFTER, TEST_COUNT_AA_COUNT_AFTER,
...@@ -133,6 +134,7 @@ inline void declare_tests() { ...@@ -133,6 +134,7 @@ inline void declare_tests() {
RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_POSITIONS, "KmerAffectAnalyser: getMaximum() function, positions of maximum"); RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_POSITIONS, "KmerAffectAnalyser: getMaximum() function, positions of maximum");
RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_COUNTS, "KmerAffectAnalyser: getMaximum() function, counts of affectations"); RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_COUNTS, "KmerAffectAnalyser: getMaximum() function, counts of affectations");
RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_VALUE, "KmerAffectAnalyser: getMaximum() function, maximum value"); RECORD_TAP_TEST(TEST_AA_GET_MAXIMUM_VALUE, "KmerAffectAnalyser: getMaximum() function, maximum value");
RECORD_TAP_TEST(TEST_AA_GET_SEQUENCE, "KmerAffectAnalyser: getSequence() function");
RECORD_TAP_TEST(TEST_COUNT_AA_COUNT, "CountKmerAffectAnalyser::count"); RECORD_TAP_TEST(TEST_COUNT_AA_COUNT, "CountKmerAffectAnalyser::count");
RECORD_TAP_TEST(TEST_COUNT_AA_COUNT_BEFORE, "CountKmerAffectAnalyser::countBefore"); RECORD_TAP_TEST(TEST_COUNT_AA_COUNT_BEFORE, "CountKmerAffectAnalyser::countBefore");
RECORD_TAP_TEST(TEST_COUNT_AA_COUNT_AFTER, "CountKmerAffectAnalyser::countAfter"); RECORD_TAP_TEST(TEST_COUNT_AA_COUNT_AFTER, "CountKmerAffectAnalyser::countAfter");
......
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