Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Anchor.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 protocols/AnchoredDesign/Anchor.cc
11 /// @brief Anchor methods implemented
12 /// @author Steven Lewis
13 
14 
15 // Unit Headers
17 
18 // Project Headers
19 // AUTO-REMOVED #include <protocols/loops/Loops.hh>
20 
21 #include <core/pose/Pose.hh>
22 #include <core/pose/PDBPoseMap.hh>
23 #include <core/pose/PDBInfo.hh>
24 
25 // Utility Headers
26 #include <basic/Tracer.hh>
27 #include <core/types.hh>
28 #include <basic/options/option.hh>
29 #include <utility/io/izstream.hh>
30 #include <utility/exit.hh>
31 // AUTO-REMOVED #include <numeric/random/random.hh>
32 
33 // C++ Headers
34 #include <string>
35 #include <iostream>
36 
37 // option key includes
38 #include <basic/options/keys/AnchoredDesign.OptionKeys.gen.hh>
39 
40 #include <utility/vector1.hh>
41 
42 
43 using basic::T;
44 using basic::Error;
45 using basic::Warning;
46 
47 static basic::Tracer TR( "protocols.AnchoredDesign.Anchor" );
48 
49 namespace protocols{
50 namespace anchored_design{
51 
52 std::string const bad_anchorfile("YOU_FORGOT_TO_SPECIFY_AN_ANCHOR_FILE");
53 
54 // default ctor sets all to 0. You'll need to run the setter and run read_anchorfile yourself.
56  start_(0),
57  end_(0),
58  anchorfile_(bad_anchorfile)
59 {}
60 
61 // input constructor for arbitrary anchor, if you know resids
63  start_(start),
64  end_(end),
65  anchorfile_("NO_ANCHORFILE_NEEDED")
66 {}
67 
68 // input constructor from pose and anchorfile
70  start_(0),
71  end_(0),
72  anchorfile_(filename)
73 {
74  read_anchorfile(pose, filename);
75 }
76 
77 // input constructor from pose, assumes anchorfile
79  start_(0),
80  end_(0),
81  anchorfile_(bad_anchorfile)
82 {
83  read_options();
84  read_anchorfile(pose);
85 }
86 
87 ///@details virtual destructors make c++ happy
89 
90 ///@brief copy ctor
91 Anchor::Anchor( Anchor const & rhs ) :
92  utility::pointer::ReferenceCount(rhs)
93 {
94  *this = rhs;
95 }
96 
97 ///@brief assignment operator
98 Anchor & Anchor::operator=( Anchor const & rhs ){
99 
100  //abort self-assignment
101  if (this == &rhs) return *this;
102 
103  start_ = rhs.start();
104  end_ = rhs.end();
105  anchorfile_ = rhs.get_filename();
106  return *this;
107 }
108 
109 ///@details read_anchorfile from internally stored anchorfile (from the option system)
111  core::pose::Pose const & pose)
112 {
113  read_anchorfile(pose, anchorfile_);
114 }
115 
116 ///@details read_anchorfile reads in an anchor file (formatted as whitespace-delineated PDB-relevant start end chain information). It queries the pose('s members) for the mapping from PDB numbers to pose resids.
118  core::pose::Pose const & pose,
119  std::string const & filename )
120 {
121 
122  //find the anchor file, open it, handle error
123  utility::io::izstream anchorfile( filename );
124  if ( !anchorfile ) {
125  Error() << "Can't open anchorfile file: " << filename << std::endl;
126  Error() << "Use -AnchoredDesign::anchor to specify" << std::endl;
127  utility_exit();
128  }
129 
130  core::Size PDBstart;
131  core::Size PDBend;
132  char chain;
133 
134  anchorfile >> chain >> PDBstart >> PDBend;
135 
136  //if the stream fails, bad formatting
137  if( anchorfile.fail() ){
138  Error() << "Can't parse anchor file. Using the PDB numbering, format is:\n chain start end \n "
139  << "Only the first line is read." << std::endl;
140  utility_exit();
141  }
142  //use info to modify Anchor's data members
143  using core::pose::PDBInfo;
145  if( !pose.pdb_info() ){ //if that's not a NULL pointer
146  utility_exit_with_message("Cannot read anchor file because pose has no PDBInfo");
147  }
148 
149  PDBPoseMap const & pose_map = pose.pdb_info()->pdb2pose();
150  start_ = pose_map.find(chain, PDBstart);
151  end_ = pose_map.find(chain, PDBend);
152 
153 }
154 
155 
156 ///@brief setter for filename for anchorfile
158 
159 ///@brief getter for filename for anchorfile
161 
162 ///@brief read option system into internal data
164  anchorfile_ = basic::options::option[ basic::options::OptionKeys::AnchoredDesign::anchor ].value();
165 }
166 
167 }//namespace protocols
168 }//namespace anchored_design