Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecondarySimilarity.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/SecondarySimilarity.cc
11 /// @brief scores a fragment by secondary structure similarity
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
15 
16 // type headers
17 #include <core/types.hh>
18 
19 // package headers
24 
26 
27 // AUTO-REMOVED #include <basic/prof.hh>
28 
29 // project headers
30 #include <basic/Tracer.hh>
31 
32 #include <utility/vector1.hh>
33 
34 
35 namespace protocols {
36 namespace frag_picker {
37 namespace scores {
38 
39 static basic::Tracer trSecondarySimilarity(
40  "protocols.frag_picker.scores.SecondarySimilarity");
41 
43 
44  Real totalScore = 0.0;
45  for (Size i = 1; i <= f->get_length(); i++) {
46  Real ss_weight(0.0);
47  VallChunkOP chunk = f->get_chunk();
48 
49  char s(chunk->at(f->get_first_index_in_vall() + i - 1)->ss());
50  if (s == 'H')
51  ss_weight = 1 - query_ss_->helix_fraction(f->get_first_index_in_query() + i - 1);
52  if (s == 'E')
53  ss_weight = 1 - query_ss_->strand_fraction(f->get_first_index_in_query() + i - 1);
54  if (s == 'L')
55  ss_weight = 1 - query_ss_->loop_fraction(f->get_first_index_in_query() + i - 1);
56 
57  totalScore += ss_weight;
58  }
59  totalScore /= (Real) f->get_length();
60  empty_map->set_score_component(totalScore, id_);
61  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
62  return false;
63  return true;
64 }
65 
66 
68 
69  std::string & tmp = chunk->chunk_key();
70  if (tmp.compare(cached_scores_id_) == 0)
71  return;
72  cached_scores_id_ = tmp;
73 
74  do_caching_simple(chunk);
75  for(Size fl=1;fl<=cache_.size();fl++) {
76  if(cache_[fl].size() != 0) {
77  trSecondarySimilarity.Trace << "caching secondary score for " << chunk->get_pdb_id()
78  << " of size " << chunk->size() << " for fragment size "<<fl<<std::endl;
80  }
81  }
82 }
83 
85 
86  assert(query_ss_);
87  utility::vector1<Size> chunk_ss_id( chunk->size() );
88  for (Size j = 1; j <= chunk->size(); ++j) {
89  char s(chunk->at(j)->ss());
90  if (s == 'H') chunk_ss_id[j] = 1;
91  if (s == 'E') chunk_ss_id[j] = 2;
92  if (s == 'L') chunk_ss_id[j] = 3;
93  }
94 
95  for (Size i = 1; i <= query_len_; ++i) {
96  for (Size j = 1; j <= chunk->size(); ++j) {
97  scores_[i][j] = raw_probs_[i][chunk_ss_id[j]];
98  }
99  }
100  trSecondarySimilarity.Debug << "precomputed matrix of scores " << scores_.size()
101  << "x" << chunk->size() << std::endl;
102 }
103 
104 
106  FragmentScoreMapOP empty_map) {
107 
108 /*
109  std::string & tmp = f->get_chunk()->chunk_key();
110  if (tmp.compare(cached_scores_id_) != 0)
111  do_caching(f->get_chunk());
112 */
113  Real totalScore = cache_[f->get_length()][f->get_first_index_in_query()][f->get_first_index_in_vall()];
114 
115  totalScore /= (Real) f->get_length();
116 
117  empty_map->set_score_component(totalScore, id_);
118  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
119  return false;
120  return true;
121 }
122 
123 SecondarySimilarity::SecondarySimilarity(Size priority, Real lowest_acceptable_value, bool use_lowest,
124  core::fragment::SecondaryStructureOP query_prediction, std::string prediction_name,
125  Size sequence_length, utility::vector1<Size> & frag_sizes, Size longest_vall_chunk) :
126  CachingScoringMethod(priority, lowest_acceptable_value, use_lowest,
127  "SecondarySimilarity") , prediction_name_(prediction_name) {
128 
129  query_len_ = sequence_length;
130  query_ss_ = query_prediction;
131 
132  runtime_assert( query_prediction->total_residue() == query_len_ );
133 
134  for (Size i = 1; i <= query_len_; ++i) {
135  utility::vector1<Real> row(longest_vall_chunk);
136  scores_.push_back(row);
137  utility::vector1<Real> prow(3);
138  prow[1] = 1 - query_prediction->helix_fraction(i);
139  prow[2] = 1 - query_prediction->strand_fraction(i);
140  prow[3] = 1 - query_prediction->loop_fraction(i);
141  raw_probs_.push_back(prow);
142  }
143 
144  create_cache(frag_sizes,query_len_,longest_vall_chunk,cache_);
145 }
146 
147 } // scores
148 } // frag_picker
149 } // protocols
150 
151