Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProfileScore.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 an amino acid sequence identity
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 
15 // type headers
16 #include <core/types.hh>
17 
19 
20 // package headers
25 
26 // mini headers
30 #include <basic/Tracer.hh>
31 
32 // option key includes
33 // AUTO-REMOVED #include <core/init.hh>
34 #include <basic/options/option.hh>
35 // AUTO-REMOVED #include <basic/options/option_macros.hh>
36 #include <basic/options/keys/OptionKeys.hh>
37 #include <basic/options/keys/frags.OptionKeys.gen.hh>
38 
39 // utils
40 // AUTO-REMOVED #include <basic/prof.hh>
41 
42 #include <utility/vector1.hh>
43 
44 
45 namespace protocols {
46 namespace frag_picker {
47 namespace scores {
48 
49 using namespace basic::options;
50 using namespace basic::options::OptionKeys;
51 
52 static basic::Tracer trProfScore(
53  "protocols.frag_picker.scores.ProfileScore");
54 
56 
58 
59  std::string tmp = chunk->chunk_key();
60  if (tmp.compare(cached_scores_id_) == 0)
61  return;
62  cached_scores_id_ = tmp;
63  Size size_q = query_profile_->length();
64  core::sequence::SequenceProfileOP chunk_profile = chunk->get_profile();
65  assert( chunk_profile->length() !=0 );
66  trProfScore.Debug << "caching profile score for " << chunk->get_pdb_id()
67  << " of size " << chunk->size() << std::endl;
68  assert( chunk->size() == chunk_profile->length() );
69  for (Size i = 1; i <= size_q; ++i) {
70  for (Size j = 1; j <= chunk->size(); ++j) {
71  scores_[i][j] = profile_scoring_->score(query_profile_,
72  chunk_profile, i, j);
73  }
74  }
75 
76  trProfScore.Debug << "precomputed matrix of scores " << scores_.size()
77  << "x" << chunk->size() << std::endl;
78 }
79 
81 
82 /* std::string tmp = f->get_chunk()->chunk_key();
83  if (tmp.compare(cached_scores_id_) != 0)
84  do_caching(f->get_chunk());
85 */
86 
87  Real totalScore = 0;
88  for (Size i = 1; i <= f->get_length(); i++) {
89  assert(f->get_first_index_in_query() + i - 1 <= scores_.size());
90  assert(f->get_first_index_in_vall()
91  + i - 1<= scores_[1].size());
92  totalScore
93  += scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall()
94  + i - 1];
95  }
96  totalScore /= (Real) f->get_length();
97  empty_map->set_score_component(totalScore, id_);
98  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
99  return false;
100  return true;
101 }
102 
104  FragmentScoreMapOP empty_map, std::ostream& out) {
105 
106  Real totalScore = 0;
107  core::sequence::SequenceProfileOP chunk_profile =
108  f->get_chunk()->get_profile();
109  Size firstQ = f->get_first_index_in_query();
110  Size firstV = f->get_first_index_in_vall();
111 
112  out << "\nvall: " << f->get_chunk()->get_pdb_id() << " " << I(5,
113  f->get_first_index_in_vall()) << " " << out << "\nquery " << I(5,
114  f->get_first_index_in_query()) << "\n";
115 
116  for (Size i = 1; i <= f->get_length(); ++i) {
117  out << "V row: " << F(5, 3, chunk_profile->prof_row(firstV + i - 1)[1]);
118  for (Size j = 2; j <= 20; ++j) {
119  out << " " << F(5, 3, chunk_profile->prof_row(firstV + i - 1)[j]);
120  }
121  out << "\n";
122  out << "Q row: "
123  << F(5, 3, query_profile_->prof_row(firstQ + i - 1)[1]);
124  for (Size j = 2; j <= 20; ++j) {
125  out << " " << F(5, 3, query_profile_->prof_row(firstQ + i - 1)[j]);
126  }
127  out << "\n";
128  out << "Position score: " << scores_[firstQ + i - 1][firstV + i - 1]
129  << "\n";
130  totalScore
131  += scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall()
132  + i - 1];
133  }
134  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
135  out << "Total score " << F(5, 3, totalScore) << " ACCEPTED"
136  << std::endl;
137  else
138  out << "Total score " << F(5, 3, totalScore) << " REJECTED"
139  << std::endl;
140  totalScore /= (Real) f->get_length();
141  empty_map->set_score_component(totalScore, id_);
142  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
143  return false;
144  return true;
145 }
146 
148  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP picker, std::string) {
149 
150  if (option[frags::scoring::profile_score].user()) {
151  Size len = picker->get_vall()->get_largest_chunk_size();
154  option[frags::scoring::profile_score]()));
155  trProfScore << "Profile scoring method is: "
156  << option[frags::scoring::profile_score]() << std::endl;
157  return (FragmentScoringMethodOP) new ProfileScore(priority,
158  lowest_acceptable_value, use_lowest, picker->get_query_seq(), ss, len);
159  }
160  utility_exit_with_message(
161  "[ERROR] Undefined profile scoring method. Provide it with frags::scoring::profile_score flag");
162 
163  return NULL;
164 }
165 
166 } //scores
167 } // frag_picker
168 } // protocols