Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SidechainContactDistCutoff.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 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/SidechainContactDistCutoff.cc
11 /// @brief Defines sidechain contact distance cutoffs.
12 /// @author David E. Kim (dekim@u.washington.edu)
13 
14 // Unit headers
16 
17 
18 // Package headers
19 
20 // Project headers
21 #include <core/types.hh>
22 #include <core/chemical/AA.hh>
23 
24 #include <basic/database/open.hh>
25 #include <basic/Tracer.hh>
26 
27 // Utility headers
28 #include <utility/exit.hh>
29 #include <utility/io/izstream.hh>
30 
31 // C/C++ headers
32 #include <iostream>
33 #include <string>
34 
35 
36 namespace protocols {
37 namespace frag_picker {
38 
39 // @brief Auto-generated virtual destructor
41 
42 using namespace core;
43 
44 static basic::Tracer TR("protocols.frag_picker.SidechainContactDistCutoff");
45 
48 }
49 
51  scale_factor_ = scale_factor;
52  initialize();
53 }
54 
56 
57  // set aa mapping
58  // GLY ALA SER CYS VAL THR ILE PRO MET ASP ASN LEU LYS GLU GLN ARG HIS PHE TYR TRP
59  aa_map_.resize(20);
60  aa_map_[1] = 'G';
61  aa_map_[2] = 'A';
62  aa_map_[3] = 'S';
63  aa_map_[4] = 'C';
64  aa_map_[5] = 'V';
65  aa_map_[6] = 'T';
66  aa_map_[7] = 'I';
67  aa_map_[8] = 'P';
68  aa_map_[9] = 'M';
69  aa_map_[10] = 'D';
70  aa_map_[11] = 'N';
71  aa_map_[12] = 'L';
72  aa_map_[13] = 'K';
73  aa_map_[14] = 'E';
74  aa_map_[15] = 'Q';
75  aa_map_[16] = 'R';
76  aa_map_[17] = 'H';
77  aa_map_[18] = 'F';
78  aa_map_[19] = 'Y';
79  aa_map_[20] = 'W';
80 
81  // set aa to index mapping
82  for (Size i=1;i<=aa_map_.size();++i)
83  aa_to_index_map_[aa_map_[i]] = i;
84 
87 
88  // read distance tables
89  // first table is the mean and the second is the standard deviation
90  utility::io::izstream data(basic::database::full_name("sampling/sidechain_contact.txt"));
91  TR.Info << "read sidechain contact data from sidechain_contact.txt" << std::endl;
92  if (!data)
93  utility_exit_with_message("[ERROR] Unable to open file: sidechain_contact.txt");
94 
95  std::string line;
96  Size tablecnt = 0;
97  while (getline(data, line)) {
98  if (line.size() > 3 && line.substr(0,3) == "GLY") { // tables start with GLY
99  tablecnt++;
100  Size rowcnt = 1;
101  utility::vector1<Real> col(20);
102  std::istringstream line_stream( line );
103  std::string col1;
104  line_stream >> col1;
106  utility_exit_with_message( "Error in sidechain name mapping in sidechain_contact.txt!" );
107  for (Size i=1;i<=col.size();++i) line_stream >> col[i];
108  if ( line_stream.fail() )
109  utility_exit_with_message( "Error reading in SidechainContactDistCutoff()!" );
110  if (tablecnt == 1)
111  mean_dist.push_back(col);
112  else if (tablecnt == 2)
113  stddev_dist.push_back(col);
114  for (Size j=1;j<=19;++j) { // read the remaining table rows
115  getline(data, line);
116  rowcnt++;
117  std::istringstream line_stream_next(line);
118  line_stream_next >> col1;
120  utility_exit_with_message( "Error in sidechain name mapping in sidechain_contact.txt!" );
121  for (Size i=1;i<=col.size();++i) line_stream_next >> col[i];
122  if ( line_stream_next.fail() )
123  utility_exit_with_message( "Error reading in SidechainContactDistCutoff()!" );
124  if (tablecnt == 1)
125  mean_dist.push_back(col);
126  else if (tablecnt == 2)
127  stddev_dist.push_back(col);
128  }
129  }
130  }
131  data.close();
132 
133  // calculate cutoffs
134  // from I-TASSER paper
135  cutoff_.resize(20);
136  cutoff_squared_.resize(20);
137  for (Size i=1;i<=mean_dist.size();++i) {
138  for (Size j=1;j<=mean_dist[i].size();++j) {
139  cutoff_[i].push_back( scale_factor_*(mean_dist[i][j] + 2.5*stddev_dist[i][j]) );
140  cutoff_squared_[i].push_back( cutoff_[i][j]*cutoff_[i][j] );
141  TR.Debug << "cutoff_squared: " << i << " " << j << " " << cutoff_squared_[i][j] << std::endl;
142  }
143  }
144 }
145 
147  return cutoff_[aa_to_index_map_[aa_i]][aa_to_index_map_[aa_j]];
148 }
149 
151  return cutoff_squared_[aa_to_index_map_[aa_i]][aa_to_index_map_[aa_j]];
152 }
153 
155  return scale_factor_;
156 }
157 
158 } // frag_picker
159 } // protocols
160 
161