Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UpstreamResTypeGeometry.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 protocols/match/upstream/ProteinUpstreamBuilder.cc
12 /// @brief
13 /// @author Alex Zanghellini (zanghell@u.washington.edu)
14 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
15 
16 // Unit headers
18 
19 // Package headers
20 // AUTO-REMOVED #include <protocols/match/upstream/OriginalScaffoldBuildPoint.hh>
21 
22 // Project headers
24 #include <core/chemical/Atom.hh>
25 
26 // Utility headers
27 #include <utility/exit.hh>
28 // AUTO-REMOVED #include <utility/string_util.hh>
29 
30 #include <utility/vector1.hh>
31 
32 
33 namespace protocols {
34 namespace match {
35 namespace upstream {
36 
37 /// @details Auto-generated virtual destructor
39 
40 
42  restype_name_( "UNINITIALIZED" ),
43  N_atom_id_( 0 ),
44  CA_atom_id_( 0 ),
45  C_atom_id_( 0 ),
46  O_atom_id_( 0 ),
47  CB_atom_id_( 0 ),
48  H_atom_id_( 0 ),
49  HA_atom_id_( 0 )
50 {}
51 
53  restype_name_( res.name() ),
54  N_atom_id_( 0 ),
55  CA_atom_id_( 0 ),
56  C_atom_id_( 0 ),
57  O_atom_id_( 0 ),
58  CB_atom_id_( 0 ),
59  H_atom_id_( 0 ),
60  HA_atom_id_( 0 )
61 {
63 }
64 
65 void
67  core::chemical::ResidueType const & res
68 )
69 {
70  if ( restype_name_ != res.name() ) {
71  restype_name_ = res.name();
72  }
73 
74  /// 1. Resize arrays that depend on the number of atoms
75  Size const n_atoms = res.natoms();
76 
78  which_point_for_atom_.resize( n_atoms );
79  std::fill( which_point_for_atom_.begin(), which_point_for_atom_.end(), 0 );
80  restype_atom_id_2_nonchi_atom_id_.resize( n_atoms );
83  nonchi_atoms_in_ideal_frame_.resize( 0 );
84 
85  /// 2. Resize arrays that depend on the number of chi
86  Size const n_chi = res.nchi();
87 
88  chitip_atoms_.resize( n_chi );
89  std::fill( chitip_atoms_.begin(), chitip_atoms_.end(), 0 );
90 
91  ht_for_chitip_atoms_.resize( n_chi );
92  for ( Size ii = 1; ii <= n_chi; ++ii ) ht_for_chitip_atoms_[ ii ].set_identity();
93 
94  nonchitip_atoms_.resize( res.nchi() );
95  for ( Size ii = 1; ii <= n_chi; ++ii ) nonchitip_atoms_[ ii ].clear();
96 
97  points_for_nonchitip_atoms_.resize( res.nchi() );
98  for ( Size ii = 1; ii <= n_chi; ++ii ) points_for_nonchitip_atoms_[ ii ].clear();
99 
100  /// Quick atom indexing
101 
102  N_atom_id_ = ( res.has( "N" ) ? res.atom_index("N") : 0 );
103  CA_atom_id_ = ( res.has( "CA" ) ? res.atom_index("CA") : 0 );
104  C_atom_id_ = ( res.has( "C" ) ? res.atom_index("C") : 0 );
105  O_atom_id_ = ( res.has( "O" ) ? res.atom_index("O") : 0 );
106  CB_atom_id_ = ( res.has( "CB" ) ? res.atom_index("CB") : 0 );
107  H_atom_id_ = ( res.has( "H" ) ? res.atom_index("H") : 0 );
108  HA_atom_id_ = ( res.has( "HA" ) ? res.atom_index("HA") : 0 );
109 
110  if ( HA_atom_id_ == 0 && res.aa() == core::chemical::aa_gly ) {
111  HA_atom_id_ = ( res.has( "2HA" ) ? res.atom_index( "2HA" ) : 0 );
112  }
113 
114  if ( N_atom_id_ != 0 && CA_atom_id_ != 0 && C_atom_id_ != 0 ) {
115 
116  Vector halfpoint = 0.5 * ( res.atom( N_atom_id_ ).ideal_xyz() + res.atom( C_atom_id_ ).ideal_xyz() );
117  HTReal ideal_frame( res.atom( N_atom_id_ ).ideal_xyz(), halfpoint, res.atom( CA_atom_id_ ).ideal_xyz() );
118 
119  /// backbone atoms, besides the cannonical 3
120  for ( Size ii = 1; ii <= n_atoms; ++ii ) {
121  if ( ii == N_atom_id_ || ii == CA_atom_id_ || ii == C_atom_id_ ) continue;
122  if ( res.last_controlling_chi( ii ) != 0 ) continue;
123  nonchi_atoms_in_ideal_frame_.push_back( ideal_frame.to_local_coordinate( res.atom( ii ).ideal_xyz() ));
124  nonchi_atom_id_2_restype_atom_id_.push_back( ii );
126  }
127  }
128 
129 
130  if ( nchi() == 0 ) return; // match from gly? can't see why you'd want to!
131 
132 
133  for ( Size ii = 1; ii <= n_chi; ++ii ) {
134  assert( res.chi_atoms( ii ).size() == 4 );
135 
136  Size const
137  chiat2( res.chi_atoms( ii )[ 2 ] ),
138  chiat3( res.chi_atoms( ii )[ 3 ] ),
139  chiat4( res.chi_atoms( ii )[ 4 ] );
140 
141  chitip_atoms_[ ii ] = chiat4;
142 
143 
144  ht_for_chitip_atoms_[ ii ].set_xaxis_rotation_rad( -1 * res.icoor( chiat4 ).theta() );
145  ht_for_chitip_atoms_[ ii ].walk_along_z( res.icoor( chiat4 ).d() );
146 
147  HTReal chi_tip_frame(
148  res.atom( chiat2 ).ideal_xyz(),
149  res.atom( chiat3 ).ideal_xyz(),
150  res.atom( chiat4 ).ideal_xyz() );
151 
152  Size const n_nontip_ats_for_chi = res.atoms_last_controlled_by_chi( ii ).size() - 1;
153 
154  nonchitip_atoms_[ ii ].reserve( n_nontip_ats_for_chi );
155  points_for_nonchitip_atoms_[ ii ].reserve( n_nontip_ats_for_chi );
156 
157  for ( Size jj = 1; jj <= res.atoms_last_controlled_by_chi( ii ).size(); ++jj ) {
158  Size const jjatom = res.atoms_last_controlled_by_chi( ii )[ jj ];
159  if ( jjatom == chiat4 ) continue;
160 
161  Vector jjloc_in_chitip_frame = chi_tip_frame.to_local_coordinate( res.atom( jjatom ).ideal_xyz() );
162  nonchitip_atoms_[ ii ].push_back( jjatom );
163  points_for_nonchitip_atoms_[ ii ].push_back( jjloc_in_chitip_frame );
164  which_point_for_atom_[ jjatom ] = points_for_nonchitip_atoms_[ ii ].size();
165  }
166  }
167 
168 }
169 
170 bool
172 {
173  return restype_atom_id_2_nonchi_atom_id_[ restype_atomid ] != 0;
174 }
175 
178 {
179  runtime_assert( restype_atom_id_2_nonchi_atom_id_[ restype_atomid ] != 0 );
181 }
182 
183 
184 }
185 }
186 }