Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StubGenerator.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
11 /// @brief
12 /// @author Alex Ford (fordas@u.washington.edu)
13 
14 // Unit headers
16 #include <core/kinematics/RT.hh>
17 #include <core/kinematics/Stub.hh>
18 #include <core/kinematics/Jump.hh>
22 #include <core/chemical/util.hh>
26 #include <core/pose/Pose.hh>
28 #include <basic/Tracer.hh>
29 
31 
32 // Utility Headers
33 #include <core/types.hh>
34 #include <utility/pointer/ReferenceCount.hh>
35 #include <utility/pointer/owning_ptr.hh>
36 
37 #include <utility/vector1.hh>
38 
39 namespace protocols {
40 namespace hotspot_hashing {
41 
42 static basic::Tracer tr( "protocols.hotspot_hashing.StubGenerator" );
43 
45 {
46  using namespace core::conformation;
47  using namespace core::chemical;
48 
50  rsd_set_from_cmd_line()->name_map( name ) );
51 
53 
54  return residue;
55 }
56 
58 {
59  tr.Debug << "Placing at transform: " << transform << std::endl;
60 
61  core::conformation::ResidueOP new_residue(new core::conformation::Residue(*sourceResidue));
62  moveIntoStubFrame(new_residue, transform);
63 
64  // Places residue at last jump & residue number
65  placeResidueOnPose(pose, new_residue);
66  residueindex = pose.total_residue();
67  residuejumpindex = pose.num_jump();
68 
69  tr.Debug << "Placed residue at anchor location: " << pose.residue(residueindex).xyz("CA") << std::endl;
70 }
71 
73 {
75  *residue,
76  pose.total_residue(),
77  "",
78  residue->atom_name(residue->nbr_atom()),
79  true );
80 
81  if(pose.num_jump() != 0)
82  {
83  // Adjust jump to realign residue
84  core::Size atom_center;
85  core::Size atom_a;
86  core::Size atom_b;
87  residue->select_orient_atoms(atom_center, atom_a, atom_b);
88 
89  core::kinematics::Stub source_stub(
90  residue->xyz(atom_center),
91  residue->xyz(atom_a),
92  residue->xyz(atom_b));
93 
94  core::kinematics::Stub current_stub(
95  pose.residue(pose.total_residue()).xyz(atom_center),
96  pose.residue(pose.total_residue()).xyz(atom_a),
97  pose.residue(pose.total_residue()).xyz(atom_b));
98 
99  core::kinematics::RT transform(source_stub, current_stub);
100 
101  core::kinematics::Stub upstreamstub = pose.conformation().upstream_jump_stub(pose.num_jump());
102  core::kinematics::Jump residuejump = pose.jump(pose.num_jump());
103  core::kinematics::Jump newjump(residuejump);
104 
105  newjump.rotation_by_matrix(upstreamstub, source_stub.v, transform.get_rotation());
106  if (transform.get_translation().length() != 0)
107  {
108  newjump.translation_along_axis(upstreamstub, transform.get_translation(), transform.get_translation().length());
109  }
110 
111  pose.set_jump(pose.num_jump(), newjump);
112  }
113 
114 
115  tr.Debug << "Appended residue on pose. Residue: " << pose.total_residue() << " Jump: " << pose.num_jump() << " Anchor atom: " << residue->atom_name(residue->nbr_atom()) << std::endl;
116 }
117 
119 {
120  for (core::Size i = 1; i <= residue->natoms(); i++)
121  {
122  residue->set_xyz(i, transform.local2global(residue->xyz(i)));
123  }
124 }
125 
127 {
128  for (core::Size i = 1; i <= residue->natoms(); i++)
129  {
130  residue->set_xyz(i, transform.global2local(residue->xyz(i)));
131  }
132 }
133 
135 {
136  core::Size a, b, c;
137  residue->select_orient_atoms( a, b, c );
138  core::kinematics::Stub result(residue->xyz(a), residue->xyz(b), residue->xyz(c));
139 
140  return result;
141 }
142 
144 {
145  // Obtain the stub needed to generate
146  // Canonical transform aligns CA atom to <0, 0, 0>
147  // CA->SC heavyatom centroid vector along <1,0,0>
148  // CA->C vector on the XY plane (<CA->C> * <0,0,1> == 0)
149 
150  core::kinematics::Stub result;
151 
152  result.from_four_points(
153  residue->xyz(residue->atom_index("CA")),
154  residueStubCentroid(residue),
155  residue->xyz(residue->atom_index("CA")),
156  residue->xyz(residue->atom_index("C")));
157 
158  return result;
159 }
160 
162 {
163  Vector centroid;
164  centroid = 0;
165 
166  if (residue->first_sidechain_atom() > residue->nheavyatoms())
167  {
168  return residue->xyz(residue->nbr_atom());
169  }
170 
171  for (core::Size i = residue->first_sidechain_atom(); i <= residue->nheavyatoms(); ++i)
172  {
173  centroid += residue->xyz(i);
174  }
175 
176  centroid /= (1 + residue->nheavyatoms() - residue->first_sidechain_atom());
177 
178  return centroid;
179 }
180 
181 } // namespace hotspot_hashing
182 } // namespace protocols