Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragData.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/fragments/FragData.hh
12 /// @brief A fragment as list of SingleResidue Data
13 /// @author Oliver Lange (olange@u.washington.edu)
14 /// @date Wed Oct 20 12:08:31 2007
15 ///
16 #ifndef INCLUDED_core_fragment_FragData_HH
17 #define INCLUDED_core_fragment_FragData_HH
18 
19 // Unit Headers
21 
22 // Package Headers
25 
26 // Project Headers
27 #include <core/pose/Pose.fwd.hh>
29 #include <core/types.hh>
30 
31 // Utility headers
32 #include <utility/vector1_bool.hh>
33 #include <utility/pointer/ReferenceCount.hh>
34 
35 // C/C++ headers
36 // AUTO-REMOVED #include <iostream>
37 #include <string>
38 
39 #include <utility/vector1.hh>
40 
41 
42 namespace core {
43 namespace fragment {
44 
46 
49 
50 public:
51  FragData () : valid_( false ), score_( 0.0 ) {};
52 
53  //@brief convience constructor to create FragData object that contains n SRFD of same type
54  // argument SRFD will only be used for cloning
56 
57  //@brief
58  virtual ~FragData() {};
59 
60  virtual
61  FragDataOP clone() const;
62 
63  //might be overwritten to shortcut for continous changes
64  virtual Size apply( kinematics::MoveMap const&, pose::Pose&, Size start, Size end ) const; // continous application to length residues
65  virtual Size apply( kinematics::MoveMap const&, pose::Pose&, Frame const& ) const; //application to any set of residues specified by the Fr
66 
67  //without movemap --- just apply the full fragment
68  virtual Size apply( pose::Pose&, Frame const& ) const; //application to any set of residues specified by the Fr
69  virtual Size apply( pose::Pose&, Size start, Size end ) const; // continous application to length residues
70 
71  // @brief apply framents sec-struct info to ss-string
72  virtual Size apply_ss( kinematics::MoveMap const&, std::string& ss, Frame const& ) const;
73 
74  // @brief check weather the dofs changed by this fragment are allowed according to movemap
75  // return the number of allowed residues before a disabled one is met
76  virtual Size is_applicable( kinematics::MoveMap const&, Size start, Size end ) const;
77  virtual Size is_applicable( kinematics::MoveMap const&, Frame const& ) const;
78 
79  // set FragData from the given pose ( inverse of apply )
80  virtual bool steal( pose::Pose const&, Size start, Size end ); // continous application to length residues
81  virtual bool steal( pose::Pose const&, Frame const& ); //application to any set of residues specified by the Frame
82 
83  // check if both frag_data contain the same number and types of SRFD
84  bool is_compatible( FragData const& frag_data ) const;
85 
86  bool is_valid() const {
87  return valid_;
88  }
89 
90  Size size() const {
91  return data_.size();
92  }
93 
94  char secstruct( Size const pos) const {
95  return data_[pos]->secstruct();
96  }
97 
98  char sequence( Size const pos ) const {
99  return data_[ pos ] -> sequence();
100  }
101 
104  for (Size pos=1; pos<=size(); pos++ ) {
105  str.push_back( secstruct( pos) );
106  };
107  return str;
108  };
109 
112  for (Size pos=1; pos<=size(); pos++ ) {
113  str.push_back( sequence( pos) );
114  };
115  return str;
116  };
117 
118  void set_sequence( Size const pos, char const setting ) {
119  data_[ pos ] -> set_sequence( setting );
120  }
121 
123  if ( pos < data_.size() ) {
124  data_.resize( pos );
125  };
126  data_[ pos ] = res;
127  };
128 
130  data_.push_back ( res );
131  };
132 
134  return data_[ pos ];
135  }
136 
137  //returns new FragData object with residues start...stop
139 
140  virtual void show( std::ostream &out ) const;
141  virtual void show( std::ostream &out, Frame const& ) const;
142  virtual void show_classic( std::ostream &out ) const;
143 
144  //@brief notify FragData that it now contains some proper numbers ( would like to have this protected )
145  // but IO needs access to this.
146  void set_valid( bool setting = true ) {
147  valid_ = setting;
148  }
149 
150  /// @brief Returns the PDB identifier if it has been specified, "no_pdb" otherwise.
151  virtual std::string pdbid() const {
152  return "no_pdb";
153  }
154 
155  /// @brief Returns the chain if it has been specified, '_' otherwise.
156  virtual char chain() const {
157  return '_';
158  }
159 
160  virtual
161  Size pdbpos() const {
162  return 0;
163  }
164 
165  /// @brief Set a score value for this fragment
166  void set_score( Real score ) {
167  score_ = score;
168  }
169 
170  /// @brief Returns the score for this fragment
172  return score_;
173  }
174 
175 protected: // make private
176  FragData( Size nr_res ) : data_( nr_res ) {};
177 
178 private:
180 
181  // this will be true if dofs are set ( via steal, or IO )
182  bool valid_;
183 
185 
186 };
187 
188 
189 /// @brief FragData that contains additional information
190 class AnnotatedFragData : public FragData {
191 typedef FragData Parent;
192 
193 public:
194  AnnotatedFragData(const std::string& pdb_id, Size start_pos, char chain='_') {
195  // initialize w/ known chain
196  initialize(pdb_id, chain, start_pos);
197  }
198 
199  AnnotatedFragData(const std::string& pdb_id, Size start_pos, const FragData& frag, char chain='_')
200  : FragData(frag) {
201  initialize(pdb_id, chain, start_pos);
202  }
203 
204  virtual FragDataOP clone() const;
205 
206  virtual std::string pdbid() const {
207  return pdbid_;
208  }
209 
210  virtual Size pdbpos() const {
211  return startpos_;
212  }
213 
214  virtual char chain() const {
215  return chain_;
216  }
217 
218 private:
219  /// @brief common initialization routine
220  void initialize(const std::string& pdb_id, char chain, Size start_pos) {
221  pdbid_ = pdb_id;
222  chain_ = chain;
223  startpos_ = start_pos;
224  }
225 
227 
228  /// @brief 1-letter chain identifier or '' if it was not specified.
229  char chain_;
230 
231  Size startpos_; //or list of indices
232 };
233 
234 
235 inline std::ostream& operator<<( std::ostream& out, FragData const& fr ) {
236  fr.show( out );
237  return out;
238 }
239 
240 } // fragment
241 } // core
242 
243 #endif