4340 |
16 Apr 23 |
peter |
// $Id$ |
4340 |
16 Apr 23 |
peter |
2 |
|
4340 |
16 Apr 23 |
peter |
3 |
/* |
4340 |
16 Apr 23 |
peter |
Copyright (C) 2023 Peter Johansson |
4340 |
16 Apr 23 |
peter |
5 |
|
4340 |
16 Apr 23 |
peter |
This file is part of the yat library, https://dev.thep.lu.se/yat |
4340 |
16 Apr 23 |
peter |
7 |
|
4340 |
16 Apr 23 |
peter |
The yat library is free software; you can redistribute it and/or |
4340 |
16 Apr 23 |
peter |
modify it under the terms of the GNU General Public License as |
4340 |
16 Apr 23 |
peter |
published by the Free Software Foundation; either version 3 of the |
4340 |
16 Apr 23 |
peter |
License, or (at your option) any later version. |
4340 |
16 Apr 23 |
peter |
12 |
|
4340 |
16 Apr 23 |
peter |
The yat library is distributed in the hope that it will be useful, |
4340 |
16 Apr 23 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4340 |
16 Apr 23 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4340 |
16 Apr 23 |
peter |
General Public License for more details. |
4340 |
16 Apr 23 |
peter |
17 |
|
4340 |
16 Apr 23 |
peter |
You should have received a copy of the GNU General Public License |
4340 |
16 Apr 23 |
peter |
along with yat. If not, see <https://www.gnu.org/licenses/>. |
4340 |
16 Apr 23 |
peter |
20 |
*/ |
4340 |
16 Apr 23 |
peter |
21 |
|
4340 |
16 Apr 23 |
peter |
22 |
#include <config.h> |
4340 |
16 Apr 23 |
peter |
23 |
|
4340 |
16 Apr 23 |
peter |
24 |
#include "mNeedlemanWunsch.h" |
4340 |
16 Apr 23 |
peter |
25 |
|
4340 |
16 Apr 23 |
peter |
26 |
namespace theplu { |
4340 |
16 Apr 23 |
peter |
27 |
namespace yat { |
4340 |
16 Apr 23 |
peter |
28 |
namespace utility { |
4340 |
16 Apr 23 |
peter |
29 |
|
4340 |
16 Apr 23 |
peter |
30 |
mNeedlemanWunsch::mNeedlemanWunsch(double gap, double open_gap) |
4340 |
16 Apr 23 |
peter |
31 |
: mNeedlemanWunsch(gap, open_gap, gap, open_gap) |
4340 |
16 Apr 23 |
peter |
32 |
{} |
4340 |
16 Apr 23 |
peter |
33 |
|
4340 |
16 Apr 23 |
peter |
34 |
|
4340 |
16 Apr 23 |
peter |
35 |
mNeedlemanWunsch::mNeedlemanWunsch(double insertion_penalty, |
4340 |
16 Apr 23 |
peter |
36 |
double open_insertion_penalty, |
4340 |
16 Apr 23 |
peter |
37 |
double deletion_penalty, |
4340 |
16 Apr 23 |
peter |
38 |
double open_deletion_penalty) |
4353 |
23 Aug 23 |
peter |
39 |
: mAligner<mNeedlemanWunsch>(Affine(insertion_penalty, |
4353 |
23 Aug 23 |
peter |
40 |
open_insertion_penalty), |
4353 |
23 Aug 23 |
peter |
41 |
Affine(deletion_penalty, |
4353 |
23 Aug 23 |
peter |
42 |
open_deletion_penalty)) |
4340 |
16 Apr 23 |
peter |
43 |
{} |
4340 |
16 Apr 23 |
peter |
44 |
|
4340 |
16 Apr 23 |
peter |
45 |
|
4353 |
23 Aug 23 |
peter |
46 |
double mNeedlemanWunsch::init_row(size_t q) const |
4340 |
16 Apr 23 |
peter |
47 |
{ |
4353 |
23 Aug 23 |
peter |
48 |
return -deletion_(q); |
4340 |
16 Apr 23 |
peter |
49 |
} |
4340 |
16 Apr 23 |
peter |
50 |
|
4340 |
16 Apr 23 |
peter |
51 |
|
4353 |
23 Aug 23 |
peter |
52 |
double mNeedlemanWunsch::init_col(size_t r) const |
4340 |
16 Apr 23 |
peter |
53 |
{ |
4353 |
23 Aug 23 |
peter |
54 |
return -insertion_(r); |
4340 |
16 Apr 23 |
peter |
55 |
} |
4340 |
16 Apr 23 |
peter |
56 |
|
4340 |
16 Apr 23 |
peter |
57 |
|
4353 |
23 Aug 23 |
peter |
58 |
double mNeedlemanWunsch::init(size_t r, size_t q) const |
4340 |
16 Apr 23 |
peter |
59 |
{ |
4353 |
23 Aug 23 |
peter |
60 |
return -std::numeric_limits<double>::infinity(); |
4340 |
16 Apr 23 |
peter |
61 |
} |
4340 |
16 Apr 23 |
peter |
62 |
|
4340 |
16 Apr 23 |
peter |
63 |
|
4353 |
23 Aug 23 |
peter |
64 |
void mNeedlemanWunsch::update(const std::vector<Alignment>& alignments, |
4353 |
23 Aug 23 |
peter |
65 |
size_t r, size_t rsize) |
4340 |
16 Apr 23 |
peter |
66 |
{ |
4353 |
23 Aug 23 |
peter |
67 |
if (r+1 == rsize) |
4353 |
23 Aug 23 |
peter |
68 |
best_ = alignments.back(); |
4340 |
16 Apr 23 |
peter |
69 |
} |
4340 |
16 Apr 23 |
peter |
70 |
|
4340 |
16 Apr 23 |
peter |
71 |
}}} |