Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragmentAllAtomCrmsd.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/FragmentAllAtomCrmsd.cc
10 /// @brief Object that scores a fragment by its crmsd to the native
11 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
12 
19 #ifdef WIN32
21 #endif
22 
23 // option key includes
24 #include <basic/options/option.hh>
25 #include <basic/options/keys/OptionKeys.hh>
26 #include <basic/options/keys/in.OptionKeys.gen.hh>
27 
29 #include <basic/Tracer.hh>
30 
31 
32 #include <numeric/model_quality/rms.hh>
33 
34 // utils
35 #include <ObjexxFCL/FArray2D.hh>
36 #include <ObjexxFCL/FArray1D.hh>
37 // AUTO-REMOVED #include <basic/prof.hh>
38 
40 #include <core/id/NamedAtomID.hh>
43 #include <utility/vector1.hh>
44 #include <fstream>
45 
46 
47 namespace protocols {
48 namespace frag_picker {
49 namespace scores {
50 
51 using namespace basic::options;
52 using namespace basic::options::OptionKeys;
53 
54 static basic::Tracer trRmsScore(
55  "protocols.frag_picker.scores.FragmentAllAtomCrmsd");
56 
58 
59 FragmentAllAtomCrmsd::FragmentAllAtomCrmsd(Size priority, Real lowest_acceptable_value,
60  bool use_lowest, std::string query_sequence, core::pose::PoseOP reference_pose) :
61  FragmentScoringMethod(priority, lowest_acceptable_value, use_lowest, "FragmentAllAtomCrmsd"), query_sequence_(query_sequence) {
62 
63  reference_pose_ = reference_pose;
65  total_ref_resids_ = reference_pose_->total_residue();
66  reference_coordinates_.redimension(3, 4 * total_ref_resids_, 0.0);
68  weights_.redimension(reference_pose_->total_residue() * 4, 1.0);
69 
70  core::pose::make_pose_from_sequence(*fragment_pose_, reference_pose_->sequence(), *(chemical::ChemicalManager::get_instance()->residue_type_set("centroid")));
71 }
72 
73 FragmentAllAtomCrmsd::FragmentAllAtomCrmsd(Size priority, Real lowest_acceptable_value, bool use_lowest,
75  FragmentScoringMethod(priority, lowest_acceptable_value, use_lowest, "FragmentAllAtomCrmsd"),
76  query_sequence_(query_sequence) {
77 
78  total_ref_resids_ = xyz.size() / 5;
80  reference_coordinates_.redimension(3, 4 * total_ref_resids_, 0.0);
81  weights_.redimension(total_ref_resids_ * 4, 1.0);
82  for (core::Size i = 1; i <= total_ref_resids_ * 4; i++) {
83  trRmsScore.Trace << i<<" ";
84  for (core::Size d = 1; d <= 3; ++d) {
85  reference_coordinates_(d, i) = xyz[i][d];
86  trRmsScore.Trace <<xyz[i][d]<<" ";
87  }
88  trRmsScore.Trace <<std::endl;
89  }
90  core::pose::make_pose_from_sequence(*fragment_pose_, reference_pose_->sequence(), *(chemical::ChemicalManager::get_instance()->residue_type_set("centroid")));
91 }
92 
94  FArray2_double& coords, Size n_res, std::string ) {
95 
96  trRmsScore.Debug << "Copying coordinates from ... The first residues are: "
97  << pose.residue(1).name3() << " " << pose.residue(2).name3() << " "
98  << pose.residue(3).name3() << std::endl;
99 
100  core::Size n_at = 1;
101  for (core::Size i = 1; i <= n_res; i++) {
102  id::NamedAtomID idN("N", i);
103  PointPosition const& xyzN = pose.xyz(idN);
104  for (core::Size d = 1; d <= 3; ++d) {
105  coords(d, n_at) = xyzN[d - 1];
106  }
107  n_at++;
108 
109  id::NamedAtomID idCA("CA", i);
110  PointPosition const& xyzCA = pose.xyz(idCA);
111  for (core::Size d = 1; d <= 3; ++d) {
112  coords(d, i) = xyzCA[d - 1];
113  }
114  n_at++;
115 
116  id::NamedAtomID idC("C", i);
117  PointPosition const& xyzC = pose.xyz(idC);
118  for (core::Size d = 1; d <= 3; ++d) {
119  coords(d, n_at) = xyzC[d - 1];
120  }
121  n_at++;
122 
123  id::NamedAtomID idO("O", i);
124  PointPosition const& xyzO = pose.xyz(idO);
125  for (core::Size d = 1; d <= 3; ++d) {
126  coords(d, i) = xyzO[d - 1];
127  }
128  n_at++;
129  }
130 }
131 
133 
134 
135  if ((Size) fragment_coordinates_.size2() < f->get_length() * 4) {
136  fragment_coordinates_.redimension(3, f->get_length()*4, 0.0);
137  frag_pos_coordinates_.redimension(3, f->get_length()*4, 0.0);
138  }
139  for (Size i = 1; i <= f->get_length(); i++) {
140  fragment_pose_->set_phi( i, f->get_residue(i)->phi() );
141  fragment_pose_->set_psi( i, f->get_residue(i)->psi() );
142  fragment_pose_->set_omega( i, f->get_residue(i)->omega() );
143 
144  for (core::Size d = 1; d <= 3; ++d) {
145 // std::cerr << i << " " << reference_coordinates_.size2() << " " << frag_pos_coordinates_.size2() << " " << f->get_first_index_in_query()<< std::endl;
146  frag_pos_coordinates_(d,i) = reference_coordinates_(d,i + f->get_first_index_in_query() - 1);
147  }
148  }
149 
150  fill_coords(*fragment_pose_, fragment_coordinates_, f->get_length(), f->sequence());
151 
152  Real rms = numeric::model_quality::rms_wrapper(f->get_length(),
154 
155  empty_map->set_score_component(rms, id_);
156 
157  if ((rms > lowest_acceptable_value_) && (use_lowest_ == true))
158  return false;
159 
160  return true;
161 }
162 
163 
165  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP //picker
166  , std::string) {
167 
168  if (option[in::file::native].user()) {
169  trRmsScore
170  << "Reference structure to score fragments by crmsd loaded from: "
171  << option[in::file::native]() << std::endl;
172  core::pose::PoseOP nativePose = new core::pose::Pose;
173  core::import_pose::pose_from_pdb(*nativePose, option[in::file::native]());
174 
175  return (FragmentScoringMethodOP) new FragmentAllAtomCrmsd(priority,
176  lowest_acceptable_value, use_lowest, nativePose->sequence(), nativePose);
177  }
178  if (option[in::file::s].user()) {
179  trRmsScore
180  << "Reference structure to score fragments by crmsd loaded from: "
181  << option[in::file::s]()[1] << std::endl;
182  core::pose::PoseOP nativePose = new core::pose::Pose;
183  core::import_pose::pose_from_pdb(*nativePose, option[in::file::s]()[1]);
184 
185  return (FragmentScoringMethodOP) new FragmentAllAtomCrmsd(priority,
186  lowest_acceptable_value, use_lowest, nativePose->sequence(), nativePose);
187  }
188  if (option[in::file::xyz].user()) {
189 
190  trRmsScore
191  << "Reference structure to score fragments by crmsd loaded from: "
192  << option[in::file::xyz]().c_str() << std::endl;
193  std::string line;
195  // std::istream & input = utility::io::izstream( option[ in::file::xyz ]().c_str() );
196  std::ifstream input( option[ in::file::xyz ]().c_str() );
197 
198  std::string seq;
199  while( getline( input, line ) ) {
200  trRmsScore.Warning << line<<std::endl;
201  if ( line.substr(0,1) == "#" ) continue;
202  std::istringstream line_stream( line );
204  Real x,y,z;
205  char c;
206  line_stream >> c >> x >> y >> z;
207  seq += c;
208  row.push_back(x);
209  row.push_back(y);
210  row.push_back(z);
211  xyz.push_back( row );
212  }
213  trRmsScore << xyz.size() << " atoms found in the reference" << std::endl;
214 
215  return (FragmentScoringMethodOP) new FragmentAllAtomCrmsd(priority,
216  lowest_acceptable_value, use_lowest, seq, xyz);
217  }
218  utility_exit_with_message(
219  "Can't read a reference structure. Provide it with in::file::s flag");
220 
221  return NULL;
222 }
223 
224 } // scores
225 } // frag_picker
226 } // protocols