Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 //
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/pose/util.hh
11 /// @brief Pose utilities
12 /// @author Phil Bradley
13 /// @author Modified by Sergey Lyskov
14 
15 #ifndef INCLUDED_core_pose_util_hh
16 #define INCLUDED_core_pose_util_hh
17 
18 // C/C++ headers
19 #include <map>
20 #include <set>
21 
22 // Utility headers
23 #include <numeric/xyzVector.hh>
24 #include <utility/vector1.fwd.hh>
25 
26 // Project headers
27 #include <core/types.hh>
31 #include <core/id/AtomID.fwd.hh>
35 #include <core/id/TorsionID.fwd.hh>
43 
44 // Package headers
45 #include <core/pose/util.tmpl.hh>
47 
48 #include <utility/vector1.hh>
49 
50 //Auto Headers
52 #include <core/kinematics/Jump.hh>
53 #include <core/pose/Pose.fwd.hh>
54 
55 #ifdef USELUA
56 #include <lua.hpp>
57 #include <luabind/luabind.hpp>
58 #include <luabind/out_value_policy.hpp>
59 #endif
60 
61 namespace core {
62 namespace pose {
63 
64 typedef std::set<int> Jumps;
65 
66 /// @brief Retrieves jump information from <pose>, storing the result in <jumps>.
67 /// Jumps are keyed by their jump id.
68 void jumps_from_pose(const core::pose::Pose& pose, Jumps* jumps);
69 
70 /// @brief Removes all virtual residues from <pose>
72 
73 /// @brief Updates the rigid-body transform of the specified jump in <pose>
74 void swap_transform(Size jump_num, const kinematics::RT& xform, Pose* pose);
75 
76 /// @brief Returns true if <residue> is positionally conserved, false otherwise
77 bool is_position_conserved_residue(const Pose& pose, core::Size residue);
78 
79 void
81  Pose const & src,
82  utility::vector1< Size > const & positions,
83  kinematics::FoldTree const & f,
84  Pose & pose
85 );
86 
87 void
89  pose::Pose const & src,
90  int const jump_number,
91  pose::Pose & partner1,
92  pose::Pose & partner2
93 );
94 
95 /// @brief Analyzes <pose> residue phi/psi sets and guesses the secondary
96 /// structure, ideally dssp should be used for that
97 void
99  pose::Pose & pose
100 );
101 
102 // /// @brief Analyses the pose in terms of phi/psi and guesses at the secondary
103 // /// structure - ideally dssp should be used for that
104 // void
105 // set_ss_from_phipsi_dssp(
106 // pose::Pose &pose
107 // );
108 
110 
111 /// getters/setters for things in the Pose DataCache
112 bool getPoseExtraScores(
113  core::pose::Pose const & pose,
114  std::string const name,
115  core::Real & value
116 );
117 
118 void setPoseExtraScores(
119  core::pose::Pose & pose,
120  std::string name,
121  core::Real value
122 );
123 
125  core::pose::Pose & pose,
126  std::string const & name
127 );
128 
130  core::pose::Pose & pose
131 );
132 
133 /// @brief Adds a VRT res to the end of the pose at the center of mass.
134 /// Reroots the structure on this res.
136 
137 /// @brief Adds a virtual residue to the end of the pose at the specified location.
138 /// Roots the structure on this residue.
140 
141 /// @brief Adds a key-value pair to the STRING_MAP in the Pose DataCache. If
142 /// there is no STRING_MAP in the DataCache, one is created.
143 void add_comment(
144  core::pose::Pose & pose,
145  std::string const & key,
146  std::string const & val
147 );
148 
149 /// @brief Attempts to access the entry in the STRING_MAP associated with the
150 /// given key. If an entry for the key exists, the value associated with the key
151 /// is put into val, and this function returns true. Otherwise, this function
152 /// returns false and val left unmodified.
153 bool get_comment(
154  core::pose::Pose const & pose,
155  std::string const & key,
156  std::string & val
157 );
158 
159 /// @brief Deletes the entry in the STRING_MAP associated with the
160 /// given key.
161 void delete_comment(
162  core::pose::Pose & pose,
163  std::string const & key
164 );
165 
166 /// @brief Gets a map< string, string > representing comments about the Pose in
167 /// the form of key-value pairs.
168 std::map< std::string, std::string > get_all_comments(
169  core::pose::Pose const & pose
170 );
171 
172 /// @brief Sets a PDB-style REMARK entry in the Pose.
173 /// @detailed This is different from a comment in its interpretation by the
174 /// silent-file output machinery. A REMARK is written on its own separate line
175 /// in the output silent-file, while a comment is written as part of the Pose
176 /// SCORE: lines.
178  core::pose::Pose & pose,
179  std::string const & key,
180  std::string const & val
181 );
182 
184  core::pose::Pose const & pose,
185  std::string const & key,
186  std::string & val
187 );
188 
189 /// @brief Gets a map< string, string > representing score_line_strings about the Pose in
190 /// the form of key-value pairs.
191 std::map< std::string, std::string > get_all_score_line_strings(
192  core::pose::Pose const & pose
193 );
194 
195 /// @brief get Conformation chain -> PDBInfo chain mapping
196 /// @remarks Any chains whose PDBInfo chain records are marked entirely as
197 /// PDBInfo::empty_record() will be mapped to that character. Note that
198 /// Conformation -> PDBInfo is always unique, but the reverse may not be true.
199 /// @return the mapping if PDBInfo available and chains appear consistent,
200 /// otherwise returns an empty mapping
201 std::map< int, char > conf2pdb_chain( core::pose::Pose const & pose );
202 
203 
204 /// @brief renumber PDBInfo based on Conformation chains; each chain starts from 1
205 /// @param[in,out] pose The Pose to modify.
206 /// @param[in] fix_chains If true, the procedure will attempt to fix any empty record
207 /// characters it finds in the PDBInfo. (default true)
208 /// @param[in] start_from_existing_numbering If true, will attempt to start each
209 /// chain from the existing numbering in the PDBInfo. E.g. if the first residue
210 /// of chain 2 in the Conformation is 27, then the renumbering of the chain in
211 /// PDBInfo will start from 27. (default true)
212 /// @param[in] keep_insertion_codes If true, will maintain insertion codes and
213 /// will not increment the pdb residue numbering for those residues. This means
214 /// new numbering with insertion codes will only reflect properly if the
215 /// old numbering included the base numbering of the insertion code residues,
216 /// i.e. 100 100A 100B and not just 100A 100B (with 100 never appearing).
217 /// (default false)
218 /// @param[in] rotate_chain_ids If true, allows support for more than 26 pdb chains
219 /// by rotating [A,Z] continuously. WARNING: This will break the assumption
220 /// made by the PDBPoseMap that each pdb chain id is unique, so make sure you
221 /// are not using the PDBPoseMap feature downstream in your code path without
222 /// corrections! (default false)
223 /// @remarks If fixing chains and there is only one chain and the PDBInfo exists
224 /// but all records are marked as empty, will renumber and set the PDBInfo chain
225 /// to 'A'.
226 /// @return true if renumbering successful, false otherwise
228  core::pose::Pose & pose,
229  bool fix_chains = true,
230  bool const start_from_existing_numbering = true,
231  bool const keep_insertion_codes = false,
232  bool const rotate_chain_ids = false
233 );
234 
235 /// @brief Returns true if the <pose> geometry is ideal
236 /// @param[in] pose The Pose to check.
237 /// @return true if all pose positions have ideal bond lengths and angles
238 /// up to some very small epsilon
239 bool is_ideal_pose(
240  core::pose::Pose const & pose
241 );
242 
243 /// @brief Returns true if the <pose> geometry is ideal in position <seqpos>
244 /// @param[in] pose The Pose to check.
245 /// @return true if position seqpos has ideal bond lengths and angles
246 /// up to some very small epsilon
247 bool is_ideal_position(
248  Size seqpos,
249  core::pose::Pose const & pose
250 );
251 
252 ///@brief this function removes all residues from the pose which are not protein residues. This removal includes, but is not limited to, metals, DNA, RNA, and ligands. It will NOT remove ligands which are canonical residues (for example, if a protein binds an alanine monomer, the monomer will be untouched).
254 
255 ///@brief this function removes all residues with both UPPER and LOWER terminus types. This is intended for removing ligands that are canonical residues.
257 
258 ///@brief this function compares pose atom coordinates for equality; it is not the == operator because it does not compare all pose data.
259 ///@author Steven Lewis smlewi@gmail.com
260 ///@param[in] lhs one pose to compare
261 ///@param[in] rhs one pose to compare
262 ///@param[in] n_dec_places number of decimal places to compare for the coordinates (remember == doesn't work for float); defaults to 3 which is PDB accuracy
264  Pose const & lhs,
265  Pose const & rhs,
266  Size const n_dec_places = 3);
267 
268 ///@breif this function compares poses for equality up to the
269 ///information stored in the binary protein silent struct format.
271  Pose const & lhs,
272  Pose const & rhs);
273 
274 
275 
276 /////////////////////////////////////////////////////////////////////////////////////////////////////
277 ///@brief A very useful function that copies degrees of freedom from one pose to another. res_map defines how to map residue numbers from the large pose to the smaller "scratch" pose.
278 ///@author rhiju, 2009.
279 
280 ////////////////////////////////////////////////////////////////////////////////////////////////
281 void
282 copy_dofs(
283  pose::Pose & pose,
284  MiniPose const & scratch_pose,
285  core::pose::ResMap const & res_map );
286 
287 void
288 copy_dofs_match_atom_names( //Parin Sripakdeevong Dec 27, 2011.
289  pose::Pose & pose,
290  MiniPose const & chunk_pose,
291  core::pose::ResMap const & res_map );
292 
293 ////////////////////////////////////////////////////////////////////////////////////////////////
294 
295 void
296 copy_dofs(
297  pose::Pose & pose,
298  pose::Pose const & scratch_pose,
299  core::pose::ResMap const & res_map );
300 
301 ////////////////////////////////////////////////////////////////////////////////////////////////
302 void
304  pose::Pose & pose,
305  Pose const & scratch_pose,
306  core::pose::ResMap const & res_map,
307  bool const backbone_only = false,
308  bool const ignore_virtual = true );
309 
310 
311 ////////////////////////////////////////////////////////////////////////////////////////////////
312 void
313 copy_dofs(
314  pose::Pose & pose,
315  Pose const & scratch_pose,
316  std::map < id::AtomID , id::AtomID > const & atom_id_map);
317 
318 ////////////////////////////////////////////////////////////////////////////////////////////////
319 void
320 copy_dofs(
321  pose::Pose & pose,
322  MiniPose const & scratch_pose,
323  std::map < id::AtomID , id::AtomID > const & atom_id_map);
324 
325 ////////////////////////////////////////////////////////////////////////////////////////////////
326 void
327 copy_dofs(
328  pose::Pose & pose,
329  MiniPose const & scratch_pose,
330  std::map < id::AtomID , id::AtomID > const & atom_id_map );
331 
332 ////////////////////////////////////////////////////////////////////////////////////////////////
333 void
334 copy_dofs(
335  pose::Pose & pose,
336  MiniPose const & scratch_pose,
337  std::map < id::AtomID , id::AtomID > const & atom_id_map,
338  std::map< id::AtomID, Size > const & atom_id_domain_map );
339 
340 
341 ///////////////////////////////////////////////////////////////////
342 bool
343 get_scratch_atom_id( id::AtomID & other_scratch_atom_id,
344  std::map< core::id::AtomID, core::id::AtomID> const & atom_id_map,
345  core::kinematics::tree::AtomCOP other_atom );
346 
347 ///////////////////////////////////////////////////////////////////
348 void
350  std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
351  core::pose::ResMap const & res_map,
352  core::pose::Pose const & pose );
353 
354 ///////////////////////////////////////////////////////////////////
355 void
356 setup_atom_id_map_match_atom_names( //June 16, 2011 Parin Sripakdeevong
357  std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
358  ResMap const & res_map,
359  core::pose::Pose const & pose,
360  MiniPose const & chunk_pose );
361 
362 ///////////////////////////////////////////////////////////////////
363 void
365  std::map < core::id::AtomID , core::id::AtomID > & atom_id_map,
366  ResMap const & res_map,
367  core::pose::Pose const & pose,
368  core::pose::Pose const & reference_pose,
369  bool const backbone_only = false,
370  bool const ignore_virtual = true);
371 
374  core::id::AtomID const & atom_id,
375  Pose const & pose
376 );
377 
380  core::id::NamedAtomID const & named_atom_id,
381  Pose const & pose,
382  bool raise_exception = true
383 );
384 
387  core::id::StubID const & stub_id,
388  Pose const & pose
389 );
390 
393  core::id::NamedStubID const & named_stub_id,
394  Pose const & pose
395 );
396 
397 ///////////////////////////////////////////////////////////////////
399 void tag_into_pose( core::pose::Pose & pose, std::string const & tag );
400 
402  core::pose::Pose & pose, core::scoring::ScoreType const & sc_type
403 );
404 
406  core::pose::Pose & pose, std::string const & sc_type
407 );
408 
410 
411 void
412 transfer_phi_psi( const core::pose::Pose& srcpose, core::pose::Pose& tgtpose, core::Size ir, core::Size jr );
413 
414 void
415 transfer_phi_psi( const core::pose::Pose& srcpose, core::pose::Pose& tgtpose );
416 
417 void
418 transfer_jumps( const core::pose::Pose& srcpose, core::pose::Pose& tgtpose);
419 
420 void
422  pose::Pose & pose,
423  Size const seqpos,
424  core::chemical::ResidueType const & new_rsd_type
425  );
426 
429  conformation::Residue const & old_rsd,
430  core::chemical::VariantType const & variant_type,
431  pose::Pose const & pose
432  );
433 
434 
437  conformation::Residue const & old_rsd,
438  core::chemical::VariantType const & variant_type,
439  pose::Pose const & pose
440  );
441 
442 void
444  pose::Pose & pose,
445  chemical::VariantType const & variant_type,
446  Size const seqpos
447  );
448 
449 void
451  pose::Pose & pose,
452  chemical::VariantType const & variant_type,
453  Size const seqpos
454  );
455 
456 
457 void
459  pose::Pose & pose,
460  Size const seqpos
461  );
462 
463 
464 void
466  pose::Pose & pose,
467  Size const seqpos
468  );
469 
470 
471 void
473  pose::Pose & pose,
474  Size const seqpos
475  );
476 
477 
478 void
480  pose::Pose & pose,
481  Size const seqpos
482  );
483 
484 
485 /// @brief set up a map to look up TORSION_ID by DOF_ID (Map[DOF_ID] = TORISION_ID)
486 void
488  pose::Pose const & pose,
490  );
491 
492 
493 /// @brief convert from allow-bb,allow-chi MoveMap to simple DOF_ID boolean mask needed by the minimizer
494 void
496  core::kinematics::MoveMap const & mm,
497  pose::Pose const & pose,
498  id::DOF_ID_Mask & dof_mask
499  );
500 
501 bool
502 has_chain(std::string const & chain, core::pose::Pose const & pose);
503 
504 bool
505 has_chain(char const & chain, core::pose::Pose const & pose);
506 
507 std::set<core::Size>
508 get_jump_ids_from_chain_ids(std::set<core::Size> const chain_ids, core::pose::Pose const & pose);
509 
511 get_jump_id_from_chain_id(core::Size const & chain_id, core::pose::Pose const & pose);
512 
513 //std::set<core::Size> get_chain_ids(core::pose::Pose const & pose);
514 
516 get_chain_id_from_chain(std::string const & chain, core::pose::Pose const & pose);
517 
519 get_chain_id_from_chain(char const & chain, core::pose::Pose const & pose);
520 
522 get_chain_ids_from_chain(std::string const & chain, core::pose::Pose const & pose);
523 
525 get_chain_ids_from_chain(char const & chain, core::pose::Pose const & pose);
526 
527 char
528 get_chain_from_chain_id(core::Size const & chain_id, core::pose::Pose const & pose);
529 
531 get_jump_id_from_chain(std::string const & chain, core::pose::Pose const & pose);
532 
534 get_jump_id_from_chain(char const & chain, core::pose::Pose const & pose);
535 
537 get_jump_ids_from_chain(char const & chain, core::pose::Pose const & pose);
538 
540 get_jump_ids_from_chain(std::string const & chain, core::pose::Pose const & pose);
541 
543 get_chain_id_from_jump_id(core::Size const & jump_id, core::pose::Pose const & pose);
544 
545 char
546 get_chain_from_jump_id(core::Size const & jump_id, core::pose::Pose const & pose);
547 
549 get_chain_residues(core::pose::Pose const & pose, core::Size chain_id);
550 
552  core::Size begin,
553  core::Size const end,
554  core::pose::Pose const & pose
555 );
556 
558  core::Size begin,
559  core::Size const end,
560  core::pose::Pose const & pose
561 );
562 
564  core::Size begin,
565  core::Size const end,
566  core::pose::Pose const & pose
567 );
568 
570  core::Size begin,
571  core::Size const end,
572  core::pose::Pose const & pose
573 );
576  core::Size begin,
577  core::Size const end,
578  core::pose::Pose const & pose
579 );
580 
583  core::Size begin,
584  core::Size const end,
585  core::pose::Pose const & pose
586 );
587 
589 molar_mass(
590  core::Size begin,
591  core::Size const end,
592  core::pose::Pose const & pose
593 );
594 
596 get_hash_from_chain(char const & chain, core::pose::Pose const & pose);
597 
599 get_hash_excluding_chain(char const & chain, core::pose::Pose const & pose);
600 
601 std::string get_sha1_hash_excluding_chain(char const & chain, core::pose::Pose const & pose);
602 
603 /// @brief Initialize a DOF_ID_Map for a given Pose using the DOF_ID_Map's current default fill values
604 template< typename T >
605 void
606 initialize_dof_id_map( id::DOF_ID_Map< T > & dof_map, Pose const & pose );
607 
608 /// @brief Initialize a DOF_ID_Map for a given Pose using a specified fill value
609 template< typename T >
610 void
611 initialize_dof_id_map( id::DOF_ID_Map< T > & dof_map, Pose const & pose, T const & value );
612 
613 ///@brief returns a Distance
615 pose_max_nbr_radius( pose::Pose const & pose );
616 
617 /// @brief Initialize an AtomID_Map for a given Pose using the AtomID_Map's current default fill values
618 template< typename T >
619 void
620 initialize_atomid_map( id::AtomID_Map< T > & atom_map, pose::Pose const & pose );
621 
622 /// @brief Initialize an AtomID_Map for a given Pose using a specified fill value
623 template< typename T >
624 void
625 initialize_atomid_map( id::AtomID_Map< T > & atom_map, pose::Pose const & pose, T const & value );
626 
627 /// @brief Initialize an AtomID_Map for a given Conformation using the AtomID_Map's current default fill values
628 template< typename T >
629 void
630 initialize_atomid_map( id::AtomID_Map< T > & atom_map, conformation::Conformation const & conformation );
631 
632 
633 /// @brief Initialize an AtomID_Map for a given Conformation using a specified fill value
634 template< typename T >
635 void
636 initialize_atomid_map( id::AtomID_Map< T > & atom_map, conformation::Conformation const & conformation, T const & value );
637 
638 /// @brief Initialize an AtomID_Map for a given Pose using the AtomID_Map's current default fill values
639 template< typename T >
640 void
642 
643 /// @brief Initialize an AtomID_Map for a given Pose using a specified fill value
644 template< typename T >
645 void
646 initialize_atomid_map_heavy_only( id::AtomID_Map< T > & atom_map, pose::Pose const & pose, T const & value );
647 
648 /// @brief Initialize an AtomID_Map for a given Conformation using the AtomID_Map's current default fill values
649 template< typename T >
650 void
652 
653 /// @brief Initialize an AtomID_Map for a given Conformation using a specified fill value
654 template< typename T >
655 void
656 initialize_atomid_map_heavy_only( id::AtomID_Map< T > & atom_map, conformation::Conformation const & conformation, T const & value );
657 
658 
659 /// @brief detect and fix disulfide bonds
660 void
662  Pose & pose);
663 
664 ///@brief Returns a string giving the pose's tag if there is such a thing or "UnknownTag" otherwise.
666 
667 /// @brief Create a sequence map of first pose onto the second, matching the PDBInfo
668 /// If the PDBInfo of either Pose is missing or invalid, do a simple sequence alignment matching.
669 core::id::SequenceMapping sequence_map_from_pdbinfo( Pose const & first, Pose const & second );
670 #ifdef USELUA
671 void lregister_util( lua_State * lstate );
672 #endif
673 
674 
675 /// @brief count the number of canonical residues in the pose
677 
678 /// @brief count the number of non-canonical residues in the pose
680 
681 /// @brief count the number of canonical amino acid atoms in the pose
683 
684 /// @brief count the number of non-canonical amino acids in thepose
686 
687 /// @brief count the number of non-canonical chi angles in the pose
689 
690 } // pose
691 } // core
692 
693 #endif // INCLUDED_core_pose_util_HH