Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MembraneTopology.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/MembraneTopology.cc
11 /// @brief MembraneTopology
12 /// @author Bjorn Wallner
13 ///
14 
15 
16 // Unit headers
18 
19 // Package headers
20 
21 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
22 
23 // Project headers
24 // AUTO-REMOVED #include <core/chemical/AA.hh>
25 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
26 // AUTO-REMOVED #include <core/conformation/Residue.hh>
27 // AUTO-REMOVED #include <basic/database/open.hh>
28 // AUTO-REMOVED #include <core/pose/Pose.hh>
29 #include <core/pose/Pose.hh>
30 #include <basic/options/option.hh>
31 #include <basic/options/keys/in.OptionKeys.gen.hh>
32 // AUTO-REMOVED #include <basic/options/after_opts.hh>
34 #include <basic/datacache/BasicDataCache.hh>
35 
36 // Utility headers
37 #include <utility/io/izstream.hh>
38 #include <basic/Tracer.hh>
39 
40 #include <utility/vector1.hh>
41 
42 
43 
44 // just for debugging
45 //#include <ObjexxFCL/format.hh>
46 
47 // C++
48 
49 
50 namespace core {
51 namespace scoring {
52 
53 static basic::Tracer TR("core.scoring.MembraneTopology");
54 
56  CacheableData()
57 {
58  helix_id_=src.helix_id_;
59  span_=src.span_;
65  depth_=src.depth_;
69  tmregion_=src.tmregion_;
73  init_=src.init_;
75 }
76 
77 void
79 {
80  using namespace basic::options;
81  using namespace basic::options::OptionKeys;
82  // std::string spanfile("BRD7.span");
83  TR << "Initialize Membrane spanning regions with " << spanfile << std::endl;
84  std::string line;
85  utility::io::izstream stream (spanfile);
86  getline(stream,line);
87  TR << line << std::endl;
88  getline(stream,line);
89  Size total_residue;
90  {
91  std::istringstream l(line);
92  TR << line << std::endl;
93  l>> total_tmhelix_ >> total_residue;
94  }
95 
96  Size const max_tmhelix(total_tmhelix_);
97  span_.dimension(max_tmhelix,2);
98  full_span_.dimension(max_tmhelix,2);
99  relative_tmh_ori_.dimension(max_tmhelix,max_tmhelix);
100  helix_id_.dimension(max_tmhelix);
101 
102 
103  getline(stream,line); //n2c
104  TR << line << std::endl;
105  getline(stream,line); //parallel
106  TR << line << std::endl;
107  for(Size i=1;i<=total_tmhelix_;++i)
108  {
109  getline(stream,line);
110  {
111  std::istringstream l(line);
112  l >> span_(i,1) >> span_(i,2);
113  }
114 
115  TR << line << std::endl ;
116  helix_id_(i)=i;
117  }
118  if(total_tmhelix_==0)
119  {
120  utility_exit_with_message("bad format for spanfile total_tmhelix=0");
121  }
122  stream.close();
123  stream.clear();
124 
125 
126 
127  for ( Size reg1 = 1; reg1 <= total_tmhelix_; ++reg1 ) {
128  for ( Size reg2 = 1; reg2 <= total_tmhelix_; ++reg2 ) {
129  relative_tmh_ori_(reg1,reg2)=1;
130  }
131  }
132 
133  full_span_(1,1)=1;
134  full_span_(total_tmhelix_,2)=total_residue;
135 
136  for ( Size reg1 = 2; reg1 <= total_tmhelix_; ++reg1 ) {
137  full_span_(reg1,1)=span_(reg1,1);
138  full_span_(reg1-1,2)=span_(reg1,1);
139  }
140  depth_.resize(total_residue,0.0);
141  tmregion_.resize(total_residue,false);
142  allow_scoring_.resize(total_residue,true);
143  allow_tmh_scoring_.resize(total_tmhelix_,true);
145 
146  for(Size i=1;i<=total_residue;++i) {
147  for ( Size reg1 = 1; reg1 <= total_tmhelix_; ++reg1 ) {
148  if(i>=span_(reg1,1) && i<=span_(reg1,2)) {
149  tmregion_[i]=true;
150  continue;
151  }
152  }
153  //TR << "tmregion " << i << " " << tmregion_[i] << std::endl;
154  }
155 
156  //init Lipo
157  if(option[in::file::lipofile].user())
158  {
159  Size NumberOfConstraints(0);
160  Size resnum;
161  Real exposure;
162 
163  std::string lipofile(option[OptionKeys::in::file::lipofile]());
164  TR << "init lipo using " << lipofile << std::endl;
165  LipidExposure_.resize(total_residue,0.0);
166  LipidBurial_.resize(total_residue,0.0);
167  stream.open(lipofile);
168 
169  if(stream) {
170  getline(stream,line);
171  getline(stream,line);
172  while(!stream.eof()) {
173  std::istringstream l(line);
174 
175  l >> resnum;
176  l >> exposure;
177  if(exposure>0) {
178  LipidExposure_[resnum]+=exposure;
179  NumberOfConstraints++;
180  } else {
181  LipidBurial_[resnum]+=std::abs(exposure);
182  NumberOfConstraints++;
183  }
184  TR << resnum << " " << exposure << " " << LipidExposure_[resnum] << " " << LipidBurial_[resnum] << std::endl;
185  getline(stream,line);
186  }
187  stream.close();
188  stream.clear();
189  TR << NumberOfConstraints << " exposure constraints read!" << std::endl;
190  if(NumberOfConstraints>0)
191  {
192  LipoDefined_=true;
193  }
194  }else{
195  TR << "unable to open " << lipofile << std::endl;
196  }
197 
198 
199 
200  }
201 
202 
203 
204  init_=true;
205  //pba
206  initialized_=true;
207  return;
208 }
209 
210 void
212 {
213 
214  for(Size i=1;i<=total_tmhelix_;++i)
215  {
216  span_(i,1)+=shift;
217  span_(i,2)+=shift;
218  full_span_(i,1)+=shift;
219  full_span_(i,2)+=shift;
220  if(full_span_(i,1)<=0)
221  {
222  utility_exit_with_message("Span out of bounds");
223  }
224  }
225 }
226 
227 //void
228 //MembraneTopology::attach_to_pose(pose::Pose & pose)
229 //{
230 // if ( pose.data().has( basic::MEMBRANE_TOPOLOGY ) ) {
231 //
232 // core::scoring::MembraneTopologyOP topology = *this; //new core::scoring::MembraneTopology;
233 // return *( static_cast< core::scoring::MembraneTopology * >( pose.data().get_ptr( basic::MEMBRANE_TOPOLOGY )() ));
234 // }
235  // else
236 // core::scoring::MembraneTopologyOP topology = *this;
237 // pose.data().set( basic::MEMBRANE_TOPOLOGY, *this); //topology );
238 
239 //}
240 
241 void
243 {
244  TR << "TOTAL TMH " << total_tmhelix_ << std::endl;
245  for(Size i=1;i<=total_tmhelix_;++i)
246  {
247  TR << "SPAN " << i << " " << span_(i,1) << " " << span_(i,2) << std::endl;
248  }
249 }
250 
251 
252 void
254 {
255 
256  // Assume list is sorted for now...
257  // Will add a sorter here later....
258 
259  if(TMH_list.size()>src.total_tmhelix_)
260  {
261  utility_exit_with_message("Too long TMH_list");
262  }
263  Size const len(TMH_list.size());
264  span_.dimension(len,2);
265  full_span_.dimension(len,2);
266  relative_tmh_ori_.dimension(len,len);
267 
268 
269  for(Size i=1;i<=len;++i)
270  {
271  span_(i,1)=src.span_(TMH_list[i],1);
272  span_(i,2)=src.span_(TMH_list[i],2);
273  full_span_(i,1)=src.full_span_(TMH_list[i],1);
274  full_span_(i,2)=src.full_span_(TMH_list[i],2);
275  helix_id_(i)=TMH_list[i];
276  for(Size j=1;j<=TMH_list.size();++j)
277  {
278  relative_tmh_ori_(i,j)=src.relative_tmh_ori_(TMH_list[i],TMH_list[j]);
279  }
280  }
281 
282 
283 
284  total_tmhelix_=TMH_list.size();
285 
286 
287 
288 
289 }
290 //pbadebug
291 MembraneTopology const &
293 {
294  // ////using core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY;
295 
297  return *( static_cast< MembraneTopology const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY )() ));
298 }
299 
300 /// @details Either returns a non-const reference to the cenlist object already stored
301 /// in the pose, or creates a new cenist object, places it in the pose, and returns
302 /// a non-const reference to it.
305 {
306  // ////using core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY;
307 
309  return *( static_cast< MembraneTopology * >( pose.data().get_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY )() ));
310  }
311  // else
312  MembraneTopologyOP membrane_topology = new MembraneTopology;
313  pose.data().set( core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY, membrane_topology );
314  return *membrane_topology;
315 }
316 //pbadebug
317 /*
318 MembraneTopology &
319 MembraneTopology_from_pose( pose::Pose const & pose ) const
320 {
321  return *( static_cast< MembraneTopology const * >( pose.data().get_const_ptr( basic::MEMBRANE_TOPOLOGY )() ));
322 }
323 */
324 }
325 }