Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProfileScoreDistWeight.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/ProfileScore.cc
11 /// @brief scores a fragment by weighting L1 profile distances by residue type
12 /// @author Robert Vernon
13 
14 
15 // type headers
16 #include <core/types.hh>
17 
19 
20 // package headers
25 
26 // project headers
27 #include <basic/Tracer.hh>
28 
29 // mini headers
31 
32 // option key includes
33 #include <basic/options/keys/OptionKeys.hh>
34 
35 // utils
36 #include <basic/prof.hh>
37 
38 #include <utility/vector1.hh>
39 
40 
41 namespace protocols {
42 namespace frag_picker {
43 namespace scores {
44 
45 using namespace basic::options;
46 using namespace basic::options::OptionKeys;
47 
48 static basic::Tracer trProfScoreDistWeight(
49  "protocols.frag_picker.scores.ProfileScoreDistWeight");
50 
52 
53  std::string tmp = chunk()->chunk_key();
54  if (tmp.compare(cached_scores_id_) == 0)
55  return;
56  cached_scores_id_ = tmp;
57  //Size size_q = query_profile_->length();
58 
59  trProfScoreDistWeight.Debug << "caching profile score for " << chunk->get_pdb_id()
60  << " of size " << chunk->size() << std::endl;
61  PROF_START( basic::FRAGMENTPICKING_PROFILE_CAHING );
62  //for (Size i = 1; i <= size_q; ++i) {
63  //std::cout << "A " << query_sequence_ << " " << query_sequence_.length() << std::endl;
64  for (Size i = 0; i < query_sequence_.length(); ++i) {
65  //std::cout << "B" << chunk->size() << std::endl;
66  //utility::vector1<Real> query_prof_row = query_profile_->prof_row(i);
67  Size seqpos_res_id(aa_order_map_.find(query_sequence_[i])->second);
68 
69 
70  for (Size j = 1; j <= chunk->size(); ++j) {
71  //std::cout << "C" << chunk->size() << std::endl;
72 
73  //utility::vector1<Real> tmplt_prof_row = chunk->at(j)->profile();
74  Real score(0.0);
75 
76  Size tmplt_res_id (aa_order_map_.find(chunk->at(j)->aa())->second);
77 
78  for (Size s = 1; s <= 3; s++) {
79  Real ss_weight(0.0);
80  if (s == 1)
81  ss_weight = query_ss_->helix_fraction(i+1);
82  if (s == 2)
83  ss_weight = query_ss_->strand_fraction(i+1);
84  if (s == 3)
85  ss_weight = query_ss_->loop_fraction(i+1);
86 
87  //for (Size v = 1; v <= 20; v++) {
88  // Real distance_weight(0.0);
89  //
90  // distance_weight = distance_weights_[s][seqpos_res_id][v];
91  // score += tmplt_prof_row[v]*ss_weight*distance_weight;
92  //}
93 
94  Real distance_weight(0.0);
95 
96  distance_weight = distance_weights_[s][seqpos_res_id][tmplt_res_id];
97  score += ss_weight*distance_weight;
98 
99  //score += std::abs(tmplt_prof_row[v] - query_prof_row[q])
100  // *ss_weight
101  // *distance_weight;
102  // }
103 
104  //std::cout << "SCOREIJ_FINAL " << score << std::endl;
105  }
106 
107  //std::cout << "SCOREIJ_FINAL " << score << " " << i+1 << " " << j << " " << query_sequence_[i] << " " << chunk->at(j)->aa() << " " << query_ss_->helix_fraction(i+1) << " " << query_ss_->strand_fraction(i+1) << " " << query_ss_->loop_fraction(i+1) << " " << distance_weights_[1][seqpos_res_id][tmplt_res_id] << " " << distance_weights_[2][seqpos_res_id][tmplt_res_id] << " " << distance_weights_[3][seqpos_res_id][tmplt_res_id] << std::endl;
108 
109  scores_[i+1][j] = score;
110  }
111  }
112 
113  PROF_STOP( basic::FRAGMENTPICKING_PROFILE_CAHING );
114  trProfScoreDistWeight.Debug << "precomputed matrix of scores " << scores_.size()
115  << "x" << chunk->size() << std::endl;
116 }
117 
119 
120  std::string tmp = f->get_chunk()->chunk_key();
121  if (tmp.compare(cached_scores_id_) != 0)
122  do_caching(f->get_chunk());
123 
124  Real totalScore = 0.0;//f->get_length() * 20.0;
125  for (Size i = 1; i <= f->get_length(); i++) {
126  assert(f->get_first_index_in_query() + i - 1 <= scores_.size());
127  assert(f->get_first_index_in_vall()
128  + i - 1<= scores_[1].size());
129  totalScore += scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall() + i - 1];
130  //std::cout << "TOTALSCORE " << totalScore << " " << scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall() + i - 1] << " " << f->get_first_index_in_query() + i - 1 << " " << f->get_first_index_in_vall() + i - 1 << std::endl;
131  }
132  totalScore *= (Real) 100.0;
133  totalScore /= (Real) f->get_length();
134  empty_map->set_score_component(totalScore, id_);
135  if ((totalScore < lowest_acceptable_value_) && (use_lowest_ == true))
136  return false;
137  return true;
138 }
139 
141  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP picker, std::string prediction_id) {
142 
143  //query_sequence_ = picker->get_query_seq_string();
144 
145  //std::cout << "QUERY_SEQUENCE " << query_sequence_ << std::endl;
146 
147  Size len = picker->get_vall()->get_largest_chunk_size();
148 
149  //std::istringstream line_stream(config_line);
150  //std::string score_name;
151  //Size p;
152  //Real weight;
153  //Real lowest;
154  //std::string prediction_id;
155  //line_stream >> score_name >> p >> weight >> lowest >> prediction_id;
156 
157  trProfScoreDistWeight << "Profile scoring method is: DistWeight" << std::endl;
158  return (FragmentScoringMethodOP) new ProfileScoreDistWeight(priority,
159  lowest_acceptable_value, use_lowest, picker->get_query_seq(), picker->get_query_ss(prediction_id),picker->get_query_seq_string(),len);
160 }
161 
162 } //scores
163 } // frag_picker
164 } // protocols