Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtraThreadingMover.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 
10 /// @file protocols/comparative_modeling/ExtraThreadingMover.cc
11 /// @brief method declarations for ExtraThreadingMover.
12 /// @author James Thompson
13 
14 // AUTO-REMOVED #include <protocols/comparative_modeling/util.hh>
16 
17 #include <core/types.hh>
18 
20 // AUTO-REMOVED #include <core/chemical/ChemicalManager.fwd.hh>
21 
22 #include <core/pose/util.hh>
23 #include <core/pose/Pose.hh>
24 #include <core/pose/PDBInfo.hh>
25 
26 // AUTO-REMOVED #include <core/conformation/Residue.functions.hh>
28 
29 #include <core/id/AtomID.hh>
30 #include <core/id/AtomID_Map.hh>
32 // AUTO-REMOVED #include <core/id/NamedAtomID.hh>
33 
40 #include <core/sequence/util.hh>
41 #include <core/scoring/rms_util.hh>
42 
43 #include <basic/Tracer.hh>
44 
45 #include <utility/vector1.hh>
46 #include <utility/string_util.hh>
47 
48 // C++ headers
49 #include <string>
50 
51 // option key includes
52 // AUTO-REMOVED #include <basic/options/option.hh>
53 // AUTO-REMOVED #include <basic/options/keys/cm.OptionKeys.gen.hh>
54 
55 #include <basic/options/keys/OptionKeys.hh>
56 
57 //Auto Headers
58 #include <core/pose/util.tmpl.hh>
59 
60 namespace protocols {
61 namespace comparative_modeling {
62 
63 static basic::Tracer tr("protocols.comparative_modeling.extra_threading");
64 
67  core::pose::Pose const & template_pose,
68  utility::vector1< core::Size > const & residue_selection
69 ) :
70  protocols::moves::Mover( "ExtraThreadingMover" ),
71  query_index_( 1 ),
72  template_index_( 2 ),
73  template_pose_( template_pose ),
74  align_( align ),
75  residue_selection_(residue_selection)
76 {}
77 
78 /// @brief Returns the index of the query sequence in SequenceAlignment
79 /// object.
81  return query_index_;
82 }
83 
84 /// @brief Returns the index of the template sequence in SequenceAlignment
85 /// object.
87  return template_index_;
88 }
89 
90 /// @brief Returns the SequenceAlignment object used in threading.
92  return align_;
93 }
94 
96  core::pose::Pose const & query_pose
97 ) const {
98  // put checks here to make sure that the template pose and the template
99  // pose in the alignment file match up!
100  using namespace core::id;
101  using namespace core::sequence;
102 
103  SequenceOP query_sequence(
104  new Sequence(
105  align_.sequence( 1 )->ungapped_sequence(),
106  align_.sequence( 1 )->id(),
107  align_.sequence( 1 )->start()
108  )
109  );
110 
111  SequenceOP aligned_template(
113  );
114 
115  SequenceOP t_align_seq(
116  new Sequence(
117  aligned_template->ungapped_sequence(),
118  aligned_template->id() + "_align_seq",
119  aligned_template->start()
120  )
121  );
122 
123  SequenceOP t_pdb_seq(
124  new Sequence (
126  aligned_template->id() + "_pdb_seq",
127  1
128  )
129  );
130 
131  // construct an intermediate alignment of the sequence from the alignment
132  // to the sequence in the PDB file.
133  SWAligner sw_align;
134  ScoringSchemeOP ss( new SimpleScoringScheme( 120, 0, -100, 0 ) );
135 
136  tr.Debug << "query sequence : " << query_pose.sequence() << std::endl;
137  tr.Debug << "query sequence : " << (*query_sequence) << std::endl;
138  tr.Debug << "aligned_template : " << (*aligned_template) << std::endl;
139  tr.Debug << "template_sequence (aln): " << (*t_align_seq) << std::endl;
140  tr.Debug << "template_sequence (pdb): " << (*t_pdb_seq) << std::endl;
141 
142  SequenceAlignment intermediate = sw_align.align( t_align_seq, t_pdb_seq, ss );
143 
144  if ( intermediate.identities() != intermediate.length() ) {
145  tr.Warning << "Error: potential mismatch between sequence from alignment ";
146  tr.Warning << " and sequence from PDB!" << std::endl;
147  tr.Warning << "alignment: " << std::endl << intermediate
148  << std::endl;
149  }
150 
151  SequenceMapping query_to_fullseq = align_.sequence_mapping(
153  );
154  tr.Debug << "Query: " << *align_.sequence( query_index_ ) << std::endl;
155  tr.Debug << "Template: " << *align_.sequence( template_index_ ) << std::endl;
156  tr.Debug << "Original Mapping:" << query_index_ << "-->" << template_index_
157  << std::endl;
158  query_to_fullseq.show( tr.Debug );
159 
160  SequenceMapping intermed_map = intermediate.sequence_mapping( 1, 2 );
161 
162  // final mapping is the mapping from query to the template PDB sequence,
163  // rather then the direct template sequence.
165  query_to_fullseq, intermed_map
166  );
167  tr.Debug << "Transitive Map" << std::endl;
168  query_to_pdbseq.show( tr.Debug );
169 
170  return query_to_pdbseq;
171 }
172 
174  core::pose::Pose & query_pose
175 ) {
176  using core::Real;
177  using core::Size;
178  using std::string;
179  using utility::vector1;
180  using core::id::AtomID;
181  using core::id::AtomID_Map;
182  using namespace basic::options;
183  using namespace basic::options::OptionKeys;
184 
185  core::id::SequenceMapping mapping = get_qt_mapping(query_pose);
186  tr.Debug << "mapping from " << query_index_ << " to " << template_index_
187  << std::endl;
188  mapping.show( tr.Debug );
189 
190  std::string const template_id(utility::file_basename(template_pose_.pdb_info()->name()));
191  core::pose::add_score_line_string( query_pose, "extra_template", template_id );
192 
193  // superimpose query onto template
194  AtomID_Map< AtomID > atom_map;
196 
197  for ( Size ii = 1; ii <= query_pose.total_residue(); ++ii ) {
198  Size const templ_ii( mapping[ii] );
199  if ( templ_ii == 0 ) continue;
200  if ( !query_pose.residue(ii).has("CA") || !template_pose_.residue(templ_ii).has("CA") ) continue;
201 
202  AtomID const id1( query_pose.residue(ii).atom_index("CA"), ii );
203  AtomID const id2( template_pose_.residue(templ_ii).atom_index("CA"), templ_ii );
204  atom_map.set( id1, id2 );
205  }
206 
208  superimpose_pose( query_pose, template_pose_, atom_map );
209 
210  // Iterate over residue selection, copy relevant residues.
211  // Make sure that fold-tree is coherent by checking for bonded_partners
213  typedef vector1< Size >::const_iterator iter;
214  std::map< Size, Size > template_to_query_res; // keeps track of residues that we've added to query_pose.
215  Size const query_jump_anchor( query_pose.total_residue() ); // maybe do this with a VRT residue later.
216  //Size current_chain( query_pose.residue(query_jump_anchor).chain() );
217 
218  for ( iter it = residue_selection_.begin(), end = residue_selection_.end(); it != end; ++it ) {
219  Residue const & template_res(template_pose_.residue(*it));
220  Residue new_rsd(template_res);
221 
222  bool append_by_jump(true);
223  // Check for chemical bond to a residue that we've already added to query_pose.
224  // If that bond exists, add this residue by bond.
225  typedef std::map< Size, Size >::const_iterator map_iter;
226  for ( map_iter m_iter = template_to_query_res.begin(), m_end = template_to_query_res.end(); m_iter != m_end; ++m_iter ) {
227  Residue const & partner_res( template_pose_.residue( m_iter->first ) );
228  if ( template_res.is_bonded( partner_res ) ) {
229  // append by bond to analogous residue in query
230  query_pose.conformation().append_residue_by_bond(new_rsd);
231  append_by_jump = false;
232  }
233  }
234 
235  if ( append_by_jump ) {
236  query_pose.conformation().append_residue_by_jump(new_rsd, query_jump_anchor, "", "", true);
237  }
238 
239  // keep track of what extra residues have been added to query_pose.
240  template_to_query_res[*it] = query_pose.total_residue();
241  }
242 
243  tr.flush();
244 } // apply
245 
248  return "ExtraThreadingMover";
249 }
250 
251 } // comparative_modeling
252 } // protocols