Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModifyVariantTypeMover.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 src/protocols/simple_moves/ModifyVariantTypeMover.cc
11 /// @brief Modify variant type to residues
12 /// @author Alex Ford <fordas@uw.edu>
13 
14 // Unit Headers
17 
18 // Package headers
19 
20 // Project headers
21 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
27 #include <core/pose/util.hh>
28 #include <core/pose/Pose.hh>
29 #include <utility/tag/Tag.hh>
32 
34 
35 // tracer
36 #include <basic/Tracer.hh>
37 
38 // Utility Headers
39 
40 // C++ Headers
41 #include <iostream>
42 #include <utility/vector1.hh>
43 #include <utility/string_util.hh>
44 
45 #include <boost/algorithm/string.hpp>
46 #include <utility/excn/Exceptions.hh>
47 #include <boost/foreach.hpp>
48 
49 
50 // ObjexxFCL Headers
51 
52 namespace protocols {
53 namespace simple_moves {
54 
55 static basic::Tracer TR( "protocols.simple_moves.ModifyVariantTypeMover" );
56 
57 
58 /// ModifyVariantTypeMover; based on the protocols::moves::Mover basis class
60  protocols::moves::Mover("ModifyVariantType"),
61  task_factory_(NULL),
62  add_target_types_(),
63  remove_target_types_()
64  {}
65 
66 // @brief apply function here
67 void
69 {
70  // Create map of target residues using taskoperation
72 
73  if ( task_factory_ != 0 )
74  {
75  task = task_factory_->create_task_and_apply_taskoperations( pose );
76  TR.Debug << "Initializing from packer task." << std::endl;
77  }
78  else
79  {
80  TR.Debug << "No packer task specified, using default task." << std::endl;
81  }
82 
83  for (core::Size resi = 1; resi <= pose.n_residue(); resi++)
84  {
85  if( task->pack_residue(resi) )
86  {
87  core::chemical::ResidueTypeSet const & rsd_set(pose.residue(resi).residue_type_set());
88  core::chemical::ResidueTypeCOP new_rsd_type(pose.residue(resi).type());
89 
90  BOOST_FOREACH(std::string remove_type, remove_target_types_)
91  {
92  new_rsd_type = rsd_set.get_residue_type_with_variant_removed( *new_rsd_type, remove_type);
93  }
94 
95  BOOST_FOREACH(std::string add_type, add_target_types_)
96  {
97  new_rsd_type = rsd_set.get_residue_type_with_variant_added( *new_rsd_type, add_type);
98  }
99 
101  }
102  }
103 }
104 
107  return "ModifyVariantType";
108 }
109 
112 {
113  return new ModifyVariantTypeMover( *this );
114 }
115 
118 {
119  return new ModifyVariantTypeMover;
120 }
121 
123  utility::tag::TagPtr const tag,
127  core::pose::Pose const & /*pose*/
128 )
129 {
130  add_target_types_.clear();
131  remove_target_types_.clear();
132 
133  std::string add_type_value = tag->getOption< std::string >( "add_type", "");
134  //boost::split(add_target_types_, add_type_value, boost::is_any_of(","));
135  add_target_types_ = utility::string_split<std::string>(add_type_value,',',std::string());
136 
137  std::string remove_type_value = tag->getOption< std::string >( "remove_type", "");
138  //boost::split(remove_target_types_, remove_type_value, boost::is_any_of(","));
139  remove_target_types_ = utility::string_split<std::string>(remove_type_value,',',std::string());
140 
141  if (add_target_types_.size() == 0 && remove_target_types_.size() == 0)
142  {
143  TR.Error << "Must specify add_type and/or remove_type type in ModifyVariantTypeMover." << std::endl;
144  throw utility::excn::EXCN_RosettaScriptsOption("Must specify add_type and/or remove_type type in ModifyVariantTypeMover.");
145  }
146 
148 }
149 
152 
154 ModifyVariantTypeMoverCreator::keyname() const { return "ModifyVariantType"; }
155 
156 } // moves
157 } // protocols
158