Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesSeqRecoveryCache.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 .hh file for enzdes sequence recovery cache
11 /// @brief
12 /// @author sinibjelic@gmail.com
13 
14 //unit headers
16 
17 //package headers
18 
19 //project headers
20 #include <core/types.hh>
22 
23 //utility headers
24 #include <utility/pointer/ReferenceCount.hh>
25 #include <basic/Tracer.hh>
26 
27 // C++ headers
28 #include <set>
29 #include <string>
30 
32 #include <core/pose/Pose.hh>
33 #include <utility/vector1.hh>
34 
35 
36 namespace protocols {
37 namespace toolbox {
38 namespace match_enzdes_util {
39 
40 static basic::Tracer TR("protocols.enzdes.EnzdesSeqRecoveryCache");
41 
43  sequence_.clear();
44  designable_residues_.clear();
45 }
46 
47 //copy constructor
49  ReferenceCount( other ) {
50  sequence_ = other.sequence_;
52 }
53 
55 
56 void
58  core::pose::Pose & native_pose
59 ) {
60  for(core::Size jj=1; jj <= native_pose.total_residue(); ++jj) {
61  sequence_[jj] = native_pose.residue( jj ).name1();
62  }
63 }
64 
65 std::map< core::Size, char >
67  return sequence_;
68 }
69 
70 void
72  std::set< core::Size > des_res
73 ) {
74  std::set< core::Size >::const_iterator it;
75  for ( it = des_res.begin(); it != des_res.end(); ++it ){
76  //sequnce_ keeps indirectly track of what residues are wt
77  //as insertions and deletions are never added and always deleted
78  if ( sequence_.find(*it) != sequence_.end() ) designable_residues_.insert( *it );
79  }
80 }
81 
82 std::set< core::Size >
84  return designable_residues_;
85 }
86 
89  core::pose::Pose const & designed_pose
90 ) const
91 {
92  core::Size n_residues_recovered(0);
93  core::Size n_residues_total(0);
94 
95  //check if the container is full/empty
96  if ( !designable_residues_.empty() ) {
97  std::set< core::Size >::const_iterator it;
98  for( it = designable_residues_.begin(); it != designable_residues_.end(); ++it ) {
99  if ( sequence_.find(*it)->second == designed_pose.residue(*it).name1() ) {
100  ++n_residues_recovered;
101  }
102  }
103  n_residues_total = designable_residues_.size();
104  return ( static_cast< core::Real > ( n_residues_recovered) / n_residues_total );
105  }
106 
107  //No residues have been set to designable or there is something seriously wrong
108  //No sequence change => 1.0
109  return 1.0;
110 }
111 
112 void
114  core::id::SequenceMapping const & smap
115 ){
116  std::map< core::Size, char > remap_sequence;
117  std::set< core::Size >remap_designable_residues;
118 
119  //smap( old res number ) = new res number
120  for( core::Size it=1; it <= smap.mapping().size(); ++it ) {
121  //remap sequence_
122  if ( smap[it] != 0 && sequence_.find( it ) != sequence_.end() ) {
123  remap_sequence[ smap[it] ] = sequence_.find( it ) -> second;
124  }
125  //remap designable_residues_
126  if ( smap[it] != 0 && designable_residues_.find( it ) != designable_residues_.end() ) {
127  remap_designable_residues.insert( smap[it] );
128  }
129  }//smap for loop
130 
131  //modify wt sequence accordingly
132  sequence_ = remap_sequence;
133 
134  //assign new modified designable_residues_ from remap_designable_residues.
135  //designable_residues_ are cleared automatically by = operator
136  designable_residues_ = remap_designable_residues;
137 }
138 
139 
140 } //match_enzdes_util
141 } //toolbox
142 } //protocols