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() ||
73  }
75  bool IsPolysaccharide() const
76  {
77  return type_==CHAINTYPE_POLY_SAC_D || type_==CHAINTYPE_POLY_SAC_L;
78  }
80  bool IsPolypeptide() const
81  {
82  return type_==CHAINTYPE_POLY_PEPTIDE_D || type_==CHAINTYPE_POLY_PEPTIDE_L ||
84  }
86  bool IsPolynucleotide() const
87  {
88  return type_==CHAINTYPE_POLY_DN || type_==CHAINTYPE_POLY_RN ||
89  type_==CHAINTYPE_POLY_DN_RN;
90  }
91 
95  void SetDescription(const String desc)
96  {
97  description_ = desc;
98  }
99 
104  {
105  return description_;
106  }
107 
110  // force deep to be set explicitely, because it is better than implicit
111  // (and since we are on the impl level interface consistency isn't that critical)
112  ResidueImplPtr AppendResidue(const ResidueImplPtr& res, bool deep);
113 
114  ResidueImplPtr InsertResidueBefore(int index, const ResNum& n,
115  const ResidueKey& k);
116  ResidueImplPtr InsertResidueAfter(int index, const ResNum& n,
117  const ResidueKey& k);
123 
125  ResidueImplPtr AppendResidue(const ResidueKey& k, const ResNum& n);
126 
127 
128  // next residue, not necessarily in sequence
129  ResidueImplPtr GetPrev(const ResidueImplPtr& r) const;
130 
132  ResidueImplPtr GetNext(const ResidueImplPtr& r) const;
133 
134  const ResidueImplList& GetResidueList() const;
136  bool InSequence() const;
137 
139  return residue_list_;
140  }
141 
142  Real GetMass() const;
143  geom::Vec3 GetCenterOfMass() const;
145 
148 
149 
152  ResidueImplPtr FindResidue(const ResNum& number) const;
153 
154  AtomImplPtr FindAtom(const ResNum& number,
155  const String& atom_name) const;
156 
158  int GetResidueCount() const;
159 
161  int GetAtomCount() const;
162 
164  int GetBondCount() const;
165 
166  void Apply(EntityVisitor& v);
167 
168  EntityImplPtr GetEntity() const;
169 
170  void DeleteResidue(const ResNum& number);
171 
172  void DeleteResidue(const ResidueImplPtr& residue);
173 
174  void DeleteAllResidues();
175 
176  void ReorderResidues();
177 
178  void RenumberAllResidues(int start, bool keep_spacing);
179 
180  void RenumberAllResidues(const ResNumList& new_numbers);
181 
182  int GetIndex(const ResidueImplPtr& res) const;
184  const ResNum& start,
185  const ResNum& end);
186  int GetIndexForResNum(const ResNum& number) const;
189  void SetInSequence(int index);
190 
191  void UpdateTransformedPos();
192 
193 private:
194  int GetIndexForResNumInSequence(const ResNum& number) const;
195  void UpdateShifts();
196  typedef struct {
197  int start;
198  int shift;
199  } Shift;
200  std::list<Shift> shifts_;
201  EntityImplW ent_;
202  String name_;
203  ResidueImplList residue_list_;
206  bool in_sequence_;
207  ChainType type_;
208  String description_;
209 };
210 
211 }}} // ns
212 
213 #endif
214 
String ResidueKey
ImageStateConstModOPAlgorithm< ShiftFnc > Shift
Definition: alg_shift.hh:73
void Apply(EntityVisitor &v)
int GetBondCount() const
Get number of bonds of this chain.
EntityImplPtr GetEntity() const
ResidueImplPtr InsertResidueAfter(int index, const ResNum &n, const ResidueKey &k)
std::string String
Definition: base.hh:54
bool IsPolymer() const
whether the chain is a polymer
Definition: chain_impl.hh:68
float Real
Definition: base.hh:44
void SetInSequence(int index)
checks if the residue with that index breaks the in_sequence property and updates it accordingly ...
axis-aligned cuboid
int GetAtomCount() const
Get number of atoms of this chain.
void SetType(const ChainType type)
Assign a type to a chain.
Definition: chain_impl.hh:54
void DeleteResidue(const ResNum &number)
std::vector< ResidueImplPtr > ResidueImplList
geom::Vec3 GetCenterOfMass() const
ResidueImplPtr AppendResidue(const ResidueImplPtr &res, bool deep)
append new residue with exactly the same parameters as res, but no atoms and bonds ...
void AssignSecondaryStructure(SecStructure ss, const ResNum &start, const ResNum &end)
int GetResidueCount() const
Get number of residues of this chain.
geom::AlignedCuboid GetBounds() const
returns the axis-aligned bounding box of the entity
boost::shared_ptr< ResidueImpl > ResidueImplPtr
int GetIndexForResNum(const ResNum &number) const
void SetName(const String &new_name)
Secondary structure types as defined by DSSP. For convenience, the enum values match the characters u...
pointer_it< T > end(const std::vector< T > &values)
std::vector< ResNum > ResNumList
ResidueImplPtr InsertResidueBefore(int index, const ResNum &n, const ResidueKey &k)
ResidueImplPtr GetNext(const ResidueImplPtr &r) const
previous residue, not necessarily in sequence
int GetIndex(const ResidueImplPtr &res) const
EntityVisitor interface.
(D) amino acid sequence
Definition: chain_type.hh:35
String GetDescription() const
Get information about a chain.
Definition: chain_impl.hh:103
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
bool IsPolypeptide() const
whether the chain is a polypeptide
Definition: chain_impl.hh:80
boost::shared_ptr< EntityImpl > EntityImplPtr
polydeoxyribonucleotide
Definition: chain_type.hh:37
ResidueImplPtr FindResidue(const ResNum &number) const
Get residue by number. Returns a invalid pointer if the chain does not have any residue with this num...
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
void SetDescription(const String desc)
Assign a description to a chain.
Definition: chain_impl.hh:95
ResidueImplPtr GetPrev(const ResidueImplPtr &r) const
const ResidueImplList & GetResidueList() const
polyribonucleotide
Definition: chain_type.hh:38
ResidueImplList & GetResidueList()
Definition: chain_impl.hh:138
ChainImpl(const EntityImplPtr &e, const String &name)
AtomImplPtr FindAtom(const ResNum &number, const String &atom_name) const
bool IsPolysaccharide() const
whether the chain is a polysaccharide
Definition: chain_impl.hh:75
String GetName() const
base class for the implementation
bool IsPolynucleotide() const
whether the chain is a polynucleotide
Definition: chain_impl.hh:86
bool InSequence() const
whether the residue numbers are in ascending order
polydeoxyribonucleotide/ -ribonucleotide hybrid
Definition: chain_type.hh:41
void RenumberAllResidues(int start, bool keep_spacing)
boost::weak_ptr< EntityImpl > EntityImplW
(L) amino acid sequence
Definition: chain_type.hh:36
geom::Vec3 GetCenterOfAtoms() const
ChainType GetType() const
Get the type of a chain.
Definition: chain_impl.hh:62