Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProfileScoreDistWeight.hh
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 and 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.hh
11 /// @brief scores a fragment by weighting L1 profile distances by residue type
12 /// @author Robert Vernon
13 
14 #ifndef INCLUDED_protocols_frag_picker_scores_ProfileScoreDistWeight_hh
15 #define INCLUDED_protocols_frag_picker_scores_ProfileScoreDistWeight_hh
16 
17 // type headers
18 #include <core/types.hh>
19 
20 // package headers
23 
26 
27 // utility headers
28 #include <utility/exit.hh>
29 #include <utility/io/izstream.hh>
30 #include <string>
31 #include <map>
32 
33 #include <utility/vector1.hh>
34 
35 
36 namespace protocols {
37 namespace frag_picker {
38 namespace scores {
39 
41 
42 /// @brief a fragment candidate
44 public:
45 
47  Size priority,
48  Real lowest_acceptable_value,
49  bool use_lowest,
50  sequence::SequenceProfileOP query_profile,
51  core::fragment::SecondaryStructureOP query_ss_prediction,
52  std::string query_sequence, Size longest_vall_chunk
53  ) :
55  priority, lowest_acceptable_value, use_lowest, "ProfileScoreDistWeight"
56  ) {
57 
58  query_profile_ = query_profile;
59  query_ss_ = query_ss_prediction;
60  query_sequence_ = query_sequence;
61 
62  for (Size i = 1; i <= query_profile->length(); ++i) {
63  utility::vector1<Real> row(longest_vall_chunk);
64  scores_.push_back(row);
65  }
66 
67 
71  20, 0.0
72  )
73  )
74  );
75  distance_weights_ = temp;
76 
77  utility::io::izstream data("distances.txt");
78 
79  if (!data)
80  utility_exit_with_message("[ERROR] Unable to open distances.txt");
81 
82  std::string line;
83  char res1;
84  char res2;
85  char ss1;
86  char ss2;
87  Real dist;
88 
89  std::map<char,Size> ss_type_temp;
90  ss_type_temp.insert(std::make_pair('H',1));
91  ss_type_temp.insert(std::make_pair('E',2));
92  ss_type_temp.insert(std::make_pair('L',3));
93 
94  ss_type_map_ = ss_type_temp;
95 
96  std::map<char,Size> aa_order_tmp;
97  aa_order_tmp.insert(std::make_pair('A',1));
98  aa_order_tmp.insert(std::make_pair('C',2));
99  aa_order_tmp.insert(std::make_pair('D',3));
100  aa_order_tmp.insert(std::make_pair('E',4));
101  aa_order_tmp.insert(std::make_pair('F',5));
102  aa_order_tmp.insert(std::make_pair('G',6));
103  aa_order_tmp.insert(std::make_pair('H',7));
104  aa_order_tmp.insert(std::make_pair('I',8));
105  aa_order_tmp.insert(std::make_pair('K',9));
106  aa_order_tmp.insert(std::make_pair('L',10));
107  aa_order_tmp.insert(std::make_pair('M',11));
108  aa_order_tmp.insert(std::make_pair('N',12));
109  aa_order_tmp.insert(std::make_pair('P',13));
110  aa_order_tmp.insert(std::make_pair('Q',14));
111  aa_order_tmp.insert(std::make_pair('R',15));
112  aa_order_tmp.insert(std::make_pair('S',16));
113  aa_order_tmp.insert(std::make_pair('T',17));
114  aa_order_tmp.insert(std::make_pair('V',18));
115  aa_order_tmp.insert(std::make_pair('W',19));
116  aa_order_tmp.insert(std::make_pair('Y',20));
117 
118  aa_order_map_ = aa_order_tmp;
119 
120  while (getline(data, line)) {
121  std::istringstream line_stream(line);
122  line_stream >> res1 >> ss1 >> res2 >> ss2 >> dist;
123 
124 
125 
126  Size res_type( 0 );
127  if (ss1 == ss2) {
128  res_type = ss_type_map_.find(ss1)->second;
129  }
130 
131  //std::cout << "AAAA: " << res1 << " " << res2 << " " << ss1 << " " << ss2 << " " << dist << " " << res_type << std::endl;
132 
133  if ( res_type != 0 ) {
134 
135 
136 
137  Size i_res1, i_res2;
138 
139  i_res1 = aa_order_map_.find(res1)->second;
140  i_res2 = aa_order_map_.find(res2)->second;
141 
142  distance_weights_[res_type][i_res1][i_res2] = dist;
143  //std::cout << "BBBB: " << res1 << " " << res2 << " " << ss1 << " " << ss2 << " " << res_type << " " << i_res1 << " " << i_res2 << " " << dist << std::endl;
144  }
145  }
146  }
147 
148  void do_caching(VallChunkOP);
149  void clean_up() {
150  }
152  //bool describe_score(FragmentCandidateOP f, FragmentScoreMapOP empty_map, std::ostream& out);
153 
154 protected:
156 
157 private:
159 
161 
162  std::map<char,Size> ss_type_map_;
163  std::map<char,Size> aa_order_map_;
164 
168  void clear();
169 };
170 
172 public:
173 
175  MakeFragmentScoringMethod("ProfileScoreDistWeight") {
176  }
177 
179 };
180 
181 } // scores
182 } // frag_picker
183 } // protocols
184 
185 #endif /* INCLUDED_protocols_frag_picker_scores_ProfileScoreDistWeight_HH */