Commit 522f902a authored by Carsten Kemena's avatar Carsten Kemena

Improving AlignmentMatrix

-run traceback automatically when required
-adapted tests
parent c953d67b
This diff is collapsed.
/*
* Nw_Gotoh_Test.hpp
* AlignmentMatrix_Test.hpp
*
* Created on: 20 Nov 2013
* Created on: 19 Feb 2018
* Author: Carsten Kemena
* Email: c.kemena[@]uni-muenster.de
* Copyright: 2013
* Copyright: 2018
*
* This file is part of BioSeqDataLib.
*
......@@ -70,23 +70,24 @@ BOOST_AUTO_TEST_CASE( nw_domain_test)
mat.scoring(simMat);
mat.nw(seq1, seq2);
std::vector<long> eS1, eS2;
mat.traceback(eS1, eS2);
//std::vector<long> eS1, eS2;
//mat.traceback(eS1, eS2);
std::vector<long int> expected1 { 0, -1, 1};
std::vector<long int> expected2 { 0, 1, 2};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
auto eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat2(-100, simMat);
mat2.nw(seq1, seq2);
std::vector<long> eS12, eS22;
mat2.traceback(eS12, eS22);
BOOST_CHECK_EQUAL_COLLECTIONS(eS12.begin(), eS12.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS22.begin(), eS22.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
}
BOOST_AUTO_TEST_CASE( gotoh_align_Test )
......@@ -97,16 +98,16 @@ BOOST_AUTO_TEST_CASE( gotoh_align_Test )
BioSeqDataLib::AlignmentMatrix<float, BioSeqDataLib::SimilarityMatrix<float>> mat(-11, -1, simMat);
mat.gotoh(seq1, seq2);
std::vector<long> eS1, eS2;
mat.traceback(eS1,eS2);
std::vector<long int> expected1 {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,-1,-1};
std::vector<long int> expected2 {-1, 0,1,2,3,-1,-1,-1,-1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
auto eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
}
BOOST_AUTO_TEST_CASE( Gotoh_alignDomain_Test2 )
......@@ -130,13 +131,12 @@ BOOST_AUTO_TEST_CASE( Gotoh_alignDomain_Test2 )
BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat(-50, -10, simMat);
mat.gotoh(seq1, seq2);
std::vector<long int> eS1, eS2;
mat.traceback(eS1, eS2);
std::vector<long int> expected1 { 0, 1, 2};
std::vector<long int> expected2 { -1, 0, 1};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
auto eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.score(), 190.0);
......@@ -148,12 +148,13 @@ BOOST_AUTO_TEST_CASE( Gotoh_alignDomain_Test2 )
seq1.push_back(dom);
seq2.push_back(dom);
mat.gotoh(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = {0, 1};
expected2 = {-1, 0};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.score(), 90.0);
......@@ -165,12 +166,13 @@ BOOST_AUTO_TEST_CASE( Gotoh_alignDomain_Test2 )
dom.accession("PF12881");
seq1.push_back(dom);
mat.gotoh(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = { 0, 1};
expected2 = { 0, -1};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.score(), 90.0);
mat.gep(-5);
......@@ -185,17 +187,20 @@ BOOST_AUTO_TEST_CASE( Gotoh_alignDomain_Test2 )
seq1.push_back(dom);
seq2.push_back(dom);
mat.gotoh(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = { 0, -1, 1};
expected2 = { 0, 1, 2};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.score(), 145.0);
mat.gotoh(seq2, seq1);
mat.traceback(eS1, eS2);
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL(mat.score(), 145.0);
}
......@@ -209,12 +214,14 @@ BOOST_AUTO_TEST_CASE(sw_align_test )
BioSeqDataLib::AlignmentMatrix<float, BioSeqDataLib::SimilarityMatrix<float> > mat(-3, simMat);
mat.sw(seq1, seq2);
std::vector<long int> eS1, eS2;
mat.traceback(eS1, eS2);
std::vector<long int> expected1 { 10, 11, 12, 13, 14, 15, 16, 17, -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};
std::vector<long int> expected2 { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
auto eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
}
......@@ -242,12 +249,12 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat(-10, simMat);
mat.raspodom(seq1, seq2);
std::vector<long int> eS1, eS2;
mat.traceback(eS1, eS2);
std::vector<long int> expected1 { 0, 1, 2};
std::vector<long int> expected2 { 2, 0, 1};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
auto eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), true);
BOOST_CHECK_EQUAL(mat.score(), 500);
......@@ -267,11 +274,12 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
seq2.push_back(dom);
mat.raspodom(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = { 3, 0, 1, 2};
expected2 = { -1, 2, 0, 1};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), true);
BOOST_CHECK_EQUAL(mat.score(), 490);
......@@ -292,11 +300,12 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
seq2.push_back(dom);
mat.raspodom(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = { -1, 0, 1, 2};
expected2 = { 2, 3, 0, 1};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), true);
......@@ -319,11 +328,12 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
seq2.push_back(dom);
mat.raspodom(seq1, seq2);
mat.traceback(eS1, eS2);
expected1 = { -1, -1, 0, 1, 2};
expected2 = { 0, 1, 2, 3, 4};
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
eS = mat.editString1();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected1.begin(), expected1.end());
eS = mat.editString2();
BOOST_CHECK_EQUAL_COLLECTIONS(eS.begin(), eS.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), false);
}
......
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