Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SuperimposeMover.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 SuperimposeMover.cc
11 ///
12 /// @brief
13 /// @author Ingemar Andre
14 
15 // unit headers
18 
19 // type headers
20 #include <core/types.hh>
21 #include <core/id/types.hh>
22 
23 // project headers
24 #include <protocols/moves/Mover.hh>
25 #include <core/scoring/rms_util.hh>
26 #include <core/id/AtomID.hh>
27 #include <core/id/AtomID_Map.hh>
29 #include <core/pose/util.hh>
31 
32 // utility header
33 #include <basic/Tracer.hh>
34 #include <utility/vector1.hh>
35 #include <utility/exit.hh>
36 #include <basic/options/keys/OptionKeys.hh>
37 #include <basic/options/option.hh>
38 #include <utility/tag/Tag.hh>
39 
40 //option key includes
41 #include <basic/options/keys/in.OptionKeys.gen.hh>
42 
43 namespace protocols {
44 namespace simple_moves {
45 
46 static basic::Tracer TR("protocols.simple_moves.SuperimposeMover");
47 
50 {
52 }
53 
56  return new SuperimposeMover;
57 }
58 
61 {
62  return "Superimpose";
63 }
64 
66  protocols::moves::Mover("SuperimposeMover"),
67  ref_pose_(0)
68 {}
69 
71  protocols::moves::Mover("SuperimposeMover"),
72  ref_pose_(new Pose(pose))
73  {}
74 
76 
79 {
80  return new SuperimposeMover( *this );
81 }
82 
85 {
86  return new SuperimposeMover();
87 }
88 
89 void
91  ref_pose_ = new Pose(pose);
92  ref_start_ = start;
93  ref_end_ = (end == 0) ? pose.total_residue() : end;
94  runtime_assert(ref_start_ > 0 && ref_start_ < ref_end_ && ref_end_ <= pose.total_residue());
95 }
96 
97 void
100  target_end_ = end;
101  runtime_assert(target_start_ > 0 && target_start_ < target_end_);
102 }
103 
104 /// @details copied and modified from calpha_superimpose_pose
107  core::pose::Pose & mod_pose,
108  core::pose::Pose const & ref_pose,
109  Size ref_start,
110  Size ref_end,
111  Size target_start,
112  Size /*target_end*/
113 )
114 {
116  std::map< core::id::AtomID, core::id::AtomID> atom_id_map;
118  for ( Size i_target = target_start, i_ref = ref_start; i_ref <= ref_end; ++i_ref, ++i_target ) {
119  if ( ! mod_pose.residue(i_target).has("CA") ) continue;
120  if ( ! ref_pose.residue(i_ref).has("CA") ) continue;
121 
122  core::id::AtomID const id1( mod_pose.residue(i_target).atom_index("CA"), i_target );
123  core::id::AtomID const id2( ref_pose.residue(i_ref).atom_index("CA"), i_ref );
124  atom_map.set( id1, id2 );
125  atom_id_map.insert( std::make_pair(id1, id2) );
126 
127  }
128  return core::scoring::superimpose_pose( mod_pose, ref_pose, atom_map );
129 }
130 
131 void
133  using namespace basic::options;
134 
135  if(ref_pose_ == 0) {
136  TR << "using -in:file:native as the reference pose " << std::endl;
137  ref_pose_ = core::import_pose::pose_from_pdb( option[ OptionKeys::in::file::native ].value() );
138  }
139 
140  const Size ref_start = ref_start_;
141  const Size target_start = target_start_;
142  const Size ref_end = (ref_end_ == 0) ? ref_pose_->total_residue() : ref_end_;
143  const Size target_end = (target_end_ == 0) ? pose.total_residue() : target_end_;
144 
145  TR << "ref_start: "<< ref_start << " ref_end " << ref_end <<std::endl;
146  TR << "target_start: "<< target_start << " target_end " << target_end <<std::endl;
147  runtime_assert(ref_start > 0 && ref_start < ref_end && ref_end <= pose.total_residue());
148  runtime_assert_msg(ref_end - ref_start == target_end - target_start, "segments to superimpose have different lenghts!");
149 
150  if ( ref_pose_->total_residue() == pose.total_residue() ) {
151  //core::Real rms = superimpose( pose, *ref_pose_, ref_start, ref_end, target_start, target_end );
152  //TR << "Rms to reference: " << rms << std::endl;
153  }
154 }
155 
158  return "SuperimposeMover";
159 }
160 
161 void
163  protocols::moves::DataMap & /*data_map*/,
166  core::pose::Pose const & )
167 {
168  ref_start_ = tag->getOption< Size >("ref_start",1);
169  ref_end_ = tag->getOption< Size >("ref_end",0);
170  target_start_ = tag->getOption< Size >("target_start",1);
171  target_end_ = tag->getOption< Size >("target_end",0);
172  if( tag->hasOption("ref_pose") ) ref_pose_ = core::import_pose::pose_from_pdb(tag->getOption< std::string >("ref_pose"));
173 }
174 
175 } // moves
176 } // protocols