Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DisulfideDistance.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 Scores fragments by disulfide-linke Calpha distances
11 /// @author Robert Vernon
12 
14 
19 
20 #include <basic/options/option.hh>
21 #include <basic/options/keys/OptionKeys.hh>
22 #include <basic/options/keys/in.OptionKeys.gen.hh>
23 
25 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
26 // AUTO-REMOVED #include <basic/Tracer.hh>
27 
28 // utils
29 #include <ObjexxFCL/FArray1D.hh>
30 #include <basic/prof.hh>
31 
32 // AUTO-REMOVED #include <boost/tuple/tuple.hpp>
33 
34 #include <utility/vector1.hh>
35 
36 
37 namespace protocols {
38 namespace frag_picker {
39 namespace scores {
40 
41 using namespace basic::options;
42 using namespace basic::options::OptionKeys;
43 
44  DisulfideDistance::DisulfideDistance(Size priority, Real lowest_acceptable_value, bool use_lowest,
45  utility::vector1< Size > disulfide_data, Size largest_fragment) :
46  CachingScoringMethod(priority, lowest_acceptable_value, use_lowest, "DisulfideDistance"),
47  disulfide_data_(disulfide_data),
48  largest_fragment_(largest_fragment)
49 {
50 }
51 
53 
54  n_res_ = current_chunk->size();
55 
56  chunk_ca_distances_.redimension(n_res_, n_res_, 0.0);
57  for (Size x = 1; x <= n_res_; ++x) {
58  VallResidueOP xr = current_chunk->at(x);
59 
60  for (Size y = x - largest_fragment_ - 3; (y <= x + largest_fragment_ + 3) && (y <= n_res_); ++y) {
61  //for (Size y = 1; y <= n_res_; ++y) {
62  if (y > 0) {
63  VallResidueOP yr = current_chunk->at(y);
64 
65  Real distance = sqrt( pow( xr->x() - yr->x(), 2) + pow( xr->y() - yr->y(), 2) + pow( xr->z() - yr->z(), 2) );
67  }
68  }
69  }
70 }
71 
73  return cached_score( fragment, scores );
74 }
75 
77 
78  std::string tmp = fragment->get_chunk()->chunk_key();
79  if (tmp.compare(cached_scores_id_) != 0) {
80  do_caching(fragment->get_chunk());
81  cached_scores_id_ = tmp;
82  }
83 
84  Size offset_q = fragment->get_first_index_in_query() - 1;
85  Size offset_v = fragment->get_first_index_in_vall() - 1;
86  Real score = 0.0;
87 
88  //std::cout << "CACHING_FOR_DISULFIDE_DISTANCES" << std::endl;
89 
90  for (Size i = 1; i < fragment->get_length(); ++i) {
91 
92  if ( (i+offset_q) <= disulfide_data_.size() ){
93  if (disulfide_data_[i+offset_q] != 0) {
94 
95  Size res1 = i+offset_q;//disulfide_[i+offset_q].first;
96  Size res2 = disulfide_data_[i+offset_q];//.second;
97 
98  Size v1 = i+offset_v;
99 
100  Size v2(0);
101  Size seq_sep(0);
102 
103  if ( res2 > res1 ) {
104  seq_sep = res2 - res1;
105  v2 = v1 + seq_sep;
106  } else {
107  seq_sep = res1 - res2;
108  if ( v1 > (res1 - res2) ) {
109  v2 = v1 - seq_sep;
110  }
111  }
112 
113  //std::cout << "CACHED " << res1 << " " << res2 << " " << n_res_ << std::endl;
114 
115  if ( (res2 != 0) && (res2 <= (3 + offset_q + fragment->get_length())) && (res2 >= offset_q - 3)
116  && (v2 > 0) && (v2 <= n_res_) ) {
117 
118  if ( seq_sep >= 4) {
119  if ( (chunk_ca_distances_(v1,v2) < 3.6) || (chunk_ca_distances_(v1,v2) > 7.0) ) {
120  score += 10.0;
121  }
122  } else {
123  if ( seq_sep >= 2 ) {
124  if ( (chunk_ca_distances_(v1,v2) < 4.6) || (chunk_ca_distances_(v1,v2) > 6.7) ) {
125  score += 10.0;
126  }
127  } else {
128  if ( (chunk_ca_distances_(v1,v2) > 4.0) ) {
129  score += 10.0;
130  }
131  }
132  }
133  }
134 
135  //std::cout << "DISULFIDE_SCORING " << res1 << " " << res2 << " " << v1 << " " << v2 << " " << offset_q << " " << offset_v << " " << i << " " << score << " " << chunk_ca_distances_(v1,v2) << std::endl;
136  }
137  }
138  }
139 
140  scores->set_score_component(score, id_);
141  PROF_STOP( basic::FRAGMENTPICKING_PHIPSI_SCORE );
142  if ((score > lowest_acceptable_value_) && (use_lowest_ == true))
143  return false;
144 
145  return true;
146 }
147 
149 }
150 
151 /// @brief Creates a DisulfideDistance scoring method
152 /// @param priority - priority of the scoring method. The higher value the earlier the score
153 /// will be evaluated
154 /// @param lowest_acceptable_value - if a calculated score is higher than this value,
155 /// fragment will be neglected
156 /// @param FragmentPickerOP object - not used
157 /// @param line - the relevant line extracted from the scoring configuration file that defines this scoring method
158 /// It could look like: "DisulfideDistance 140 -5.0 100.0 additional_string"
159 /// where 140, -5.0 && 100.0 are priority, weight && treshold, respectively.
160 /// The additional string may be:
161 /// - empty: then the maker tries to create a scoring object from a TALOS file
162 /// trying in::file::talos_phi_psi flag. If fails, will try to use a pose from in::file::s
163 /// - a pdb file, pdb extension is necessary. This will create a pose && steal Phi && Psi
164 /// - a TALOS file with Phi/Psi prediction (tab extension is necessary)
166  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP picker//picker
167  , std::string )
168 {
169 
170  if (option[in::fix_disulf].user()) {
171 
172  core::io::raw_data::DisulfideFile ds_file( option[ in::fix_disulf ]() );
173 
174  utility::vector1< std::pair<Size,Size> > disulfides_in_file;
175 
176  ds_file.disulfides(disulfides_in_file);
177 
178  Size largest_number(0);
179 
180  for ( Size i = 1; i <= disulfides_in_file.size(); ++i ) {
181 
182  Size l = disulfides_in_file[i].first;
183  Size u = disulfides_in_file[i].second;
184 
185  if ( u <= l ) {
186  utility_exit_with_message("[ERROR] Disulfide File Format: res2 must be > res1");
187  }
188 
189  if ( u > largest_number ) {
190  largest_number = u;
191  }
192  }
193 
194  utility::vector1< Size > disulfide_data(largest_number,0);
195 
196  for ( Size i = 1; i <= disulfides_in_file.size(); ++i ) {
197 
198  Size l = static_cast< Size > ( disulfides_in_file[i].first );
199  Size u = static_cast< Size > ( disulfides_in_file[i].second );
200 
201  disulfide_data[u] = l;
202  disulfide_data[l] = u;
203  }
204 
205  for ( Size i = 1; i <= largest_number; ++i ) {
206 
207  std::cout << "DISULFIDE_DATA " << i << " " << disulfide_data[i] << std::endl;
208 
209  }
210 
211  Size largest_fragment(0);
212  for ( Size i = 1; i <= picker->frag_sizes_.size(); ++i ) {
213  if ( picker->frag_sizes_[i] > largest_fragment ) largest_fragment = picker->frag_sizes_[i];
214  }
215 
216  runtime_assert( largest_fragment > 0 );
217 
218  //disulfide_data_ = disulfide_data;
219  return (FragmentScoringMethodOP) new DisulfideDistance(priority, lowest_acceptable_value, use_lowest,
220  disulfide_data, largest_fragment);
221  }
222 
223  utility_exit_with_message(
224  "Can't read disulfide connectivity file. Provide a connectivity file with -in::fix_disulf <file>\n");
225 
226  return NULL;
227 
228 }
229 
230 } // scores
231 } // frag_picker
232 } // protocols
233