Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCoupling.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // This file is part of the Rosetta software suite && is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions && developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/frag_picker/scores/FragmentCrmsd.cc
10 /// @brief Object that scores a fragment by root mean square deviation of Phi && Psi dihedrals
11 /// @author Nikolas Sgourakis sgourn@u.w.edu
12 
13 
15 
18 // AUTO-REMOVED #include <protocols/frag_picker/VallProvider.hh>
20 #ifdef WIN32
22 #endif
23 
25 #include <numeric/conversions.hh>
26 
27 // option key includes
28 // AUTO-REMOVED #include <basic/options/option.hh>
29 #include <basic/options/keys/OptionKeys.hh>
30 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
31 
32 #include <basic/Tracer.hh>
33 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
34 
35 // utils
36 // AUTO-REMOVED #include <ObjexxFCL/FArray1D.hh>
37 // AUTO-REMOVED #include <basic/prof.hh>
38 
39 #include <utility/vector1.hh>
40 
41 
42 // C++
43 
44 // Boost
45 
46 namespace protocols {
47 namespace frag_picker {
48 namespace scores {
49 
50 using namespace basic::options;
51 using namespace basic::options::OptionKeys;
52 
53 static basic::Tracer trJCoupling(
54  "protocols.frag_picker.scores.JCoupling");
55 
56 JCoupling::JCoupling(Size priority, Real lowest_acceptable_value, bool use_lowest,
57  JCouplingIO& reader) :
58  CachingScoringMethod(priority, lowest_acceptable_value, use_lowest, "JCoupling"), data_(reader) {
59 
60  len_ = data_.get_length();
61  A_ = data_.get_parameters()[1];
62  B_ = data_.get_parameters()[2];
63  C_ = data_.get_parameters()[3];
65 }
66 
67 void JCoupling::do_caching(VallChunkOP current_chunk) {
68  std::string ctmp = current_chunk()->chunk_key();
69  if (ctmp.compare("change to 'cached_scores_id_' when ready") != 0) {
70  return; // CACHING NOT BUILT IN YET
71  }
72 }
73 
75  FragmentScoreMapOP scores) {
76 
77 
78  return score( fragment, scores );
79 
80 // std::string ctmp = fragment->get_chunk()->chunk_key();
81 // if (ctmp.compare(cached_scores_id_) != 0) {
82 // do_caching(fragment->get_chunk());
83 // cached_scores_id_ = ctmp;
84 // }
85 
86 // PROF_START( basic::FRAGMENTPICKING_PHIPSI_SCORE );
87 // Size offset_q = fragment->get_first_index_in_query() - 1;
88 // Size offset_v = fragment->get_first_index_in_vall() - 1;
89 // Real score = 0.0;
90 // Real tmp = 0.0;
91 // for (Size i = 1; i < fragment->get_length(); ++i) {
92 // if (!existing_data_[i + offset_q])
93 // continue;
94 // Real d = 0.0;
95 
96 // tmp = std::abs(chunk_phi_(i + offset_v) - query_phi_(i + offset_q));
97 
98 // if ( tmp > 180.0 ) tmp = std::abs(tmp - 360.0);
99 
100 // if ( tmp > query_d_phi_(i + offset_q) ) {
101 // tmp = tmp - query_d_phi_(i + offset_q);
102 // } else {
103 // tmp = 0.0;
104 // }
105 
106 // d += tmp * tmp;
107 
108 // tmp = std::abs(chunk_psi_(i + offset_v) - query_psi_(i + offset_q));
109 
110 // if ( tmp > 180.0 ) tmp = std::abs(tmp - 360.0);
111 
112 // if ( tmp > query_d_psi_(i + offset_q) ) {
113 // tmp = tmp - query_d_psi_(i + offset_q);
114 // } else {
115 // tmp = 0.0;
116 // }
117 
118 // d += tmp * tmp;
119 
120 // score += std::sqrt(d);
121 // }
122 
123 // score = score / ((Real) fragment->get_length());
124 // PROF_STOP( basic::FRAGMENTPICKING_PHIPSI_SCORE );
125 
126 // scores->set_score_component(score, id_);
127 // if ((score > lowest_acceptable_value_) && (use_lowest_ == true))
128 // return false;
129 
130 // return true;
131 }
132 
133 
135  FragmentScoreMapOP scores) {
136 
137  Size offset_q = fragment->get_first_index_in_query();
138  Size offset_v = fragment->get_first_index_in_vall();
139 
140  VallChunkOP chunk = fragment->get_chunk();
141  Real score = 0.0;
142 
143  for (Size i = 1; i <= fragment->get_length(); ++i) {
144 
145  Size query_res = offset_q + i - 1;
146  Size vall_res = offset_v + i - 1;
147 
148  VallResidueOP r = chunk->at( vall_res );
149  Real cos_phi( cos( numeric::conversions::radians(r->phi()) + THETA_ ) );
150 
151  bool has_data(false);
152 
153  std::pair< Real, Real > datum( data_.get_data( query_res, has_data ) );
154 
155  if (has_data) {
156  Real val = datum.first;
157  Real dev = datum.second;
158 
159  Real tmp((val - (A_ * cos_phi * cos_phi + B_ * cos_phi + C_)) / dev);
160 
161 // std::cout << "COMPUTE " << query_res << " " << val << " " << dev << " " << A_ << " " << B_ << " " << C_ << " " << THETA_ << " " << r->phi() << " " << r->psi() << " " << tmp << " " << (numeric::conversions::radians(r->phi()) + THETA_) << " " << cos( numeric::conversions::radians(r->phi()) + THETA_ ) << std::endl;
162 
163  score += tmp*tmp;
164 
165  }// else {
166  // std::cout << "NO DATA " << query_res << std::endl;
167  //}
168 
169  }
170 
171  score = score / ((Real) fragment->get_length());
172 
173  scores->set_score_component(score, id_);
174  if ((score > lowest_acceptable_value_) && (use_lowest_ == true))
175  return false;
176 
177  return true;
178 }
179 
181 }
182 
183 /// @brief Creates a JCoupling scoring method
184 /// @param priority - priority of the scoring method. The higher value the earlier the score
185 /// will be evaluated
186 /// @param lowest_acceptable_value - if a calculated score is higher than this value,
187 /// fragment will be neglected
188 /// @param FragmentPickerOP object - not used
189 /// @param extras - additional parameters to create a new object. Allowed values are:
190 /// - empty: then the maker tries to create a scoring object from a TALOS file
191 /// trying in::file::talos_phi_psi flag. If fails, will try to use a pose from in::file::s
192 /// - a pdb file, pdb extension is necessary. This will create a pose && steal Phi && Psi
193 /// - a TALOS file with Phi/Psi prediction (tab extension is necessary)
195  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP //picker
196  , std::string input_file) {
197 
198  if (input_file != "") {
199 
201  << "Experimental Data for JCoupling scoring loaded from file: "
202  << input_file << std::endl;
203  JCouplingIO reader(input_file);
204  //in.write(trJCoupling.Debug);
205  return (FragmentScoringMethodOP) new JCoupling(priority,
206  lowest_acceptable_value, use_lowest, reader);
207  }
208 
209  utility_exit_with_message(
210  "Can't read JCoupling file.");
211 
212  return NULL;
213 }
214 
215 } // scores
216 } // frag_picker
217 } // protocols
218 
219 
220