Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScoreEValuator.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/ScoreEValuator.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 // option key includes
27 // AUTO-REMOVED #include <core/init.hh>
28 #include <basic/options/option.hh>
29 // AUTO-REMOVED #include <basic/options/option_macros.hh>
30 #include <basic/options/keys/OptionKeys.hh>
31 #include <basic/options/keys/frags.OptionKeys.gen.hh>
32 
33 // mini headers
37 #include <basic/Tracer.hh>
38 
39 #include <algorithm>
40 
41 #include <utility/vector1.hh>
42 
43 #include <numeric/random/random.hh>
44 #include <numeric/random/random_permutation.hh>
45 
46 namespace protocols {
47 namespace frag_picker {
48 namespace scores {
49 
50 static numeric::random::RandomGenerator RG(10402); // Magic Number
51 
52 using namespace basic::options;
53 using namespace basic::options::OptionKeys;
54 
55 static basic::Tracer trProfScore(
56  "protocols.frag_picker.scores.ScoreEValuator");
57 
59 
61 }
62 
64 
66 }
67 
69 
70  Real totalScore = 0;
71  Real mean = 0;
72  Real stdev = 0;
73 
74  utility::vector1<Size> columnsQ;
75  utility::vector1<Size> columnsV;
76  for (Size i = 1; i <= f->get_length(); i++) {
77  assert(f->get_first_index_in_query() + i - 1 <= scores_.size());
78  assert(f->get_first_index_in_vall()
79  + i - 1<= scores_[1].size());
80  totalScore
81  += scores_[f->get_first_index_in_query() + i - 1][f->get_first_index_in_vall()
82  + i - 1];
83  columnsQ.push_back(f->get_first_index_in_query() + i - 1);
84  columnsV.push_back(f->get_first_index_in_vall() + i - 1);
85  }
86 
87  for (Size i_rand = 1; i_rand <= max_rand_; ++i_rand) {
88  numeric::random::random_permutation(columnsQ.begin(), columnsQ.end(), RG);
89  numeric::random::random_permutation(columnsV.begin(), columnsV.end(), RG);
90  Real s = 0;
91  for (Size i = 1; i <= columnsQ.size(); i++) {
92  s = scores_[columnsQ[i]][columnsV[i]];
93  mean += s;
94  stdev += s * s;
95  }
96  }
97  mean /= ((Real) max_rand_);
98  stdev /= ((Real) max_rand_);
99  stdev = sqrt(stdev - mean * mean);
100 
101  totalScore = (totalScore - mean) / stdev;
102 
103  empty_map->set_score_component(totalScore, id_);
104  if ((totalScore > lowest_acceptable_value_) && (use_lowest_ == true))
105  return false;
106  return true;
107 }
108 
110  Real lowest_acceptable_value, bool use_lowest, FragmentPickerOP picker) {
111 
112  if (option[frags::scoring::profile_score].user()) {
115  option[frags::scoring::profile_score]()));
116  Size len = picker->get_vall()->get_largest_chunk_size();
117  trProfScore << "Profile scoring method is: "
118  << option[frags::scoring::profile_score]() << std::endl;
119  return (FragmentScoringMethodOP) new ScoreEValuator(priority,
120  lowest_acceptable_value, use_lowest, picker->get_query_seq(), ss, len);
121  }
122  utility_exit_with_message(
123  "[ERROR] Undefined profile scoring method. Provide it with frags::scoring_scheme flag");
124 
125  return NULL;
126 }
127 
128 } //scores
129 } // frag_picker
130 } // protocols