Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GunnCostScore.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/GunnCostScore.cc
10 /// @brief Object that scores a fragment by its crmsd to the native
11 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
12 
18 
19 // option key includes
20 #include <basic/options/option.hh>
21 #include <basic/options/keys/OptionKeys.hh>
22 #include <basic/options/keys/in.OptionKeys.gen.hh>
23 #include <basic/options/keys/frags.OptionKeys.gen.hh>
24 
25 // AUTO-REMOVED #include <core/conformation/Residue.hh>
26 #include <basic/Tracer.hh>
27 
29 
31 #include <utility/vector1.hh>
32 
33 
34 namespace protocols {
35 namespace frag_picker {
36 namespace scores {
37 
38 using namespace basic::options;
39 using namespace basic::options::OptionKeys;
40 
41 static basic::Tracer trGunnScore(
42  "protocols.frag_picker.scores.GunnCostScore");
43 
45 
46 GunnCostScore::GunnCostScore(Size priority, Real lowest_acceptable_value,
47  bool use_lowest, core::pose::PoseOP reference_pose,
48  utility::vector1<Size> frag_sizes,Size max_chunk_size) :
49  CachingScoringMethod(priority, lowest_acceptable_value, use_lowest, "GunnCostScore") , gunn_cost_( -0.01 ) {
50  reference_pose_ = reference_pose;
51  n_atoms_ = reference_pose_->total_residue();
52  max_chunk_size_ = max_chunk_size;
53 
54  for(Size j=1;j<=frag_sizes.size();j++) {
55  frag_sizes_.push_back(frag_sizes[j]);
56  trGunnScore << "Preparing Gunn score for fragments size: "<<frag_sizes[j]<<std::endl;
57 
59  v.resize( max_chunk_size_-frag_sizes[j]+1 );
60  chunk_gunn_data_.push_back( v );
61  trGunnScore << "Prepared "<<v.size()<<" Gunn tuples for the vall structure"<<std::endl;
62 
64  vn.resize( reference_pose_->total_residue()-frag_sizes[j]+1 );
65  computeGunnTuples(*reference_pose_,frag_sizes[j],vn);
66  ref_gunn_data_.push_back( vn );
67  trGunnScore << "Prepared "<<vn.size()<<" Gunn tuples for the reference structure"<<std::endl;
68  }
69 }
70 
71 
73 
74  core::pose::PoseOP pose = f->get_chunk()->get_pose();
75 
76  Size iv = f->get_first_index_in_vall();
77  Size iq = f->get_first_index_in_query();
78  GunnTuple t1;
79  GunnTuple t2;
80  gunn_cost_.compute_gunn( *pose, iv, iv + f->get_length() -1, t1);
81  gunn_cost_.compute_gunn( *reference_pose_, iq, iq + f->get_length() -1, t2);
82 
84  empty_map->set_score_component(score, id_);
85  if ((score > lowest_acceptable_value_) && (use_lowest_ == true))
86  return false;
87 
88  return true;
89 }
90 
91 
93 
94  core::pose::PoseOP pose = current_chunk->get_pose();
95  for(Size j=1;j<=frag_sizes_.size();j++) {
96  trGunnScore.Debug <<"Caching "<<frag_sizes_[j]<<" buffer size: "<<chunk_gunn_data_[j].size()<<std::endl;
98  }
99 }
100 
102 
103  trGunnScore.Debug << "Computing Gunn tuples for the vall structure of size: "
104  <<pose.total_residue()<<", results buffer size is: "<<result.size()<<std::endl;
105  for(Size i=1;i<=pose.total_residue()-frag_size + 1;i++) {
106  gunn_cost_.compute_gunn( pose, i, i+frag_size-1, result[i]);
107  }
108 }
109 
110 
112  FragmentScoreMapOP scores) {
113 
114  Size frag_len = fragment->get_length();
115  Size ifr = 1;
116  //bool if_found = false;
117  for(ifr=1;ifr<=frag_sizes_.size();ifr++) {
118  if(frag_sizes_[ifr] == frag_len) {
119  //if_found = true; set but never used ~Labonte
120  break;
121  }
122  }
123 // if(! if_found) {
124 // frag_sizes_.push_back( frag_len );
125 // ifr = frag_sizes_.size() + 1;
126 // prepare_chunk_tuples(frag_len);
127 // }
128 
129  Size iv = fragment->get_first_index_in_vall();
130  Size iq = fragment->get_first_index_in_query();
131 
133  GunnTuple & t = ref_gunn_data_[ifr][iq];
134  trGunnScore.Trace<<t.q1<<" ";
135  trGunnScore.Trace<<t.q2<<" ";
136  trGunnScore.Trace<<t.q3<<" ";
137  trGunnScore.Trace<<t.q4<<" ";
138  trGunnScore.Trace<<t.q5<<" ";
139  trGunnScore.Trace<<t.q6<<std::endl;
140  GunnTuple & t2 = chunk_gunn_data_[ifr][iv];
141  trGunnScore.Trace<<t2.q1<<" ";
142  trGunnScore.Trace<<t2.q2<<" ";
143  trGunnScore.Trace<<t2.q3<<" ";
144  trGunnScore.Trace<<t2.q4<<" ";
145  trGunnScore.Trace<<t2.q5<<" ";
146  trGunnScore.Trace<<t2.q6<<std::endl;
147  trGunnScore.Trace<<"scoring: "<<iv<<", "<<iq<<" "<<gunn_cost_.score_tuple(t2,t)<<" "<<score<<std::endl;
148 
149  scores->set_score_component(score, id_);
150  if ((score > lowest_acceptable_value_) && (use_lowest_ == true))
151  return false;
152 
153  return true;
154 }
155 
157 }
158 
160  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP picker
161  , std::string) {
162 
163 
164  Size longest_chunk = picker->get_vall()->get_largest_chunk_size();
165 
166  utility::vector1<Size> frag_sizes_tmp;
167  if (option[frags::frag_sizes].user()) {
168  frag_sizes_tmp = option[frags::frag_sizes]();
169  } else {
170  frag_sizes_tmp.push_back(3);
171  frag_sizes_tmp.push_back(9);
172  }
173 
174  if (option[in::file::s].user()) {
176  << "Reference structure to score fragments by Gunn cost loaded from: "
177  << option[in::file::s]()[1] << std::endl;
178  core::pose::PoseOP nativePose = new core::pose::Pose;
179  core::import_pose::pose_from_pdb(*nativePose, option[in::file::s]()[1]);
180 
181  return (FragmentScoringMethodOP) new GunnCostScore(priority,
182  lowest_acceptable_value, use_lowest, nativePose,
183  frag_sizes_tmp,longest_chunk);
184  }
185  utility_exit_with_message(
186  "Can't read a reference structure. Provide it with in::file::s flag");
187 
188  return NULL;
189 }
190 
191 } // scores
192 } // frag_picker
193 } // protocols
194