Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pack_missing_sidechains.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 core/pack/pack_missing_sidechains.cc
11 /// @brief function to fix missing sidechains in input PDBs (especially those surface lysines that get sidechain-backbone clashes!)
12 /// @author Steven Lewis smlewi@gmail.com
13 
14 // Unit headers
16 
17 // Package headers
21 
22 // Project headers
25 
26 // AUTO-REMOVED #include <core/id/AtomID_Mask.hh>
27 
28 #include <core/pose/Pose.hh>
29 
32 
33 #include <basic/Tracer.hh>
34 
35 #include <core/id/AtomID_Map.hh>
36 #include <utility/vector0.hh>
37 #include <utility/vector1.hh>
38 
39 
40 // ObjexxFCL headers
41 
42 
43 static basic::Tracer TR("core.pack.pack_missing_sidechains");
44 
45 namespace core {
46 namespace pack {
47 
48 ///@details this function will run rotamer trials on sidechains with missing density. It first sets up a PackerTask with repacking freedom for residues with sidechain missing atoms in the missing AtomID_Mask, then runs rotamer_trials. This function is smart enough to ignore missing virtual atoms
49 void
51  core::pose::Pose & pose,
52  core::id::AtomID_Mask const & missing
53 )
54 {
55  //build a PackerTask to control rotamer_trials
57  task->initialize_from_command_line();
58  task->restrict_to_repacking();
59 
60  utility::vector1_bool repackable;
61  bool something_to_pack = figure_out_repackable_residues( pose, missing, repackable );
62  if (!something_to_pack) return;
63 
64  //task is set up
65  task->restrict_to_residues(repackable);
66 
68  (*sfxn)(pose); // structure must be scored before rotamer_trials can be called (?)
69  //chu change from rotamer_trials to pack_rotamers
70  core::pack::pack_rotamers( pose, *sfxn, task );
71 }//pack_missing_sidechains
72 
73 
75  core::id::AtomID_Mask const & to_repack,
76  utility::vector1_bool& repackable
77 ) {
78  repackable.resize( pose.total_residue() );
79  bool any_to_repack(false);
80 
81  //set up the PackerTask
82  //iterate over all sidechain atoms, and compare to the state of the input missing map.
83  for ( core::Size resid(1); resid <= pose.total_residue(); ++resid ) {
84 
85  //iterate over all heavy sidechain atoms
86  core::chemical::ResidueType const & restype(pose.residue_type(resid));
87 
88  for( core::Size atomno=restype.first_sidechain_atom(); atomno <= restype.nheavyatoms(); ++atomno) {
89  core::id::AtomID atomid(atomno, resid);
90  //if the atom is to_repack and not a virtual atom...
91  if ( to_repack.get(atomid) &&
92  ! restype.is_virtual(atomno) &&
93  restype.atom_type(atomno).name() != "ORBS" &&
94  restype.atom_type(atomno).name() != "LPbb"
95  ) {
96  TR << "packing residue number " << resid << " because of missing atom number " << atomno << " atom name "
97  << restype.atom_name(atomno) << std::endl;
98  repackable[resid] = true;
99  any_to_repack = true;
100  break; //we can stop now
101  }
102  }//for all sidechain heavyatoms
103  }//all residues
104  return any_to_repack; //return early - prevents weird "0 residues at 0 positions" packer calls
105 }
106 
107 } //namespace pack
108 } //namespace core
109