Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AddHydrogen.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 protocols/ligand_docking/AddHydrogen.cc
11 ///
12 /// @brief
13 /// @Gordon Lemmon
14 
16 
17 #include <protocols/moves/Mover.hh>
18 
19 #include <core/types.hh>
20 
21 #include <basic/Tracer.hh>
22 
23 #include <ObjexxFCL/string.functions.hh>
24 
26 
29 
31 #include <utility/vector0.hh>
32 #include <utility/vector1.hh>
33 #include <numeric/random/random.hh>
34 
35 //Auto Headers
37 #include <core/kinematics/Jump.hh>
38 #include <core/pose/Pose.hh>
39 
40 
41 namespace protocols {
42 namespace ligand_docking {
43 
44 
46  //utility::pointer::ReferenceCount(),
47  Mover("AddHydrogen")
48 {
49  Mover::type( "AddHydrogen" );
50 }
51 
52 AddHydrogen::AddHydrogen(core::Size const residue_index, core::Size const connection_id):
53  //utility::pointer::ReferenceCount(),
54  Mover("AddHydrogen"),
55  residue_index_(residue_index),
56  connection_id_(connection_id)
57 {
58  Mover::type( "AddHydrogen" );
59 }
60 
62  //utility::pointer::ReferenceCount(),
63  protocols::moves::Mover( that ),
64  residue_index_(that.residue_index_),
65  connection_id_(that.connection_id_)
66 {}
67 
69 
71  return "AddHydrogen";
72 }
73 
74 
75 void
77 {
78  core::conformation::Residue const & res_to_fix= pose.residue(residue_index_);
79  core::chemical::ResidueConnection const & res_connection= res_to_fix.residue_connection(connection_id_);
80  core::chemical::AtomICoor const & new_i_coor= res_connection.icoor();
81 
82  core::chemical::ResidueTypeOP type_to_fix= res_to_fix.type().clone();
83  type_to_fix->name( generate_unique_name() );
84  core::Size res_conn_atom_index= type_to_fix->residue_connect_atom_index(connection_id_);
85 
86  core::chemical::AddAtom aa(" HH ", "Hapo", "X", 0.09);
87  aa.apply(*type_to_fix);
88  core::chemical::AddBond ab(" HH ", res_to_fix.atom_name(res_conn_atom_index));
89  ab.apply(*type_to_fix);
90 
91  core::Size stub_atom1= new_i_coor.stub_atom1().atomno();
92  core::Size stub_atom2= new_i_coor.stub_atom2().atomno();
93  core::Size stub_atom3= new_i_coor.stub_atom3().atomno();
94 
95  std::string name1= res_to_fix.atom_name(stub_atom1);
96  std::string name2= res_to_fix.atom_name(stub_atom2);
97  std::string name3= res_to_fix.atom_name(stub_atom3);
98 
99  core::chemical::SetICoor set_i_coor(
100  "HH",/// name this in the style of the other Hs (H1,H2,H3, etc)
101  new_i_coor.phi(),
102  new_i_coor.theta(),
103  1.11, ///TODO Lookup from bond-length table
104  name1,
105  name2,
106  name3
107  );
108  set_i_coor.apply(*type_to_fix);
109 
110  type_to_fix->finalize();
111  {
114  rsd_set.add_residue_type(type_to_fix);
115  }
117  atom_pairs.push_back(std::pair<std::string, std::string>(name1,name1) );
118  atom_pairs.push_back(std::pair<std::string, std::string>(name2,name2) );
119  atom_pairs.push_back(std::pair<std::string, std::string>(name3,name3) );
120 
121  core::conformation::Residue new_res(*type_to_fix, true);
122  //type_to_fix_is_good
123  pose.replace_residue(residue_index_, new_res, atom_pairs);
124 }
125 
129 
130  std::string new_name;
131 
132  do{
133  new_name.clear();
134  char a= numeric::random::random_range(65, 90); // ascii range for upper case letters
135  char b= numeric::random::random_range(65, 90); // ascii range for upper case letters
136  char c= numeric::random::random_range(65, 90); // ascii range for upper case letters
137 
138 
139  new_name.append(1,a);
140  new_name.append(1,b);
141  new_name.append(1,c);
142 
143  } while( rsd_set.has_name(new_name));
144 
145  return new_name;
146 
147 }
148 
149 } // namespace ligand_docking
150 } // namespace protocols