Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidualDipolarCoupling_Rohl.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/ResidualDipolarCoupling_Rohl.cc
10 /// @brief Uses NMR RDC for scoring
11 /// @author Srivatsan Raman
12 
13 //core headers
15 // AUTO-REMOVED #include <basic/options/after_opts.hh>
16 #include <basic/options/option.hh>
17 
18 #include <core/pose/Pose.hh>
20 #include <basic/datacache/BasicDataCache.hh>
21 
22 #include <basic/Tracer.hh>
23 #include <utility/excn/Exceptions.hh>
24 
25 //C++ headers
26 #include <iostream>
27 #include <fstream>
28 #include <string>
29 
30 // option key includes
31 
32 #include <basic/options/keys/in.OptionKeys.gen.hh>
33 #include <basic/options/keys/rdc.OptionKeys.gen.hh>
34 
35 /// Utility headers
36 #include <utility/io/izstream.hh>
37 
38 #include <utility/vector1.hh>
39 
40 
41 static basic::Tracer tr("core.scoring.ResidualDipolarCoupling_Rohl");
42 
43 namespace core {
44 namespace scoring {
45 
46 //////////////////////////////////////////////////////
47 //@brief reads in RDC data file
48 //////////////////////////////////////////////////////
50  // ////using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_DATA_ROHL;
52 }
53 
55  // ////using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_DATA_ROHL;
58  };
59  return NULL;
60 }
61 
63  // ////using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_DATA_ROHL;
66  };
67  return NULL;
68 }
69 
70 
72 {
73 
74  using namespace basic::options;
75  using namespace basic::options::OptionKeys;
76  runtime_assert( option[ OptionKeys::in::file::rdc ]().size() );
77  std::string filename( option[ OptionKeys::in::file::rdc ]()[ 1 ].name() );
78  utility::io::izstream infile( filename.c_str() );
79  std::string line;
80 
81  // std::cout << "Reading RDC file " << filename << std::endl;
82  tr.Info << "Reading RDC file " << filename << std::endl;
83 
84  while( getline( infile, line ) ) {
85  std::istringstream line_stream( line );
86  std::string atom1, atom2;
87  Size res1, res2;
88  Real Jdipolar;
89  line_stream >> res1 >> atom1 >> res2 >> atom2 >> Jdipolar;
90  if ( line_stream.fail() ) {
91  tr.Error << "couldn't read line " << line << " in rdc-file " << filename << "\n";
92  throw( utility::excn::EXCN_BadInput(" invalid line "+line+" in rdc-file "+filename));
93  }
94 
95  Real weight( 1.0 );
96  line_stream >> weight;
97  if ( line_stream.fail() ) {
98  tr.Debug << " set weight for RDC " << res1 << " to 1.0 " << std::endl;
99  weight = 1.0;
100  }
101 
102  if ( res1 != res2 ) {
103  std::cout << "Dipolar couplings only between atoms in the same residue are acceptable !" << std::endl;
104  continue;
105  } else {
106  Size data_type( get_RDC_data_type( atom1, atom2 ) );
107  All_RDC_lines.push_back( RDC_Rohl( data_type, res1, Jdipolar, weight ) );
108  }
109 
110  }
111 
112  //extra weight file?
113  if ( option[ OptionKeys::rdc::weights ].user() ) {
114  std::string filename( option[ OptionKeys::rdc::weights ]().name() );
115  std::ifstream infile( filename.c_str() );
116  while( getline( infile, line ) ) {
117  std::istringstream line_stream( line );
118  Real weight; Size res1;
119  line_stream >> res1 >> weight;
120  if ( line_stream.fail() ) {
121  tr.Error << "[Error] reading rdc-weight-file " << filename << std::endl;
122  throw( utility::excn::EXCN_BadInput(" invalid line "+line+" in rdc-weight-file "+filename));
123  }
124  for ( RDC_lines::iterator it = All_RDC_lines.begin(); it != All_RDC_lines.end(); ++it ) {
125  if ( it->res() == res1 ) it->weight( weight );
126  }
127  }
128  }
129 
130 }
131 
132 
133 
134 //////////////////////////////////////////////////////
135 //@brief returns type of RDC data N-H, HA-CA etc
136 //////////////////////////////////////////////////////
138  std::string const & atom1,
139  std::string const & atom2
140 )
141 {
142 
143  Size RDC_type(0);
144 
145  if ( ( atom1 == "N" && atom2 == "H" ) || ( atom1 == "H" && atom2 == "N" ) )
146  RDC_type = 1;
147  //****************** FIX THESE LATER !! **************************
148  else if ( ( atom1 == "C" && atom2 == "H" ) || ( atom1 == "H" && atom2 == "C" ) )
149  RDC_type = 2;
150  else if ( ( atom1 == "C" && atom2 == "N" ) || ( atom1 == "N" && atom2 == "C" ) )
151  RDC_type = 4;
152  else if ( ( atom1 == "C" && atom2 == "C" ) )
153  RDC_type = 5;
154  else if ( atom1 == "H" && atom2 == "H" )
155  RDC_type = 6;
156 
157  // std::cout << "RDC_type " << RDC_type << std::endl;
158 
159  assert(RDC_type != 0 );
160 
161  return RDC_type;
162 
163 }
164 
165 
166 } //namespace Scoring
167 } //namespace core