Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DecoyStruct.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/io/raw_data/DecoyStruct.cc
12 ///
13 /// @brief protein-specific "silent" file reader and writer for mini.
14 /// @author James Thompson, Monica Berrondo
15 
16 // C++ Headers
17 #include <vector>
18 #include <string>
19 #include <map>
20 
21 // mini headers
22 // AUTO-REMOVED #include <utility/io/izstream.hh>
23 // AUTO-REMOVED #include <utility/io/ozstream.hh>
24 // AUTO-REMOVED #include <utility/file/file_sys_util.hh>
25 
26 // AUTO-REMOVED #include <basic/Tracer.hh>
27 
29 
30 // AUTO-REMOVED #include <core/id/AtomID.hh>
31 #include <core/pose/Pose.hh>
33 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
34 
35 #include <numeric/model_quality/rms.hh>
36 
39 #include <utility/vector1.hh>
40 #include <ObjexxFCL/format.hh>
41 
42 
43 namespace core {
44 namespace io {
45 namespace raw_data {
46 
47 using namespace ObjexxFCL::fmt;
48 
50  core::pose::Pose const & pose,
51  std::string tag, // = "empty_tag",
52  bool fa // = false
53 ) : fullatom_( fa ) {
54  // tag information
55  decoy_tag_ = tag;
56 
57  // conformation information
58  sequence_ = pose.sequence();
59  resize( pose.total_residue() );
60  static const std::string important_atom = "CA";
61  for ( unsigned int i = 1; i <= pose.total_residue(); ++i ) {
62  core::conformation::Residue resi = pose.residue(i);
63  phi_ [i] = resi.mainchain_torsion( 1 );
64  psi_ [i] = resi.mainchain_torsion( 2 );
65  omega_[i] = resi.mainchain_torsion( 3 );
66  coords_[i] = resi.xyz( important_atom );
67  secstruct_[i] = pose.secstruct(i);
68  if ( fullatom() ) {
69  chi_[i] = resi.chi();
70  } // if ( fullatom )
71  } // for ( unsigned int i = 1; i <= pose.total_residue(); ++i )
72 } // DecoyStruct
73 
74 
75 /// @brief Resize this silent-struct to the appropriate number of residues.
76 void
78  Size const nres_in
79 )
80 {
81  nres_ = nres_in;
82  secstruct_.resize( nres_ );
83  phi_ .resize( nres_ );
84  psi_ .resize( nres_ );
85  omega_ .resize( nres_ );
86  coords_ .resize( nres_ );
87  chi_ .resize( nres_ );
88 }
89 
90 // @brief Fill a Pose with the data in this DecoyStruct.
92  core::pose::Pose & pose
93 ) {
94  using namespace core::chemical;
95  ResidueTypeSetCAP residue_set;
96  if ( fullatom() ) {
98  } else {
100  }
101  fill_pose( pose, *residue_set );
102 } // fill_pose
103 
105  core::pose::Pose & pose,
106  core::chemical::ResidueTypeSet const& residue_set
107 ) {
108 
109  // make_pose_match_sequence_( pose, sequence_, residue_set );
110  core::pose::make_pose_from_sequence( pose, sequence_, residue_set );
111 
112  for ( Size seqpos = 1; seqpos <= pose.total_residue(); ++seqpos ) {
113  pose.set_phi ( seqpos, phi_ [seqpos] );
114  pose.set_psi ( seqpos, psi_ [seqpos] );
115  pose.set_omega ( seqpos, omega_ [seqpos] );
116  if ( fullatom_ ) {
117  for ( Size j = 1; j <= pose.residue(seqpos).nchi(); ++j ){
118  pose.set_chi( j, seqpos, chi_[seqpos][j] );
119  }
120  }
121  pose.set_secstruct( seqpos, secstruct_[seqpos] );
122  }
123 
124 } // fill_pose
125 
126 /// @brief Print the conformation information contained in this object to the given ozstream.
127 void DecoyStruct::print_conformation( std::ostream& output ) const {
128  using namespace ObjexxFCL;
129 
130  for ( Size i = 1; i <= nres_; ++i ) {
131  output << I( 4, i ) << ' '
132  << secstruct_[i] << ' '
133  << F( 9, 3, phi_[i] )
134  << F( 9, 3, psi_[i] )
135  << F( 9, 3, omega_[i] )
136  << F( 9, 3, coords_[i].x() )
137  << F( 9, 3, coords_[i].y() )
138  << F( 9, 3, coords_[i].z() );
139  if ( fullatom_ ) {
140  for ( unsigned int chino = 1; chino <= 4; ++chino ) {
141  Real chi_to_print = 0.0f;
142  if ( chino <= chi_[i].size() ) {
143  chi_to_print = chi_[i][chino];
144  }
145  output << F( 9, 3, chi_to_print );
146  }
147  }
148 
149  output << ' ' << decoy_tag_;
150  output << std::endl;
151  } // for ( Size i = 1; i <= nres; ++i )
152 } // print_conformation
153 
155  using namespace ObjexxFCL;
156 
157  pose::Pose temp_pose;
158  FArray2D< Real > rebuilt_coords (3, coords_.size() ), original_coords( 3, coords_.size() );
159  static std::string atom_name = "CA";
160 
161  // build temp_pose from coordinates
162  fill_pose( temp_pose );
163 
164  for ( Size i = 1; i <= temp_pose.total_residue(); ++i ) {
165  for ( Size k = 1; k <= 3; ++k ) { // k = X, Y and Z
166  rebuilt_coords (k,i) = temp_pose.residue(i).xyz( atom_name )[k-1];
167  original_coords(k,i) = coords_[i][k-1];
168  }
169  }
170 
171  Real rmsd = numeric::model_quality::rms_wrapper( temp_pose.total_residue(), rebuilt_coords, original_coords );
172  return rmsd;
173 }
174 
175 } // namespace silent
176 } // namespace io
177 } // namespace core