Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rms_util.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 // :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/rms/rms_util.hh
12 /// @brief RMS stuff from rosetta++
13 /// @author James Thompson
14 /// @author Ian Davis
15 /// @author Christopher Miles (cmiles@uw.edu)
16 
17 #ifndef INCLUDED_core_scoring_rms_util_HH
18 #define INCLUDED_core_scoring_rms_util_HH
19 
20 // C/C++ headers
21 #include <list>
22 #include <map>
23 #include <string>
24 
25 // External headers
26 #include <boost/unordered/unordered_map.hpp>
27 
28 // Utility headers
29 #include <ObjexxFCL/FArray2D.fwd.hh>
30 #include <utility/vector1_bool.hh>
31 #include <utility/pointer/ReferenceCount.hh>
32 #include <utility/pointer/owning_ptr.hh>
33 
34 // Project headers
35 #include <core/types.hh>
37 #include <core/id/AtomID.fwd.hh>
39 #include <core/pose/Pose.fwd.hh>
41 
42 #include <utility/vector1.hh>
43 
44 
45 namespace core {
46 namespace scoring {
47 
48 using namespace ObjexxFCL;
49 
50 typedef std::list< core::Size > ResidueSelection;
52 
54 
56 
57 extern core::Real native_CA_rmsd( const core::pose::Pose &native_pose , const core::pose::Pose &pose );
58 
59 extern core::Real native_CA_gdtmm( const core::pose::Pose &native_pose , const core::pose::Pose &pose );
60 
61 /// @brief Returns a single, Global Distance Test-like value that measures the
62 /// extent to which the functional ends of a model's sidechains agree with their
63 /// counterparts in a given reference structure.
64 ///
65 /// @detail Instead of comparing residue positions on the basis of CAs, gdtsc
66 /// uses a characteristic atom near the end of each sidechain type for the
67 /// evaluation of residue-residue distance deviations.
68 ///
69 /// The traditional GDT score is a weighted sum of the fraction of residues
70 /// superimposed within limits of 1, 2, 4, and 8Å. For gdtsc, the backbone
71 /// superposition is used to calculate fractions of corresponding model-ref
72 /// sidechain atom pairs that fit under 10 distance-limit values from 0.5A
73 /// to 5A. Ambiguity in Asp or Glu terminal oxygen naming is not currently
74 /// considered.
75 ///
76 /// Reference:
77 /// Keedy, DA. The other 90% of the protein. Proteins. 2009; 77 Suppl 9:29-49.
79  const core::pose::Pose& model,
80  const std::map<core::Size, core::Size>& residues);
81 
82 /// @brief Returns the average fraction of residues superimposable under a
83 /// series of distance thresholds-- 0.5, 1.0, 2.0, and 4.0 Angstroms.
85  const core::pose::Pose& model,
86  const std::map<core::Size, core::Size>& residues);
87 
88 /// @brief Computes the RMSD of the jump residues between <model> and <native>,
89 /// storing the results in a map keyed by jump_id.
90 void compute_jump_rmsd(const core::pose::Pose& reference,
91  const core::pose::Pose& model,
92  boost::unordered_map<core::Size, core::Real>* rmsds);
93 
94 /// @brief RMSD between residues, accounting for automorphisms
95 /// (symmetries). Does NOT include H atoms -- they add lots of extra
96 /// symmetries.
99  core::conformation::Residue const & rsd1,
100  core::conformation::Residue const & rsd2,
101  bool superimpose
102 );
103 
104 /// @detail Computes the root mean squared deviation between zero or more
105 /// CA residues in pose1 and pose2, whose correspondence is specified in
106 /// the map parameter.
107 core::Real CA_rmsd(const core::pose::Pose& pose1,
108  const core::pose::Pose& pose2,
109  const std::map<core::Size, core::Size>& residues);
110 
111 /// @detail Computes the gdtmm between zero or more CA residues in pose1
112 /// and pose2, whose correspondence is specified in the map parameter.
114  const core::pose::Pose& pose2,
115  const std::map<core::Size, core::Size>& residues);
116 
117 //////////////////////////////////////////////////////////////////////////////
118 // Predicate functions to use with rmsd_no_super() and rmsd_with_super()
119 
120 bool
122  core::pose::Pose const & pose1,
123  core::pose::Pose const & ,//pose2,
124  core::Size resno,
125  core::Size atomno
126 );
127 
128 bool
130  core::pose::Pose const & pose1,
131  core::pose::Pose const & ,//pose2,
132  core::Size resno,
133  core::Size atomno
134 );
135 
136 bool
138  core::pose::Pose const& pose1,
139  core::pose::Pose const&,
140  core::Size resno,
141  core::Size atomno
142 );
143 
144 bool
146  core::pose::Pose const& pose1,
147  core::pose::Pose const&,
148  core::Size resno,
149  core::Size atomno
150 );
151 
152 bool
154  core::pose::Pose const & pose1,
155  core::pose::Pose const & ,//pose2,
156  core::Size resno,
157  core::Size atomno
158 );
159 
160 bool
162  core::pose::Pose const & pose1,
163  core::pose::Pose const & ,//pose2,
164  core::Size resno,
165  core::Size atomno
166 );
167 
168 bool
170  core::pose::Pose const & pose1,
171  core::pose::Pose const & ,//pose2,
172  core::Size resno,
173  core::Size atomno
174 );
175 
176 bool
178  core::conformation::Residue const & residue1,
179  core::conformation::Residue const &, // residue2
180  core::Size atomno
181 );
182 
183 bool
185  core::pose::Pose const & pose1,
186  core::pose::Pose const & ,//pose2,
187  core::Size resno,
188  core::Size atomno
189 );
190 
191 bool
193  core::pose::Pose const & pose1,
194  core::pose::Pose const & ,//pose2,
195  core::Size resno,
196  core::Size atomno
197 );
198 
199 /////////////////////////////////////////////
200 // Predicate classes for more complex control
201 
203 public:
204  Predicate() {};
205  virtual ~Predicate() {}
206  virtual bool operator()(
207  core::pose::Pose const & pose1,
208  core::pose::Pose const & pose2,
209  core::Size resno,
210  core::Size atomno) const = 0;
211 };
212 
215 
217 public:
220  virtual bool operator()(
221  core::pose::Pose const & pose1,
222  core::pose::Pose const & pose2,
223  core::Size resno,
224  core::Size atomno) const { return is_protein_CA(pose1, pose2, resno, atomno); }
225 };
226 
227 // (Fill in others as needed.)
228 
229 //////////////////////
230 // Combining Predicates
231 
233 public:
234  ResRangePredicate( core::Size start, core::Size end, PredicateCOP predicate ) : start_(start), end_(end), pred_(predicate) {}
235  virtual ~ResRangePredicate() {}
236  virtual bool operator()(
237  core::pose::Pose const & pose1,
238  core::pose::Pose const & pose2,
239  core::Size resno,
240  core::Size atomno) const;
241 private:
245 };
246 
248 public:
249  SelectedResPredicate( std::list< core::Size > const & selected, PredicateCOP predicate ) : selected_(selected), pred_(predicate) {}
251  virtual bool operator()(
252  core::pose::Pose const & pose1,
253  core::pose::Pose const & pose2,
254  core::Size resno,
255  core::Size atomno) const;
256 private:
257  std::list< core::Size > selected_;
259 };
260 
262 public:
263  ExcludedResPredicate( utility::vector1< Size > const & excluded, PredicateCOP predicate ) : excluded_(excluded), pred_(predicate) {}
265  virtual bool operator()(
266  core::pose::Pose const & pose1,
267  core::pose::Pose const & pose2,
268  core::Size resno,
269  core::Size atomno) const;
270 private:
273 };
274 
275 
276 //////////////////////////////////////////////////////////////////////////////
277 
279 CA_rmsd(
280  const core::pose::Pose & pose1,
281  const core::pose::Pose & pose2
282 );
283 
284 // compute rmsd for residues between start and end
286 CA_rmsd(
287  const core::pose::Pose & pose1,
288  const core::pose::Pose & pose2,
289  Size start,
290  Size end
291 );
292 
294 bb_rmsd(
295  const core::pose::Pose & pose1,
296  const core::pose::Pose & pose2
297 );
298 
299 // compute rmsd for only backbone residues (excluding carboxyl oxygen) between start and end
301 bb_rmsd(
302  const core::pose::Pose & pose1,
303  const core::pose::Pose & pose2,
304  Size start,
305  Size end,
306  utility::vector1< Size > const& exclude
307 );
308 
311  const core::pose::Pose & pose1,
312  const core::pose::Pose & pose2
313 );
314 
315 // compute rmsd for only backbone residues (including carboxyl oxygen) between start and end
318  const core::pose::Pose & pose1,
319  const core::pose::Pose & pose2,
320  Size start,
321  Size end,
322  utility::vector1< Size > const& exclude
323 );
324 
325 // compute rmsd for residues between start and end
327 CA_rmsd(
328  const core::pose::Pose & pose1,
329  const core::pose::Pose & pose2,
330  Size start,
331  Size end,
332  utility::vector1< Size > const& exclude
333 );
334 
335 // compute rmsd for residues for residues in list
337 CA_rmsd(
338  const core::pose::Pose & pose1,
339  const core::pose::Pose & pose2,
340  std::list<Size> residue_selection
341 );
342 
345  const core::pose::Pose & pose1,
346  const core::pose::Pose & pose2
347 );
348 
351  const core::pose::Pose & pose1,
352  const core::pose::Pose & pose2,
353  std::list< Size > residue_selection
354 );
355 
358  const core::pose::Pose & pose1,
359  const core::pose::Pose & pose2
360 );
361 
362 /*
363 void
364 fill_rmsd_coordinates(
365  int & natoms,
366  ObjexxFCL::FArray2D< core::Real > & p1a,
367  ObjexxFCL::FArray2D< core::Real > & p2a,
368  const core::pose::Pose & pose1,
369  const core::pose::Pose & pose2,
370  std::string atom_name
371 ); */
372 
373 // other model-quality related functions
374 
375 /// @brief Calculates a C-alpha maxsub-based superposition between pose1 and pose2, returns
376 /// the number of residues superimposed past a certain threshold. See maxsub.hh and maxsub.cc
377 /// for more information.
378 int
379 CA_maxsub(
380  const core::pose::Pose & pose1,
381  const core::pose::Pose & pose2,
382  Real rms = 4.0
383 );
384 
385 int
386 CA_maxsub(
387  const core::pose::Pose & pose1,
388  const core::pose::Pose & pose2,
389  std::list<Size> residue_selection,
390  Real rms = 4.0
391 );
392 
393 
394 int xyz_maxsub(
395  FArray2D< core::Real > p1a,
396  FArray2D< core::Real > p2a,
397  int natoms
398 );
399 
400 /// @brief Calculate gdtmm based on the given sets of xyz coordinates in p1a and p2a.
402 xyz_gdtmm(
403  FArray2D< core::Real > p1a,
404  FArray2D< core::Real > p2a,
405  core::Real& m_1_1,
406  core::Real& m_2_2,
407  core::Real& m_3_3,
408  core::Real& m_4_3,
409  core::Real& m_7_4
410 );
411 
412 /// @brief Calculate gdtmm based on the given sets of xyz coordinates in p1a and p2a.
414 xyz_gdtmm(
415  FArray2D< core::Real > p1a,
416  FArray2D< core::Real > p2a
417 );
418 
419 
420 /// @brief Calculate gdtmm score based on the C-alpha positions in pose1 and pose2.
422 CA_gdtmm(
423  core::pose::Pose const& pose1,
424  core::pose::Pose const& pose2
425 );
426 
427 /// @brief Calculate gdtmm score based on the C-alpha positions in pose1 and pose2. Also returns the
428 /// five components of the gdtmm score.
430 CA_gdtmm(
431  core::pose::Pose const& pose1,
432  core::pose::Pose const& pose2,
433  core::Real& m_1_1,
434  core::Real& m_2_2,
435  core::Real& m_3_3,
436  core::Real& m_4_3,
437  core::Real& m_7_4
438 );
439 
441 CA_gdtmm(
442  core::pose::Pose const& pose1,
443  core::pose::Pose const& pose2,
444  std::list<Size> residue_selection,
445  core::Real& m_1_1,
446  core::Real& m_2_2,
447  core::Real& m_3_3,
448  core::Real& m_4_3,
449  core::Real& m_7_4
450 );
451 
452 /// @brief Calculate gdtmm score based on the C-alpha positions in pose1 and pose2.
454 CA_gdtmm(
455  core::pose::Pose const& pose1,
456  core::pose::Pose const& pose2,
457  std::list<Size> residue_selection
458 );
459 
460 /// @brief Superimpose mod_pose onto ref_pose using the mapping of atoms from
461 /// mod_pose to ref_pose given by atom_map
462 Real
464  pose::Pose & mod_pose,
465  pose::Pose const & ref_pose,
466  id::AtomID_Map< id::AtomID > const & atom_map // from mod_pose to ref_pose
467 );
468 
469 /// @brief Superimpose mod_pose onto ref_pose using the mapping of atoms from
470 /// mod_pose to ref_pose given by atom_map
471 Real
473  pose::Pose & mod_pose,
474  pose::MiniPose const & ref_pose,
475  id::AtomID_Map< id::AtomID > const & atom_map // from mod_pose to ref_pose
476 );
477 
478 /// @brief Superimpose two poses by their calpha coordinates. Ignores residues
479 /// that do not have atoms named "CA."
480 Real
482  pose::Pose & mod_pose,
483  pose::Pose const & ref_pose
484 );
485 
488  const core::pose::Pose & pose1,
489  const core::pose::Pose & pose2
490 );
491 
494  pose::Pose const & mod_pose,
495  pose::Pose const & ref_pose );
496 
497 void
499  std::vector<int> sequence,
500  int const N,
501  std::vector< std::vector<int> > & map
502 );
503 
504 Real
506  pose::Pose const & mod_pose,
507  pose::Pose const & ref_pose,
508  std::map< core::id::AtomID, core::id::AtomID > atom_id_map
509  );
510 
511 Real
513  pose::Pose const & mod_pose,
514  pose::Pose const & ref_pose,
515  std::map< core::id::AtomID, core::id::AtomID > atom_id_map
516 );
517 
518 Real
520  pose::Pose const & mod_pose,
521  pose::Pose const & ref_pose,
522  std::map< core::id::AtomID, core::id::AtomID > atom_id_map,
523  utility::vector1< Size > const & calc_rms_res
524  );
525 
526 Real
528  pose::Pose const & mod_pose,
529  pose::Pose const & ref_pose,
530  std::map< core::id::AtomID, core::id::AtomID > atom_id_map );
531 
532 Real
534  pose::Pose const & mod_pose,
535  pose::Pose const & ref_pose,
536  std::map< core::id::AtomID, core::id::AtomID > atom_id_map,
537  utility::vector1< Size > const & calc_rms_res
538  );
539 
540 void
541 setup_matching_heavy_atoms( core::pose::Pose const & pose1, core::pose::Pose const & pose2, std::map< core::id::AtomID, core::id::AtomID > & atom_id_map );
542 
543 Real
545  pose::Pose const & mod_pose,
546  pose::Pose const & ref_pose );
547 
548 /// @brief utility function to calculate per-residue sidechain rmsd without superposition
553  bool const fxnal_group_only=false );
554 
555 void
556 setup_matching_CA_atoms( core::pose::Pose const & pose1, core::pose::Pose const & pose2, std::map< core::id::AtomID, core::id::AtomID > & atom_id_map );
557 
558 void
560  std::map< core::id::AtomID, core::id::AtomID > & atom_id_map );
561 
562 void
564  utility::vector1< std::string > const & atom_names_to_find,
565  std::map< core::id::AtomID, core::id::AtomID > & atom_id_map );
566 
567 
568 } // end namespace scoring
569 } // end namespace core
570 
571 #endif