4353 |
23 Aug 23 |
peter |
// $Id$ |
4353 |
23 Aug 23 |
peter |
2 |
|
4353 |
23 Aug 23 |
peter |
3 |
/* |
4353 |
23 Aug 23 |
peter |
Copyright (C) 2023 Peter Johansson |
4353 |
23 Aug 23 |
peter |
5 |
|
4353 |
23 Aug 23 |
peter |
This file is part of the yat library, https://dev.thep.lu.se/yat |
4353 |
23 Aug 23 |
peter |
7 |
|
4353 |
23 Aug 23 |
peter |
The yat library is free software; you can redistribute it and/or |
4353 |
23 Aug 23 |
peter |
modify it under the terms of the GNU General Public License as |
4353 |
23 Aug 23 |
peter |
published by the Free Software Foundation; either version 3 of the |
4353 |
23 Aug 23 |
peter |
License, or (at your option) any later version. |
4353 |
23 Aug 23 |
peter |
12 |
|
4353 |
23 Aug 23 |
peter |
The yat library is distributed in the hope that it will be useful, |
4353 |
23 Aug 23 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4353 |
23 Aug 23 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4353 |
23 Aug 23 |
peter |
General Public License for more details. |
4353 |
23 Aug 23 |
peter |
17 |
|
4353 |
23 Aug 23 |
peter |
You should have received a copy of the GNU General Public License |
4353 |
23 Aug 23 |
peter |
along with yat. If not, see <https://www.gnu.org/licenses/>. |
4353 |
23 Aug 23 |
peter |
20 |
*/ |
4353 |
23 Aug 23 |
peter |
21 |
|
4353 |
23 Aug 23 |
peter |
22 |
#include <config.h> |
4353 |
23 Aug 23 |
peter |
23 |
|
4353 |
23 Aug 23 |
peter |
24 |
#include "mAlignerBase.h" |
4353 |
23 Aug 23 |
peter |
25 |
|
4353 |
23 Aug 23 |
peter |
26 |
#include "Aligner.h" |
4353 |
23 Aug 23 |
peter |
27 |
|
4353 |
23 Aug 23 |
peter |
28 |
namespace theplu { |
4353 |
23 Aug 23 |
peter |
29 |
namespace yat { |
4353 |
23 Aug 23 |
peter |
30 |
namespace utility { |
4353 |
23 Aug 23 |
peter |
31 |
|
4353 |
23 Aug 23 |
peter |
32 |
mAlignerBase::mAlignerBase(const Affine& insertion, const Affine& deletion) |
4353 |
23 Aug 23 |
peter |
33 |
: insertion_(insertion), deletion_(deletion) |
4353 |
23 Aug 23 |
peter |
34 |
{} |
4353 |
23 Aug 23 |
peter |
35 |
|
4353 |
23 Aug 23 |
peter |
36 |
|
4353 |
23 Aug 23 |
peter |
37 |
const mAlignerBase::Cigar& mAlignerBase::cigar(void) const |
4353 |
23 Aug 23 |
peter |
38 |
{ |
4353 |
23 Aug 23 |
peter |
39 |
return best_.cigar(); |
4353 |
23 Aug 23 |
peter |
40 |
} |
4353 |
23 Aug 23 |
peter |
41 |
|
4353 |
23 Aug 23 |
peter |
42 |
|
4353 |
23 Aug 23 |
peter |
43 |
const mAlignerBase::Cigar& mAlignerBase::cigar2(void) const |
4353 |
23 Aug 23 |
peter |
44 |
{ |
4353 |
23 Aug 23 |
peter |
45 |
return cigar2_; |
4353 |
23 Aug 23 |
peter |
46 |
} |
4353 |
23 Aug 23 |
peter |
47 |
|
4353 |
23 Aug 23 |
peter |
48 |
|
4353 |
23 Aug 23 |
peter |
49 |
size_t mAlignerBase::position(void) const |
4353 |
23 Aug 23 |
peter |
50 |
{ |
4353 |
23 Aug 23 |
peter |
51 |
return best_.position(); |
4353 |
23 Aug 23 |
peter |
52 |
} |
4353 |
23 Aug 23 |
peter |
53 |
|
4353 |
23 Aug 23 |
peter |
54 |
|
4353 |
23 Aug 23 |
peter |
55 |
double mAlignerBase::score(void) const |
4353 |
23 Aug 23 |
peter |
56 |
{ |
4353 |
23 Aug 23 |
peter |
57 |
return best_.score(); |
4353 |
23 Aug 23 |
peter |
58 |
} |
4353 |
23 Aug 23 |
peter |
59 |
|
4353 |
23 Aug 23 |
peter |
60 |
|
4353 |
23 Aug 23 |
peter |
61 |
mAlignerBase::Affine::Affine(double pen, double open) |
4353 |
23 Aug 23 |
peter |
62 |
: pen_(pen), open_(open) |
4353 |
23 Aug 23 |
peter |
63 |
{} |
4353 |
23 Aug 23 |
peter |
64 |
|
4353 |
23 Aug 23 |
peter |
65 |
|
4353 |
23 Aug 23 |
peter |
66 |
double mAlignerBase::Affine::operator()(size_t k) const |
4353 |
23 Aug 23 |
peter |
67 |
{ |
4353 |
23 Aug 23 |
peter |
68 |
return k ? open_ + k*pen_ : 0; |
4353 |
23 Aug 23 |
peter |
69 |
} |
4353 |
23 Aug 23 |
peter |
70 |
|
4353 |
23 Aug 23 |
peter |
71 |
|
4353 |
23 Aug 23 |
peter |
72 |
double mAlignerBase::Affine::penalty(void) const |
4353 |
23 Aug 23 |
peter |
73 |
{ |
4353 |
23 Aug 23 |
peter |
74 |
return pen_; |
4353 |
23 Aug 23 |
peter |
75 |
} |
4353 |
23 Aug 23 |
peter |
76 |
|
4353 |
23 Aug 23 |
peter |
77 |
|
4353 |
23 Aug 23 |
peter |
78 |
double mAlignerBase::Affine::open_penalty(void) const |
4353 |
23 Aug 23 |
peter |
79 |
{ |
4353 |
23 Aug 23 |
peter |
80 |
return open_; |
4353 |
23 Aug 23 |
peter |
81 |
} |
4353 |
23 Aug 23 |
peter |
82 |
|
4353 |
23 Aug 23 |
peter |
83 |
|
4353 |
23 Aug 23 |
peter |
84 |
mAlignerBase::Alignment::Alignment(void) |
4353 |
23 Aug 23 |
peter |
85 |
: position_(0), score_(-std::numeric_limits<double>::infinity()) |
4353 |
23 Aug 23 |
peter |
86 |
{} |
4353 |
23 Aug 23 |
peter |
87 |
|
4353 |
23 Aug 23 |
peter |
88 |
|
4353 |
23 Aug 23 |
peter |
89 |
Aligner::Cigar& mAlignerBase::Alignment::cigar(void) |
4353 |
23 Aug 23 |
peter |
90 |
{ |
4353 |
23 Aug 23 |
peter |
91 |
return cigar_; |
4353 |
23 Aug 23 |
peter |
92 |
} |
4353 |
23 Aug 23 |
peter |
93 |
|
4353 |
23 Aug 23 |
peter |
94 |
|
4353 |
23 Aug 23 |
peter |
95 |
const Aligner::Cigar& mAlignerBase::Alignment::cigar(void) const |
4353 |
23 Aug 23 |
peter |
96 |
{ |
4353 |
23 Aug 23 |
peter |
97 |
return cigar_; |
4353 |
23 Aug 23 |
peter |
98 |
} |
4353 |
23 Aug 23 |
peter |
99 |
|
4353 |
23 Aug 23 |
peter |
100 |
|
4353 |
23 Aug 23 |
peter |
101 |
size_t& mAlignerBase::Alignment::position(void) |
4353 |
23 Aug 23 |
peter |
102 |
{ |
4353 |
23 Aug 23 |
peter |
103 |
return position_; |
4353 |
23 Aug 23 |
peter |
104 |
} |
4353 |
23 Aug 23 |
peter |
105 |
|
4353 |
23 Aug 23 |
peter |
106 |
|
4353 |
23 Aug 23 |
peter |
107 |
const size_t& mAlignerBase::Alignment::position(void) const |
4353 |
23 Aug 23 |
peter |
108 |
{ |
4353 |
23 Aug 23 |
peter |
109 |
return position_; |
4353 |
23 Aug 23 |
peter |
110 |
} |
4353 |
23 Aug 23 |
peter |
111 |
|
4353 |
23 Aug 23 |
peter |
112 |
|
4353 |
23 Aug 23 |
peter |
113 |
double& mAlignerBase::Alignment::score(void) |
4353 |
23 Aug 23 |
peter |
114 |
{ |
4353 |
23 Aug 23 |
peter |
115 |
return score_; |
4353 |
23 Aug 23 |
peter |
116 |
} |
4353 |
23 Aug 23 |
peter |
117 |
|
4353 |
23 Aug 23 |
peter |
118 |
|
4353 |
23 Aug 23 |
peter |
119 |
const double& mAlignerBase::Alignment::score(void) const |
4353 |
23 Aug 23 |
peter |
120 |
{ |
4353 |
23 Aug 23 |
peter |
121 |
return score_; |
4353 |
23 Aug 23 |
peter |
122 |
} |
4353 |
23 Aug 23 |
peter |
123 |
|
4353 |
23 Aug 23 |
peter |
124 |
|
4353 |
23 Aug 23 |
peter |
125 |
bool |
4353 |
23 Aug 23 |
peter |
126 |
mAlignerBase::Alignment::operator<(const mAlignerBase::Alignment& other) const |
4353 |
23 Aug 23 |
peter |
127 |
{ |
4353 |
23 Aug 23 |
peter |
128 |
return score_ < other.score_; |
4353 |
23 Aug 23 |
peter |
129 |
} |
4353 |
23 Aug 23 |
peter |
130 |
|
4353 |
23 Aug 23 |
peter |
131 |
|
4353 |
23 Aug 23 |
peter |
// MatchKernel |
4353 |
23 Aug 23 |
peter |
133 |
mAlignerBase::MatchKernel::MatchKernel(double mismatch_pen) |
4353 |
23 Aug 23 |
peter |
134 |
: mismatch_(mismatch_pen) |
4353 |
23 Aug 23 |
peter |
135 |
{} |
4353 |
23 Aug 23 |
peter |
136 |
|
4353 |
23 Aug 23 |
peter |
137 |
}}} |