26 #include <utility/vector1.hh>
27 #include <numeric/xyzVector.hh>
28 #include <utility/io/izstream.hh>
29 #include <basic/prof.hh>
30 #include <basic/Tracer.hh>
33 #include <basic/options/option.hh>
34 #include <basic/options/keys/OptionKeys.hh>
35 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
38 namespace frag_picker {
45 "fragment.picking.scores.AtomPairConstraintsScore");
56 Real lowest_acceptable_value,
bool use_lowest,
std::string constraints_file_name,
59 constrainable_atoms,
"AtomPairConstraintsScore") {
74 Real lowest_acceptable_value,
bool use_lowest,
std::string constraints_file_name,
77 "AtomPairConstraintsScore") {
90 PROF_START( basic::FRAGMENTPICKING_ATOMPAIR_SCORE );
92 Size frag_len = fragment->get_length();
93 Size vi = fragment->get_first_index_in_vall();
94 Size qi = fragment->get_first_index_in_query();
97 for (
Size i = 0; i < frag_len; ++i) {
99 Size firstQueryResidueIndex = qi + i;
101 if (r->get_offset() >= frag_len - i)
103 Size firstVallResidueIndex = vi + i;
104 Size secondVallResidueIndex = firstVallResidueIndex
106 if (!
has_atom(firstVallResidueIndex, r->get_first_atom()))
108 if (!
has_atom(secondVallResidueIndex, r->get_second_atom()))
111 assert (fragment->get_chunk()->size() >=secondVallResidueIndex);
114 firstVallResidueIndex, r->get_first_atom());
116 secondVallResidueIndex, r->get_second_atom());
117 Real d = v1.distance(v2);
118 total_score += r->get_function()->func(d);
121 total_score /= (
Real) frag_len;
122 scores->set_score_component(total_score,
id_);
123 PROF_STOP( basic::FRAGMENTPICKING_ATOMPAIR_SCORE );
126 << *fragment <<
" because its score is: " << total_score
136 utility::io::izstream data(constraints_file_name.c_str());
138 << constraints_file_name << std::endl;
140 utility_exit_with_message(
"[ERROR] Unable to open constraints file: "
141 + constraints_file_name);
148 while (!data.fail()) {
149 char c = data.peek();
150 if (c ==
'#' || c ==
'\n') {
157 <<
" end of file reached" << std::endl;
160 if (tag ==
"AtomPair") {
163 data >> name1 >> id1 >> name2 >> id2 >> func_type;
165 <<
" " << name2 <<
" " << id2 <<
" func: " << func_type
169 func->read_data(data);
170 std::map<std::string, Size> constr_atoms =
172 std::map<std::string, Size>::iterator it = constr_atoms.find(name1);
173 if (it == constr_atoms.end()) {
176 <<
"\nThe following constraint will NOT be used:\n"
177 << line << std::endl;
180 Size a1 = it->second;
181 it = constr_atoms.find(name2);
182 if (it == constr_atoms.end()) {
185 <<
"\nThe following constraint will NOT be used:\n"
186 << line << std::endl;
189 Size a2 = it->second;
194 <<
"Constrained atom id exceeds the length of a query sequence. The following constraint will NOT be used:\n"
195 << line << std::endl;
199 data_[id1].push_back(dat);
204 <<
"Constrained atom id exceeds the length of a query sequence. The following constraint will NOT be used:\n"
205 << line << std::endl;
209 data_[id2].push_back(dat);
221 using namespace basic::options;
222 using namespace basic::options::OptionKeys;
224 if (option[constraints::cst_file].user()) {
226 << option[constraints::cst_file]()[1] << std::endl;
229 lowest_acceptable_value, use_lowest, option[constraints::cst_file]()[1],
230 picker->size_of_query());
232 utility_exit_with_message(
233 "Can't read a constraints file. Provide it with constraints::cst_file flag");