Commit c953d67b authored by Carsten Kemena's avatar Carsten Kemena

adding more tests to RASPODOM

parent 7d971f8b
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.2)
# onec cmake 3 will be used
#set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-std=c++11)
......@@ -40,7 +40,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wunused -pedantic -Wall -Wextra")# -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wunused")# -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused")
endif ()
#message(${CMAKE_CXX_FLAGS})
#-Wshadow
......
......@@ -22,6 +22,10 @@
* along with BioSeqDataLib. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file AlignmentMatrix.hpp
* \brief Header containing the AlignmentMatrix class.
*/
#ifndef AlignmentMatrix_hpp
#define AlignmentMatrix_hpp
......@@ -39,6 +43,11 @@
namespace BioSeqDataLib
{
/**
* \class AlignmentMatrix
* \brief A class that handled the computation of pairwise Alignments
*/
template<typename DataType, typename SimMat>
class AlignmentMatrix {
private:
......@@ -75,6 +84,7 @@ private:
traceback_sw_(std::vector<long int> &editString1, std::vector<long int> &editString2);
using MatchTracker = std::set<std::pair<size_t, size_t> >;
bool
traceback_raspodom_optimal_path_(MatchTracker &matches_tl, MatchTracker &matches_tr,
MatchTracker &matches_bl, MatchTracker &matches_br, std::vector<long int> &editString1, std::vector<long int> &editString2);
......@@ -84,35 +94,73 @@ private:
MatchTracker &matches_bl, MatchTracker &matches_br);
public:
/**
* Default constructor
*/
AlignmentMatrix()
{}
/**
* \brief Constructor for using homogenous gap costs (nw, sw, raspodom)
* @param gep Gap extension costs
* @param simMat Match penalty costs. Either of Type SimilarityMatrix for sequences or DSM otherwise.
*/
AlignmentMatrix(DataType gep, const SimMat &simMat) : gep_(gep), simMat_(simMat)
{}
/**
* \brief Constructor for using affine gap pentalties (gotoh)
* @param gop Gap opening costs
* @param gep Gep extension pentalties
* @param simMat Similarity matrix
*/
AlignmentMatrix(DataType gop, DataType gep, const SimMat &simMat) : gop_(gop), gep_(gep), simMat_(simMat)
{}
~AlignmentMatrix()
{}
/**
* Runs the Needleman-Wunsch algorithm on the matrix.
* @param seq1 First sequece
* @param seq2 Second sequence
*/
template<typename SeqType>
void
nw(const SeqType &seq1, const SeqType &seq2);
/**
* \brief Run the Gotoh algorithm
* @param seq1 First sequence
* @param seq2 Second sequence
*/
template<typename SeqType>
void
gotoh(const SeqType &seq1, const SeqType &seq2);
/**
* \brief Run the Smith-Waterman algorithm
* @param seq1 First sequence
* @param seq2 Second sequence
*/
template<typename SeqType>
void
sw(const SeqType &seq1, const SeqType &seq2);
/**
* \brief Run the RASPDOM algorithm
* @param seq1 First sequence
* @param seq2 Second sequence
*/
template<typename SeqType>
void
raspodom(const SeqType &seq1, const SeqType &seq2);
/**
* \brief performs a traceback
* @param editString1 The editString of the first sequence
* @param editString2 The editString of the second sequence
*/
void
traceback(std::vector<long int> &editString1, std::vector<long int> &editString2)
{
......@@ -134,30 +182,50 @@ public:
}
}
/**
* \brief Sets the gap extension penalites, used as well as homogenous gap costs.
* @param penalty Value of the gap costs.
*/
void
gep(DataType penalty)
{
gep_ = penalty;
}
/**
* \brief Sets gap opening penalties.
* @param penalty Value of the gap costs.
*/
void
gop(DataType penalty)
{
gop_ = penalty;
}
/**
* \brief Sets the similarity Matrix.
* @param mat The matrix to use.
*/
void
scoring(const SimMat &mat)
{
simMat_ = mat;
}
/**
* \brief Returns the score of the calculated alignment.
* @return The score of the alignment.
*/
DataType
score()
{
return score_;
}
/**
* \brief Returns whether the RASPDOM algorithm has determined the two sequences to be a circular permutation.
* @return true if a circular permutation was detected, otherwise false
*/
bool
isCP()
{
......
......@@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
dom.accession("PF00001");
seq2.push_back(dom);
BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat(-50, -10, simMat);
BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat(-10, simMat);
mat.raspodom(seq1, seq2);
std::vector<long int> eS1, eS2;
mat.traceback(eS1, eS2);
......@@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), true);
BOOST_CHECK_EQUAL(mat.score(), 500);
seq1.clear();
seq2.clear();
......@@ -273,6 +273,7 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
BOOST_CHECK_EQUAL_COLLECTIONS(eS1.begin(), eS1.end(), expected1.begin(), expected1.end());
BOOST_CHECK_EQUAL_COLLECTIONS(eS2.begin(), eS2.end(), expected2.begin(), expected2.end());
BOOST_CHECK_EQUAL(mat.isCP(), true);
BOOST_CHECK_EQUAL(mat.score(), 490);
seq1.clear();
......@@ -299,51 +300,32 @@ BOOST_AUTO_TEST_CASE(raspodom_align_domain_test )
BOOST_CHECK_EQUAL(mat.isCP(), true);
// seq2.push_back(dom);
/* dom.accession("PF00001");
seq1.clear();
seq2.clear();
dom.accession("PF00001");
seq1.push_back(dom);
dom.accession("PF00002");
seq1.push_back(dom);
dom.accession("PF00003");
seq1.push_back(dom);
dom.accession("PF00244");
seq1.push_back(dom);
seq2.push_back(dom);
dom.accession("PF00245");
seq1.push_back(dom);
seq2.push_back(dom);
dom.accession("PF00246");
dom.accession("PF00003");
seq1.push_back(dom);
seq2.push_back(dom);
dom.accession("PF00001");
//seq2.push_back(dom);
seq2.push_back(dom);
dom.accession("PF00002");
//seq2.push_back(dom);
seq2.push_back(dom);
dom.accession("PF00003");
//seq2.push_back(dom);
*/
/*BioSeqDataLib::AlignmentMatrix<int, BioSeqDataLib::DSM> mat(-50, -10, simMat);
seq2.push_back(dom);
mat.raspodom(seq1, seq2);
std::vector<long int> eS1, eS2;
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());
BOOST_CHECK_EQUAL(mat.isCP(), false);
for (auto elem : eS1)
std::cout << elem << " ";
std::cout << "\n";
for (auto elem : eS2)
std::cout << elem << " ";
std::cout << "\n";
std::cout << mat.isCP() << "\n";*/
//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());
//BOOST_CHECK_EQUAL(mat.score(), 190.0);
}
BOOST_AUTO_TEST_SUITE_END()
......
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