Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DirectReadoutPotential.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 core/scoring/methods/DirectReadoutPotential.cc
11 /// @brief 1st pass implementation of Kono + Sarai's protein-DNA interaction potential
12 /// @details Needs polishing, converting to mini standards in some respects, but still in trial stage.
13 /// @author Amy Ticoll
14 
15 
16 // Unit Headers
20 #include <core/chemical/AA.hh>
21 
22 // Package headers
23 
24 // Project headers
25 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
26 // AUTO-REMOVED #include <core/chemical/AtomTypeSet.hh>
27 
28 #include <basic/database/open.hh>
29 
30 // Utility headers
31 #include <utility/io/izstream.hh>
32 #include <iostream>
33 #include <fstream>
34 #include <sstream>
35 // AUTO-REMOVED #include <math.h>
36 #include <string>
37 
38 #include <utility/vector1.hh>
39 
40 
41 namespace core {
42 namespace scoring {
43 namespace dna {
44 
45 /// @details ctor, reads data file. Need to configure to allow alternate tables/atom_sets
47  :wt( 1.0/20 ),
48  RT( 0.582 )
49 {
50  fill_bins(A_bins, 'A');
51  fill_bins(C_bins, 'C');
52  fill_bins(G_bins, 'G');
53  fill_bins(T_bins, 'T');
54  get_pairs();
55 
56  aas_at_grid = 0;
57  for (int x=0; x<9; x++)
58  {
59  for (int y=0; y<9; y++)
60  {
61  for (int z=0; z<4; z++)
62  {
63  int num_aas =
64  A_bins[x][y][z].length() +
65  C_bins[x][y][z].length() +
66  G_bins[x][y][z].length() +
67  T_bins[x][y][z].length(); // need one letter code in list for this
68  aas_at_grid += num_aas;
69  }
70  }
71  }
72 
73  Real d_eab;
74  for (int x_bin=0; x_bin<9; x_bin++)
75  {
76  for (int y_bin=0; y_bin<9; y_bin++)
77  {
78  for (int z_bin=0; z_bin<4; z_bin++)
79  {
80  for (int p=0; p<20; p++)
81  {
82  for (int d=0; d<4; d++)
83  {
84  int num_aas =
85  A_bins[x_bin][y_bin][z_bin].length() +
86  C_bins[x_bin][y_bin][z_bin].length() +
87  G_bins[x_bin][y_bin][z_bin].length() +
88  T_bins[x_bin][y_bin][z_bin].length(); // need one letter code in list for this
89 
90  Real fs = Real(num_aas)/Real(aas_at_grid);
91  int mab = num_pairs[d][p]; // m_pairs uses numbers, starting at 0
92 
93  int num_of_aa = 0;
94  string lib_aa_list;
95  if (d==0) { lib_aa_list=G_bins[x_bin][y_bin][z_bin]; } // follows order in AA.hh
96  else if (d==1) { lib_aa_list=A_bins[x_bin][y_bin][z_bin]; }
97  else if (d==2) { lib_aa_list=C_bins[x_bin][y_bin][z_bin]; }
98  else { lib_aa_list=T_bins[x_bin][y_bin][z_bin]; }
99 
100  for (Size i=0; i<lib_aa_list.length(); i++)
101  {
102  int const aa( chemical::aa_from_oneletter_code( lib_aa_list[i] ) );
103  if ( aa == p ) { num_of_aa++; } //***need to convert to_comp to its aa_number-1
104  }
105 
106  Real fscore;
107  Real gabs = Real(num_of_aa)/Real(mab);
108  Real fabs = fs/(1 + mab*wt) + (mab*wt*gabs)/(1+mab*wt);
109  if (fs!=0) { fscore = fabs/fs; }
110  else { fscore = 0; }
111  if (fscore!=0) { d_eab = -RT*log(fscore); }
112  else { d_eab = 0; }
113 
114  score[x_bin][y_bin][z_bin][p][d]=d_eab;
115  }
116  }
117  }
118  }
119  }
120 }
121 
122 Real
124 {
125  assert( rsd1.is_protein() && rsd2.is_DNA() );
126 
127  // define coordinate frame
128  bool const AG( rsd2.aa() == chemical::na_ade || rsd2.aa() == chemical::na_gua );
129  Vector const origin( AG ? rsd2.xyz("N9") : rsd2.xyz("N1") );
130  Vector p( AG ? rsd2.xyz("C4") : rsd2.xyz("C2") );
131  Vector const x( ( p - origin ).normalized() );
132  Vector z,y;
133  z = ( dna::get_z_axis( rsd2, x ) );
134  y = ( z.cross( x ) );
135  Vector const calpha( rsd1.xyz("CA") - origin );
136  Real const xx = dot(calpha,x);
137  Real const yy = dot(calpha,y);
138  Real const zz = dot(calpha,z);
139 
140  if ( ( xx >= -13.5 && xx <= 13.5 ) &&
141  ( yy >= -13.5 && yy <= 13.5 ) &&
142  ( zz >= -6.0 && zz <= 6.0 ) ) {
143  int const aa_bin = rsd1.aa() - 1;
144  int const na_bin = rsd2.aa() - chemical::first_DNA_aa;
145 
146  int x_bin = get_xy_bin(xx);
147  int y_bin = get_xy_bin(yy);
148  int z_bin = get_z_bin(zz);
149  assert( aa_bin >= 0 && aa_bin < 20 && na_bin >= 0 && na_bin < 4 );
150  return score[x_bin][y_bin][z_bin][aa_bin][na_bin];
151  } else {
152  return 0.0;
153  }
154 
155 }
156 
157 
158 void
159 DirectReadoutPotential::fill_bins(string (&my_array)[9][9][4], char const base )
160 {
161  utility::io::izstream myfile;
162 
163  // open the file
164  std::string const bins_filename( std::string("scoring/dna/") + base + "_bins.txt" );
165  basic::database::open( myfile, bins_filename );
166 
167  if ( !myfile.good() ) utility_exit_with_message( "Unable to open file: "+bins_filename );
168 
169  for ( int i=0; i<9; ++i ) {
170  for ( int j=0; j<9; ++j ) {
171  for ( int k=0; k<4; ++k ) {
172  std::string line, aas;
173  int x,y,z;
174  getline( myfile, line );
175  std::istringstream l( line );
176  l >> x >> y >> z >> aas;
177  assert( x == i && y == j && z == k );
178  if ( aas == "-" ) {
179  my_array[x][y][z]= "";
180  } else {
181  my_array[x][y][z]= aas;
182  }
183  }
184  }
185  }
186  myfile.close();
187 }
188 
189 
190 void
192 {
193  utility::io::izstream myfile;
194  basic::database::open( myfile, "scoring/dna/m_pairs.txt" );
195 
196  if ( !myfile.good() ) utility_exit_with_message( "Unable to open m_pairs.txt" );
197 
198  for ( Size i=0; i<4; ++i ) {
199  for ( Size j=0; j<20; ++j ) {
200  string line;
201  getline( myfile, line );
202  std::istringstream l(line );
203  Size itmp, jtmp;
204  l >> itmp >> jtmp >> num_pairs[i][j];
205  assert( itmp == i && jtmp == j && !l.fail() );
206  }
207  }
208  myfile.close();
209 }
210 
211 int
213 {
214  if (coord <= -13.5 || coord >= 13.5) { return -99; }
215  Real c = coord - ( -13.5 );
216  int bin = int(floor( c/3 ));
217  return bin;
218 }
219 
220 int
222 {
223  if (coord <= -6 || coord >= 6) { return -99; }
224  Real c = coord - ( -6 );
225  int bin = int(floor( c/3 ));
226  return bin;
227 }
228 
229 // int
230 // DirectReadoutPotential::num_pairs(int b, int a)
231 // {
232 // for (int i=0; i<80; i++)
233 // { if (pair_base[i]==b && pair_aa[i]==a) { return pair_num[i]; }
234 // }
235 // }
236 
237 
238 } // ns dna
239 } // ns scoring
240 } // ns core