Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ABEGO_SS_Score.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 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite && is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/frag_picker/scores/ABEGO_SS_Score.cc
11 /// @brief scores a fragment by secondary structure similarity
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
16 
17 // type headers
18 #include <core/types.hh>
19 
20 // package headers
24 
26 
27 #include <basic/options/option.hh>
28 #include <basic/options/keys/in.OptionKeys.gen.hh>
29 
30 // project headers
31 #include <basic/Tracer.hh>
32 
33 #include <utility/vector1.hh>
34 
35 
36 namespace protocols {
37 namespace frag_picker {
38 namespace scores {
39 
40 static basic::Tracer trABEGO_SS_Score(
41  "protocols.frag_picker.scores.ABEGO_SS_Score");
42 
44 
45  Real totalScore = 0.0;
46  for (Size i = 1; i <= f->get_length(); i++) {
47  VallChunkOP chunk = f->get_chunk();
48  VallResidueOP r = chunk->at(f->get_first_index_in_vall() + i - 1);
49  char s(r->ss());
50  Size bin = quota::torsion2big_bin_id(r->phi(),r->psi(),r->omega());
51  for(Size j=1;j<=maps_.size();j++) {
52  if(maps_[j]->check_status(s,bin)) {
53  totalScore += 1.0 - ratios_[i][j];
54  break;
55  }
56  }
57  }
58  totalScore /= (Real) f->get_length();
59  empty_map->set_score_component(totalScore, id_);
60  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
61  return false;
62  return true;
63 }
64 
65 
67 
68  std::string tmp = chunk()->chunk_key();
69  if (tmp.compare(cached_scores_id_) == 0)
70  return;
71  cached_scores_id_ = tmp;
72 
73  trABEGO_SS_Score.Debug << "caching ABEGO-SS score for " << chunk->get_pdb_id()
74  << " of size " << chunk->size() << std::endl;
75 
76  utility::vector1<Size> chunk_bins_;
77  for (Size j = 1; j <= chunk->size(); ++j) {
78  VallResidueOP r = chunk->at(j);
79  char s(r->ss());
80  Size bin = quota::torsion2big_bin_id(r->phi(),r->psi(),r->omega());
81  bool if_found = false;
82  for(Size i=1;i<=maps_.size();i++) {
83  if(maps_[i]->check_status(s,bin)) {
84  chunk_bins_.push_back(i);
85  if_found = true;
86  break;
87  }
88  continue;
89  }
90  if(!if_found) {
91  trABEGO_SS_Score.Warning << "Can't find a feature label for the following combination of ss,abego: "
92  <<s<<","<<maps_[1]->abego_char(bin)<<std::endl;
93  assert(false);
94  }
95  }
96  for (Size i = 1; i <= query_len_; ++i) {
97  for (Size j = 1; j <= chunk->size(); ++j) {
98  scores_[i][j] = 1.0 - ratios_[i][ chunk_bins_[j] ];
99  }
100  }
101  trABEGO_SS_Score.Debug << "precomputed matrix of scores " << scores_.size()
102  << "x" << chunk->size() << std::endl;
103 }
104 
106  FragmentScoreMapOP empty_map) {
107 
108  std::string tmp = f->get_chunk()->chunk_key();
109  if (tmp.compare(cached_scores_id_) != 0)
110  do_caching(f->get_chunk());
111 
112  Real totalScore = 0;
113  for (Size i = 1; i <= f->get_length(); ++i) {
114  assert(f->get_first_index_in_query() + i - 1 <= scores_.size());
115  assert(f->get_first_index_in_vall() + i - 1<= scores_[1].size());
116  totalScore += scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall() + i - 1];
117  }
118 
119  totalScore /= (Real) f->get_length();
120  empty_map->set_score_component(totalScore, id_);
121  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
122  return false;
123  return true;
124 }
125 
126 FragmentScoringMethodOP MakeABEGO_SS_Score::make(Size priority, Real lowest_acceptable_value, bool use_lowest,
127  FragmentPickerOP picker, std::string /*prediction_file*/) {
128 
129  using namespace basic::options;
130  using namespace basic::options::OptionKeys;
131  Size vall_max_len = picker->get_vall()->get_largest_chunk_size();
132 
133  if ( !option[ in::file::torsion_bin_probs ].user() ) {
134  utility_exit_with_message("Error: no input file specified for ABEGO_SS score; use in::file::torsion_bin_probs option");
135  }
136  return (FragmentScoringMethodOP) new ABEGO_SS_Score(priority,
137  lowest_acceptable_value, use_lowest,option[ in::file::torsion_bin_probs ](),
138  vall_max_len);
139 }
140 
141 } // scores
142 } // frag_picker
143 } // protocols
144 
145