Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_CS_Util.cc
Go to the documentation of this file.
1 // (c) Copyright Rosetta Commons Member Institutions.
2 // (c) This file is part of the Rosetta software suite and is made available under license.
3 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
4 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
5 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
6 
7 
8 /// @file core/scoring/rna/chemical_shift/RNA_CS_Util.cc
9 /// @brief
10 /// @author Parin Sripakdeevong (sripakpa@stanford.edu)
11 
12 
14 
15 #include <ObjexxFCL/format.hh>
16 #include <core/chemical/AA.hh>
17 
18 #include <numeric/xyzMatrix.hh>
19 
20 //////////////////////////////////////////////////////////////////////////////////
21 //////////////////////////////////////////////////////////////////////////////////
22 //////////////////////////////////////////////////////////////////////////////////
23 
24 using namespace core;
25 
26 namespace core {
27 namespace scoring {
28 namespace rna {
29 namespace chemical_shift {
30 
31 
33 get_rna_base_coordinate_system_from_CS_params( core::conformation::Residue const & rsd, RNA_CS_residue_parameters const & rna_cs_rsd_params){ //x and y coordinate different from 'standard' get_rna_base_coordinate_system;
34 
35  using namespace chemical;
36  Size res_type = rsd.aa();
37 
38  if( rsd.is_RNA()==false ) utility_exit_with_message("rsd.is_RNA()==false!");
39 
40  if( rsd.aa()!= rna_cs_rsd_params.aa() ) utility_exit_with_message("rsd.aa()!= rna_cs_rsd_params.aa()!");
41 
42  //RNA_CS_residue_parameters const & rna_cs_rsd_params=rna_cs_params.get_RNA_CS_residue_parameters(rsd.aa());
43 
44 
45  numeric::xyzVector<core::Real> xf_xyz(0.0, 0.0, 0.0);
46  numeric::xyzVector<core::Real> yf_xyz(0.0, 0.0, 0.0);
47  numeric::xyzVector<core::Real> xt_xyz(0.0, 0.0, 0.0);
48  numeric::xyzVector<core::Real> yt_xyz(0.0, 0.0, 0.0);
49 
50  Size xf_count = 0;
51  Size yf_count = 0;
52 
53  Size xt_count = 0;
54  Size yt_count = 0;
55 
56  Size const maxatoms=rna_cs_rsd_params.get_atomnames_size();
57 
58  for (Size count = 1; count < maxatoms; count++)
59  {
60 
61  Size const atom_index=rsd.atom_index(rna_cs_rsd_params.get_atomname(count));
62 
63  numeric::xyzVector<core::Real> const & atom_xyz=rsd.xyz(atom_index);
64 
65  if(dround(rna_cs_rsd_params.atom_data(count, xdir))==1){
66  xf_count++;
67  xf_xyz += atom_xyz;
68  }else if(dround(rna_cs_rsd_params.atom_data(count, xdir))==2){
69  xt_count++;
70  xt_xyz += atom_xyz;
71  }
72 
73  if(dround(rna_cs_rsd_params.atom_data(count, ydir))==1){
74  yf_count++;
75  yf_xyz += atom_xyz;
76  }else if(dround(rna_cs_rsd_params.atom_data(count, ydir))==2){
77  yt_count++;
78  yt_xyz += atom_xyz;
79  }
80 
81  }
82 
83  if(xf_count!=1 && xf_count!=2) utility_exit_with_message("xf_count!=1 && xf_count!=2");
84 
85  if(xt_count!=1 && xt_count!=2) utility_exit_with_message("xt_count!=1 && xt_count!=2");
86 
87  if(yf_count!=1 && yf_count!=2) utility_exit_with_message("yf_count!=1 && yf_count!=2");
88 
89  if(yt_count!=1 && yt_count!=2) utility_exit_with_message("yt_count!=1 && yt_count!=2");
90 
91  //Feb 21, 2012: UMM THIS FOLLOWS DEFINITION GIVEN IN NUCHEMICS..BUT x_base_coor and y_base_coor might not be completely perpendicular!
92 
93  numeric::xyzVector<core::Real> x_base_coor = ( (xt_xyz / xt_count) - (xf_xyz / xf_count) );
94 
95  x_base_coor.normalize();
96 
97 
98  numeric::xyzVector<core::Real> y_base_coor = ( (yt_xyz / yt_count) - (yf_xyz / yf_count) );
99 
100  y_base_coor.normalize();
101 
102  numeric::xyzVector<core::Real> z_base_coor = cross(x_base_coor, y_base_coor);
103 
104  z_base_coor.normalize(); //necessary since x_base_coor and y_base_corr are not completely orthogonal!
105 
106 
107  numeric::xyzMatrix< core::Real > const M=numeric::xyzMatrix< core::Real >::cols( x_base_coor, y_base_coor, z_base_coor );
108 
109  return M;
110 
111 }
112 
113 
114 /////////////////////////////////////////////////////////////////////////////
115 
116 
117 
118 } // chemical_shift
119 } // rna
120 } // scoring
121 } // core