source: trunk/test/smith_waterman.cc @ 3209

Last change on this file since 3209 was 3209, checked in by Peter, 9 years ago

add missing source file and fix compilation error --without-samtools

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: smith_waterman.cc 3209 2014-05-04 13:52:34Z peter $
2
3/*
4  Copyright (C) 2014 Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <config.h>
23
24#include "Suite.h"
25
26#include "yat/utility/Matrix.h"
27#include "yat/utility/SmithWaterman.h"
28
29using namespace theplu::yat;
30
31int main(int argc, char* argv[])
32{
33  test::Suite suite(argc, argv);
34
35  std::string ref = "XXXXXABCDEFGHIJDKLMNOPQRSTUVWXYZABCDEFGHXXXXXXXXXXXXXXX";
36  std::string seq =    "SSABCDEFGHIJKLMNOPQRSTUIVWXYZxBCDEFGHS";
37
38  suite.out() << "ref: " << ref << "\n";
39  suite.out() << "seq: " << seq << "\n";
40
41  utility::SmithWaterman sw(2,3);
42  double score = sw(ref.begin(), ref.end(), seq.begin(), seq.end(), 3);
43  suite.out() << "sw score: " << score << "\n";
44
45  utility::Aligner::Cigar cig = sw.cigar();
46  std::ostringstream os;
47  os << cig;
48  suite.out() << os.str() << "\n";
49  std::string str = "2S10=1D11=1I5=1X7=1S";
50  if (os.str()!=str) {
51    suite.add(false);
52    suite.err() << "error: incorrect CIGAR string, expected\n" << str << "\n";
53  }
54
55  suite.out() << "pos: " << sw.position() << "\n";
56  if (sw.position()!=5)
57    suite.err() << "error: wrong position: " << sw.position()
58                << " expected 4\n";
59
60  utility::Matrix x = sw.score();
61  return suite.return_value();
62}
Note: See TracBrowser for help on using the repository browser.