27 #include <basic/Tracer.hh>
29 #include <utility/vector1.hh>
30 #include <numeric/xyzVector.hh>
31 #include <utility/io/izstream.hh>
32 #include <numeric/NumericTraits.hh>
35 #include <basic/options/option.hh>
36 #include <basic/options/keys/OptionKeys.hh>
37 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
39 #include <basic/prof.hh>
45 namespace frag_picker {
49 "fragment.picking.scores.InterbondAngleScore");
52 Real lowest_acceptable_value,
bool use_lowest,
std::string constraints_file_name,
55 constrainable_atoms,
"InterbondAngleScore") {
67 Real lowest_acceptable_value,
bool use_lowest,
std::string constraints_file_name,
70 "InterbondAngleScore") {
84 PROF_START( basic::FRAGMENTPICKING_DIHEDRALCONSTR_SCORE );
85 Size frag_len = fragment->get_length();
86 Size vi = fragment->get_first_index_in_vall();
87 Size qi = fragment->get_first_index_in_query();
90 for (
Size i = 0; i < frag_len; ++i) {
92 Size firstQueryResidueIndex = qi + i;
93 Size firstVallResidueIndex = vi + i;
95 if (r->get_second_offset() >= frag_len - i)
97 if (r->get_third_offset() >= frag_len - i)
99 if (r->get_fourth_offset() >= frag_len - i)
101 Size secondVallResidueIndex = firstVallResidueIndex
102 + r->get_second_offset();
103 Size thirdVallResidueIndex = firstVallResidueIndex
104 + r->get_third_offset();
105 Size fourthVallResidueIndex = firstVallResidueIndex
106 + r->get_fourth_offset();
107 if (!
has_atom(firstVallResidueIndex, r->get_first_atom()))
109 if (!
has_atom(secondVallResidueIndex, r->get_second_atom()))
111 if (!
has_atom(thirdVallResidueIndex, r->get_third_atom()))
113 if (!
has_atom(fourthVallResidueIndex, r->get_fourth_atom()))
124 double angle = angle_of(v1, v2)*180.0/numeric::NumericTraits<Real>::pi();
125 total_score += r->get_function()->func(angle);
128 total_score /= (
Real) frag_len;
129 scores->set_score_component(total_score,
id_);
130 PROF_STOP( basic::FRAGMENTPICKING_DIHEDRALCONSTR_SCORE );
134 << *fragment <<
" because its score is: " << total_score
144 utility::io::izstream data(constraints_file_name.c_str());
146 << constraints_file_name << std::endl;
148 utility_exit_with_message(
"[ERROR] Unable to open constraints file: "
149 + constraints_file_name);
156 while (!data.fail()) {
157 char c = data.peek();
158 if (c ==
'#' || c ==
'\n') {
165 <<
" end of file reached" << std::endl;
168 if (tag ==
"InterbondAngleScore") {
169 Size res1, res2, res3, res4;
174 data >> name1 >> res1 >> name2 >> res2 >> name3 >> res3 >> name4
175 >> res4 >> func_type;
178 << name2 <<
" " << name3 <<
" " << name4 <<
" " << res1
179 <<
" " << res2 <<
" " << res3 <<
" " << res4 <<
" func: "
180 << func_type << std::endl;
183 func->read_data(data);
184 std::map<std::string, Size> constr_atoms =
186 std::map<std::string, Size>::iterator it = constr_atoms.find(name1);
187 if (it == constr_atoms.end()) {
189 <<
"\nThe following constraint will NOT be used:\n"
190 << line << std::endl;
193 Size a1 = it->second;
194 it = constr_atoms.find(name2);
195 if (it == constr_atoms.end()) {
198 <<
"\nThe following constraint will NOT be used:\n"
199 << line << std::endl;
202 Size a2 = it->second;
203 it = constr_atoms.find(name3);
204 if (it == constr_atoms.end()) {
206 <<
"\nThe following constraint will NOT be used:\n"
207 << line << std::endl;
210 Size a3 = it->second;
211 it = constr_atoms.find(name4);
212 if (it == constr_atoms.end()) {
215 <<
"\nThe following constraint will NOT be used:\n"
216 << line << std::endl;
219 Size a4 = it->second;
220 Size o2 = res2 - res1;
221 Size o3 = res3 - res1;
222 Size o4 = res4 - res1;
223 if ((res2 < res1) || (res3 < res1) || (res4 < res1)) {
225 <<
"The residue of the first constrained atoms must precede all the other three.\n\t\t"
226 <<
"Check residue indexes && redefine the constraint if necessary.\n\t\t"
227 <<
"The following constraint will NOT be used:\n"
228 << line << std::endl;
234 if (res1 >
data_.size()) {
236 <<
"Skipping a constraint that involves residue "
237 << res1 <<
" that does not exist in a query"
241 data_[res1].push_back(dat);
252 using namespace basic::options;
253 using namespace basic::options::OptionKeys;
257 constrainable_atoms.push_back(
"N");
258 constrainable_atoms.push_back(
"CA");
259 constrainable_atoms.push_back(
"H");
260 constrainable_atoms.push_back(
"HA");
262 if (option[constraints::cst_file].user()) {
264 << option[constraints::cst_file]()[1] << std::endl;
267 lowest_acceptable_value, use_lowest, option[constraints::cst_file]()[1],
268 picker->size_of_query(),constrainable_atoms);
270 utility_exit_with_message(
271 "Can't read a constraints file. Provide it with constraints::cst_file flag");