Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UnboundRotamersOperation.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/pack/rotamer_set/UnboundRotamersOperation.cc
11 ///
12 /// @brief
13 /// @author Ian W. Davis
14 
15 
17 
19 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
20 #include <core/io/pdb/file_data.hh>
21 #include <basic/options/option.hh>
24 #include <core/pose/Pose.hh>
25 #include <basic/Tracer.hh>
26 
27 #ifdef WIN32
28 #include <core/graph/Graph.hh>
29 #endif
30 
31 
32 // option key includes
33 
34 #include <basic/options/keys/packing.OptionKeys.gen.hh>
35 
36 #include <utility/vector1.hh>
37 
38 //Auto Headers
39 //#include <core/import_pose/import_pose.hh>
40 
41 
42 namespace core {
43 namespace pack {
44 namespace rotamer_set {
45 
46 
47 static basic::Tracer TR("core.pack.rotamer_set.UnboundRotamersOperation");
48 
49 
52  total_rot_(0),
53  poses_()
54 {
55 }
56 
57 
59 
60 
63 {
64  return new UnboundRotamersOperation( *this );
65 }
66 
67 
69 {
70  poses_.push_back(pose);
71  if(pose->total_residue() > total_rot_) total_rot_ = pose->total_residue();
72 }
73 
74 
76 {
77  return total_rot_;
78 }
79 
80 
82 {
83  using namespace basic::options;
84  if( !option[ OptionKeys::packing::unboundrot ].active() ) return;
85  for(Size i = 1; i <= option[ OptionKeys::packing::unboundrot ]().size(); ++i) {
86  std::string filename = option[ OptionKeys::packing::unboundrot ]()[i].name();
87  TR << "Adding 'unbound' rotamers from " << filename << std::endl;
89  //core::import_pose::pose_from_pdb( *pose, filename );
91  this->add_pose( pose );
92  }
93 }
94 
95 
96 /// @brief Helper function, combines existing's metadata with conformer's conformation.
99  conformation::Residue const & existing,
100  conformation::Residue const & conformer
101 )
102 {
103  // This is bad: fields like seqpos, chain, etc. don't match existing residue!
104  //conformation::ResidueOP newrsd = rotamers_[i]->clone();
105 
106  // Could start by cloning either one, but I think people are more likely to introduce
107  // new metadata than new conformational data, so I'll let clone() copy the metadata.
108  //conformation::ResidueOP newrsd = existing.clone();
109  //newrsd->atoms() = conformer.atoms();
110  //newrsd->chi() = conformer.chi();
111  //newrsd->mainchain_torsions() = conformer.mainchain_torsions();
112  //newrsd->actcoord() = conformer.actcoord();
113 
114  // The above is also bad: existing may not be the same residue type as conformer!
115  conformation::ResidueOP newrsd = conformer.clone();
116  newrsd->chain( existing.chain() );
117  newrsd->seqpos( existing.seqpos() );
118  newrsd->copy_residue_connections_from( existing ); // this is probably not good enough if residue types diverge more than protonation state...
119 
120  return newrsd;
121 }
122 
123 
124 void
126  pose::Pose const & pose,
127  scoring::ScoreFunction const & /*sfxn*/,
128  task::PackerTask const & ptask,
129  graph::GraphCOP /*packer_neighbor_graph*/,
131 )
132 {
133  Size const seqnum = (Size) rotamer_set.resid();
134  assert( seqnum <= ptask.total_residue() );
135  core::pack::task::ResidueLevelTask const & rtask = ptask.residue_task(seqnum);
136  for(Size i = 1; i <= poses_.size(); ++i) {
137  core::pose::Pose const & ubr_pose = *(poses_[i]);
138  if(seqnum > ubr_pose.total_residue()) continue;
139  core::chemical::ResidueType const & restype = ubr_pose.residue_type(seqnum);
140  bool type_is_allowed = false;
141  for(core::pack::task::ResidueLevelTask::ResidueTypeCOPListConstIter j = rtask.allowed_residue_types_begin(),
142  j_end = rtask.allowed_residue_types_end(); j != j_end; ++j)
143  {
144  if( restype.name() == (**j).name() ) {
145  type_is_allowed = true;
146  break;
147  }
148  }
149  if( type_is_allowed ) {
150  TR.Debug << "Adding 'unbound' rotamer at position " << seqnum << std::endl;
151  conformation::ResidueOP newrsd = dup_residue( pose.residue(seqnum), ubr_pose.residue(seqnum) );
152  newrsd->place( pose.residue(seqnum), pose.conformation() );
153  rotamer_set.add_rotamer( *newrsd );
154  } else {
155  TR.Debug << "Residue names do not match. Skipping 'unbound' rotamer at position " << seqnum << std::endl;
156  }
157  }
158 }
159 
160 
161 } // namespace rotamer_set
162 } // namespace pack
163 } // namespace core