-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocal_constraint.cc
133 lines (119 loc) · 4.1 KB
/
local_constraint.cc
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/******************************************************************************
* Copyright (C) 2014 Juan Antonio Garcia Martin , Peter Clote, Ivan Dotu *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************/
#include "local_constraint.h"
#include "misc.h"
#include <iostream>
using namespace std;
LocalCstr::~LocalCstr(){};
LocalCstr::LocalCstr(std::string structure, int limitType, double limitValue) : LocalCstr(1, structure, limitType, limitValue){}
LocalCstr::LocalCstr(int start_pos, std::string structure, int limitType, double limitValue) :
start_pos_(start_pos),
structure_(structure),
limitType_(limitType),
limitValue_(limitValue),
has_undet_(false){
if(validSecondaryStructure(structure_, true)<0){
limitType_=LC_WRONG_STRUCTURE;
}
else{
int* tmp_int_str_=make_BasePair_Table(structure_, true);
for(int i =0; i<=structure_.length();i++){
if(tmp_int_str_[i]==-2) has_undet_= true;
int_str_.push_back(tmp_int_str_[i]);
}
free(tmp_int_str_);
}
}
LocalCstr::LocalCstr(std::string structure, const std::string limitType, double limitValue) : LocalCstr(1, structure, limitType, limitValue){}
LocalCstr::LocalCstr(int start_pos, std::string structure, const std::string limitType, double limitValue) :
start_pos_(start_pos),
structure_(structure),
limitValue_(limitValue),
has_undet_(false){
std::map<const std::string,int>::iterator it = limitTypes_.find(limitType);
if(it != limitTypes_.end()){
limitType_ = it->second;
}
else{
cout << "Invalid helix constraint type ("<<limitType<< ")"<<endl;
limitType_=LC_WRONG_TYPE;
}
if(validSecondaryStructure(structure_, true)<0){
limitType_=LC_WRONG_STRUCTURE;
}
else{
findCutPoint(&structure_);
int* tmp_int_str_=make_BasePair_Table(structure_, true);
for(int i =0; i<=structure_.length();i++){
if(tmp_int_str_[i]==-2) has_undet_= true;
int_str_.push_back(tmp_int_str_[i]);
}
free(tmp_int_str_);
}
}
int LocalCstr::getStartPos(){
return start_pos_;
}
void LocalCstr::setStartPos(int id){
start_pos_=id;
return;
}
std::string LocalCstr::getStructureStr(){
return structure_;
}
void LocalCstr::setStructureStr(std::string structure){
structure=structure;
return;
}
std::vector<int64> LocalCstr::getStructureArr(){
return int_str_;
}
void LocalCstr::setStructureArr(std::vector<int64> int_str){
int_str_=int_str;
return;
}
int LocalCstr::getLimitType(){
return limitType_;
}
void LocalCstr::setLimitType(int limitType){
limitType_=limitType;
return;
}
double LocalCstr::getLimitValue(){
return limitValue_;
}
void LocalCstr::setLimitValue(double limitValue){
limitType_=limitValue;
return;
}
bool LocalCstr::hasUndet(){
return has_undet_;
}
bool LocalCstr::isPairedConstraint(LocalCstr c){
if (this->getStructureStr().compare(c.getStructureStr())==0 && this->getStartPos()== c.getStartPos()){
return true;
}
return false;
}
std::string LocalCstr::printTypes(){
std::string outString="";
for (std::map<const std::string,int>::iterator it = limitTypes_.begin(); it != limitTypes_.end(); ++it){
outString+=it->first;
outString+=" ";
}
return outString;
}