Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_IdealCoord.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 /// @file protocols/rna/RNA_IdealCoord.cc
10 /// @brief Apply ideal RNA geometry to a residue or a pose
11 /// @author Fang-Chieh Chou
12 
13 // Unit headers
15 #include <utility/vector1.hh>
16 #include <core/pose/Pose.hh>
17 #include <core/pose/util.hh>
21 #include <core/id/TorsionID.hh>
22 #include <core/id/AtomID.hh>
25 #include <basic/database/open.hh>
26 
27 // Numeric headers
28 #include <numeric/conversions.hh>
29 #include <numeric/constants.hh>
30 
31 //// C++ headers
32 #include <string>
33 #include <cmath>
34 
35 using namespace core;
36 using namespace core::pose;
37 using namespace core::scoring::rna;
38 
39 namespace protocols {
40 namespace rna {
41 
42 //////////////////////////////////////////////////////
43 RNA_IdealCoord::RNA_IdealCoord():
44  path_( basic::database::full_name("chemical/rna/ideal_geometry/") )
45 {
46  init();
47 }
48 
50 
51 /////////////////////////////////////////////////////
52 bool RNA_IdealCoord::is_torsion_exists(Pose const & pose, id::TorsionID const & torsion_id) const {
53  using namespace core::id;
54  Size res_index = torsion_id.rsd();
55  if ( res_index < 1 || res_index > pose.total_residue() ) return false;
56 
57  AtomID id1,id2,id3,id4;
58  bool fail = pose.conformation().get_torsion_angle_atom_ids( torsion_id, id1, id2, id3, id4 );
59  return (! fail);
60 }
61 /////////////////////////////////////////////////////
63  //Names of the pdb files
65  pdb_file_list.push_back( path_ + "/A_n_std.pdb" );
66  pdb_file_list.push_back( path_ + "/A_s_std.pdb" );
67  pdb_file_list.push_back( path_ + "/G_n_std.pdb" );
68  pdb_file_list.push_back( path_ + "/G_s_std.pdb" );
69  pdb_file_list.push_back( path_ + "/C_n_std.pdb" );
70  pdb_file_list.push_back( path_ + "/C_s_std.pdb" );
71  pdb_file_list.push_back( path_ + "/U_n_std.pdb" );
72  pdb_file_list.push_back( path_ + "/U_s_std.pdb" );
73 
74  //Initialize the reference poses
75  chemical::ResidueTypeSetCAP rsd_set = chemical::ChemicalManager::get_instance()->residue_type_set ( "rna" );
76  Pose ref_pose;
77  for (Size i = 1; i <= pdb_file_list.size(); ++i) {
78  import_pose::pose_from_pdb ( ref_pose, *rsd_set, pdb_file_list[i] );
79  ref_pose_list_.push_back(ref_pose);
80  }
81 }
82 
83 /////////////////////////////////////////////////////
84 void RNA_IdealCoord::apply( Pose & pose, Size const seqpos, bool const is_north, bool const keep_backbone_torsion ) const {
85 
86  using namespace core::id;
87  using namespace core::chemical;
88  using namespace core::conformation;
89 
90  Residue const & res = pose.residue( seqpos );
91  if ( !res.is_RNA() ) return;
92 
93  //Figure out the residue_type.
94  Size res_class = 0;
95  if ( res.aa() == na_rad ) {
96  res_class = 1;
97  } else if ( res.aa() == na_rgu ) {
98  res_class = 3;
99  } else if ( res.aa() == na_rcy ) {
100  res_class = 5;
101  } else if ( res.aa() == na_ura ) {
102  res_class = 7;
103  }
104  if (! is_north) ++res_class;
105 
106  //Record the torsions in starting pose
107  utility::vector1 < TorsionID > saved_torsion_id;
108  utility::vector1 < Real > saved_torsions;
109  if (keep_backbone_torsion) {
110  saved_torsion_id.push_back( TorsionID( seqpos, id::BB, ALPHA ) );
111  saved_torsion_id.push_back( TorsionID( seqpos, id::BB, BETA ) );
112  saved_torsion_id.push_back( TorsionID( seqpos, id::BB, GAMMA ) );
113  saved_torsion_id.push_back( TorsionID( seqpos, id::BB, EPSILON ) );
114  saved_torsion_id.push_back( TorsionID( seqpos, id::BB, ZETA ) );
115  saved_torsion_id.push_back( TorsionID( seqpos, id::CHI, 1 ) );
116  saved_torsion_id.push_back( TorsionID( seqpos, id::CHI, 4 ) );
117  saved_torsion_id.push_back( TorsionID( seqpos-1, id::BB, ZETA ) );
118  saved_torsion_id.push_back( TorsionID( seqpos+1, id::BB, ALPHA ) );
119  for (Size i = 1; i <= saved_torsion_id.size(); ++i) {
120  bool const is_exists = is_torsion_exists( pose, saved_torsion_id[i] );
121  if (is_exists) {
122  saved_torsions.push_back( pose.torsion( saved_torsion_id[i] ) );
123  } else {
124  saved_torsions.push_back( -9999 );
125  }
126  }
127  }
128 
129  //Apply ideal dofs
130  std::map <Size, Size> res_map;
131  res_map.insert( std::pair <Size, Size> (seqpos, 2) ); //Only the center res (#2) matters in ref_pose
132  Pose const & ref_pose = ref_pose_list_[res_class];
133  copy_dofs_match_atom_names(pose, ref_pose, res_map);
134 
135  //Copy back the original torsions
136  if (keep_backbone_torsion) {
137  for (Size i = 1; i <= saved_torsion_id.size(); ++i) {
138  if (saved_torsions[i] > -1000) {
139  pose.set_torsion( saved_torsion_id[i], saved_torsions[i] );
140  }
141  }
142  }
143 }
144 /////////////////////////////////////////////////////
145 //Apply ideal coords to whole pose.
146 //pucker_conformations: 0 for skipping, 1 for North, 2 for South
147 void RNA_IdealCoord::apply( Pose & pose, utility::vector1 < Size > const & pucker_conformations, bool const keep_backbone_torsion ) const {
148  if ( pose.total_residue() != pucker_conformations.size() ) {
149  utility_exit_with_message("RNA_IdealCoord::apply--pose.total_resdiue() != pucker_conformations.size() !!!!");
150  }
151  for (Size i = 1; i <= pose.total_residue(); ++i) {
152  switch ( pucker_conformations[i] ) {
153  case 0: //Skip
154  break;
155  case 1: //North
156  apply(pose, i, true, keep_backbone_torsion);
157  break;
158  case 2: //South
159  apply(pose, i, false, keep_backbone_torsion);
160  break;
161  default :
162  utility_exit_with_message("RNA_IdealCoord::apply--Invalid value for pucker_conformations!!!!");
163  }
164  }
165 }
166 /////////////////////////////////////////////////
167 
168 }
169 }