Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
trie.functions.hh
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 core/scoring/trie/trie.functions.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 
15 #ifndef INCLUDED_core_scoring_trie_trie_functions_hh
16 #define INCLUDED_core_scoring_trie_trie_functions_hh
17 
18 // Unit Headers
20 
21 // Package Headers
24 // AUTO-REMOVED #include <core/scoring/trie/RotamerTrie.hh>
26 
27 // Project Headers
31 
32 #include <utility/vector1.hh>
33 
34 
35 namespace core {
36 namespace scoring {
37 namespace trie {
38 
39 /// @details
40 /// Class AT must define a constructor that takes a residue const & and an atom index.
41 template < class AT, class CPDAT >
44  conformation::RotamerSetBase const & rotset,
45  AT const & /* dummy variable for type identification */,
46  CPDAT const & /* dummy variable for type identification */,
47  CPDataCorrespondence const & cpdata_map,
48  Distance atomic_interaction_cutoff
49 )
50 {
51 
52  utility::vector1< RotamerDescriptor< AT, CPDAT > > rotamer_descriptors( rotset.num_rotamers() );
53 
54  for ( Size ii = 1; ii <= rotset.num_rotamers(); ++ii ) {
55  conformation::ResidueCOP ii_rotamer( rotset.rotamer( ii ) );
56  rotamer_descriptors[ ii ].natoms( ii_rotamer->natoms() );
57  Size count_added_atoms = 0;
58  for ( Size jj = 1; jj <= ii_rotamer->nheavyatoms(); ++jj ) {
59 
60  AT newatom( *ii_rotamer, jj );
61  newatom.is_hydrogen( false );
62 
63  CPDAT cpdata;
64  initialize_cpdata_for_atom( cpdata, jj, *ii_rotamer, cpdata_map );
65 
66 
67  RotamerDescriptorAtom< AT, CPDAT > rdatom( newatom, cpdata );
68  rotamer_descriptors[ ii ].atom( ++count_added_atoms, rdatom );
69 
70  for ( Size kk = ii_rotamer->attached_H_begin( jj ),
71  kk_end = ii_rotamer->attached_H_end( jj );
72  kk <= kk_end; ++kk ) {
73 
74  AT newhatom( *ii_rotamer, kk );
75  newhatom.is_hydrogen( true );
76 
77  CPDAT cpdata;
78  initialize_cpdata_for_atom( cpdata, kk, *ii_rotamer, cpdata_map );
79 
80  RotamerDescriptorAtom< AT, CPDAT > rdatom( newhatom, cpdata );
81  rotamer_descriptors[ ii ].atom( ++count_added_atoms, rdatom );
82 
83  }
84  }
85  rotamer_descriptors[ ii ].rotamer_id( ii );
86  }
87 
88  sort( rotamer_descriptors.begin(), rotamer_descriptors.end() );
89 
90  RotamerTrieBaseOP newtrie = new RotamerTrie< AT, CPDAT >( rotamer_descriptors, atomic_interaction_cutoff );
91  for ( Size ii = 1; ii <= cpdata_map.n_entries(); ++ii ) {
92  newtrie->set_resid_2_connection_entry( cpdata_map.resid_for_entry( ii ), ii );
93  }
94  return newtrie;
95 }
96 
97 /// @details
98 /// Creates a rotamer trie given a single residue -- a one-residue trie.
99 /// Class AT must define a constructor that takes a residue const & and an atom index.
100 template < class AT, class CPDAT >
103  conformation::Residue const & res,
104  AT const & /* dummy variable for type identification */,
105  CPDAT const & /* dummy variable for type identification */,
106  CPDataCorrespondence const & cpdata_map,
107  Distance atomic_interaction_cutoff
108 )
109 {
110 
111  utility::vector1< RotamerDescriptor< AT, CPDAT > > rotamer_descriptor( 1 );
112 
113  rotamer_descriptor[ 1 ].natoms( res.natoms() );
114  Size count_added_atoms = 0;
115  for ( Size jj = 1; jj <= res.nheavyatoms(); ++jj ) {
116 
117  AT newatom( res, jj );
118  newatom.is_hydrogen( false );
119 
120  CPDAT cpdata;
121  initialize_cpdata_for_atom( cpdata, jj, res, cpdata_map );
122 
123 
124  RotamerDescriptorAtom< AT, CPDAT > rdatom( newatom, cpdata );
125  rotamer_descriptor[ 1 ].atom( ++count_added_atoms, rdatom );
126 
127  for ( Size kk = res.attached_H_begin( jj ), kk_end = res.attached_H_end( jj );
128  kk <= kk_end; ++kk ) {
129 
130  AT newhatom( res, kk );
131  newhatom.is_hydrogen( true );
132 
133  CPDAT cpdata;
134  initialize_cpdata_for_atom( cpdata, kk, res, cpdata_map );
135 
136  RotamerDescriptorAtom< AT, CPDAT > rdatom( newhatom, cpdata );
137  rotamer_descriptor[ 1 ].atom( ++count_added_atoms, rdatom );
138  }
139  }
140  rotamer_descriptor[ 1 ].rotamer_id( 1 );
141 
142  RotamerTrieBaseOP newtrie = new RotamerTrie< AT, CPDAT >( rotamer_descriptor, atomic_interaction_cutoff );
143  for ( Size ii = 1; ii <= cpdata_map.n_entries(); ++ii ) {
144  newtrie->set_resid_2_connection_entry( cpdata_map.resid_for_entry( ii ), ii );
145  }
146  return newtrie;
147 }
148 
149 
150 template < class CPDAT >
151 void
153  CPDAT & cp_data,
154  Size atom_index,
155  conformation::Residue const & res,
156  CPDataCorrespondence const & cpdata_map
157 )
158 {
159  for ( Size ii = 1; ii <= cpdata_map.n_entries(); ++ii ) {
160  if ( res.is_bonded( cpdata_map.resid_for_entry( ii ) ) ) {
161  for ( Size jj = 1; jj <= cpdata_map.n_connpoints_for_entry( ii ); ++jj ) {
162  Size const connection_atom(
163  res.residue_connect_atom_index( cpdata_map.connid_for_entry_connpoint( ii, jj ) ));
164  cp_data.set_dist_to_connect_point(
165  ii, jj, res.path_distance( atom_index, connection_atom ));
166  }
167  } else {
168  for ( Size jj = 1; jj <= cpdata_map.n_connpoints_for_entry( ii ); ++jj ) {
169  cp_data.set_dist_to_connect_point( ii, jj, etable::count_pair::INFINITE_SEPARATION );
170  }
171  }
172  }
173 }
174 
175 } // namespace trie
176 } // namespace scoring
177 } // namespace core
178 
179 #endif