OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
chain_impl.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_CHAIN_IMPL_HH
20 #define OST_CHAIN_IMPL_HH
21 
22 #include <boost/enable_shared_from_this.hpp>
23 
24 #include <ost/mol/module_config.hh>
25 #include <ost/geom/geom.hh>
26 
27 #include <ost/mol/residue_prop.hh>
28 #include <ost/mol/chain_type.hh>
34 
35 #include <ost/generic_property.hh>
36 
37 #include <ost/mol/sec_structure.hh>
38 
39 namespace ost { namespace mol {namespace impl {
40 
43  public boost::enable_shared_from_this<ChainImpl>
44 {
45 public:
46  ChainImpl(const EntityImplPtr& e, const String& name);
47 
48  void SetName(const String& new_name);
49  String GetName() const;
50 
54  void SetType(const ChainType type)
55  {
56  type_ = type;
57  }
58 
63  {
64  return type_;
65  }
66 
68  bool IsPolymer() const
69  {
70  return type_==CHAINTYPE_POLY || this->IsPolypeptide() ||
71  this->IsPolynucleotide() || this->IsPolysaccharide();
72  }
74  bool IsPolysaccharide() const
75  {
76  return type_==CHAINTYPE_POLY_SAC_D || type_==CHAINTYPE_POLY_SAC_L;
77  }
79  bool IsPolypeptide() const
80  {
81  return type_==CHAINTYPE_POLY_PEPTIDE_D || type_==CHAINTYPE_POLY_PEPTIDE_L;
82  }
84  bool IsPolynucleotide() const
85  {
86  return type_==CHAINTYPE_POLY_DN || type_==CHAINTYPE_POLY_RN ||
87  type_==CHAINTYPE_POLY_DN_RN;
88  }
89 
93  void SetDescription(const String desc)
94  {
95  description_ = desc;
96  }
97 
102  {
103  return description_;
104  }
105 
108  // force deep to be set explicitely, because it is better than implicit
109  // (and since we are on the impl level interface consistency isn't that critical)
110  ResidueImplPtr AppendResidue(const ResidueImplPtr& res, bool deep);
111 
112  ResidueImplPtr InsertResidueBefore(int index, const ResNum& n,
113  const ResidueKey& k);
114  ResidueImplPtr InsertResidueAfter(int index, const ResNum& n,
115  const ResidueKey& k);
121 
123  ResidueImplPtr AppendResidue(const ResidueKey& k, const ResNum& n);
124 
125 
126  // next residue, not necessarily in sequence
127  ResidueImplPtr GetPrev(const ResidueImplPtr& r) const;
128 
130  ResidueImplPtr GetNext(const ResidueImplPtr& r) const;
131 
132  const ResidueImplList& GetResidueList() const;
134  bool InSequence() const;
135 
137  return residue_list_;
138  }
139 
140  Real GetMass() const;
141  geom::Vec3 GetCenterOfMass() const;
143 
146 
147 
150  ResidueImplPtr FindResidue(const ResNum& number) const;
151 
152  AtomImplPtr FindAtom(const ResNum& number,
153  const String& atom_name) const;
154 
156  int GetResidueCount() const;
157 
159  int GetAtomCount() const;
160 
162  int GetBondCount() const;
163 
164  void Apply(EntityVisitor& v);
165 
166  EntityImplPtr GetEntity() const;
167 
168  void DeleteResidue(const ResNum& number);
169 
170  void DeleteResidue(const ResidueImplPtr& residue);
171 
172  void DeleteAllResidues();
173 
174  void ReorderResidues();
175 
176  void RenumberAllResidues(int start, bool keep_spacing);
177 
178  void RenumberAllResidues(const ResNumList& new_numbers);
179 
180  int GetIndex(const ResidueImplPtr& res) const;
182  const ResNum& start,
183  const ResNum& end);
184  int GetIndexForResNum(const ResNum& number) const;
187  void SetInSequence(int index);
188 
189  void UpdateTransformedPos();
190 
191 private:
192  int GetIndexForResNumInSequence(const ResNum& number) const;
193  void UpdateShifts();
194  typedef struct {
195  int start;
196  int shift;
197  } Shift;
198  std::list<Shift> shifts_;
199  EntityImplW ent_;
200  String name_;
201  ResidueImplList residue_list_;
204  bool in_sequence_;
205  ChainType type_;
206  String description_;
207 };
208 
209 }}} // ns
210 
211 #endif
212