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-2020 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  this->IsOligosaccharide() ||
74  }
76  bool IsPolysaccharide() const
77  {
78  return type_==CHAINTYPE_POLY_SAC_D || type_==CHAINTYPE_POLY_SAC_L;
79  }
80 
82  bool IsOligosaccharide() const
83  {
84  return type_==CHAINTYPE_OLIGOSACCHARIDE;
85  }
87  bool IsPolypeptide() const
88  {
89  return type_==CHAINTYPE_POLY_PEPTIDE_D || type_==CHAINTYPE_POLY_PEPTIDE_L ||
91  }
93  bool IsPolynucleotide() const
94  {
95  return type_==CHAINTYPE_POLY_DN || type_==CHAINTYPE_POLY_RN ||
96  type_==CHAINTYPE_POLY_DN_RN;
97  }
98 
102  void SetDescription(const String desc)
103  {
104  description_ = desc;
105  }
106 
111  {
112  return description_;
113  }
114 
117  // force deep to be set explicitely, because it is better than implicit
118  // (and since we are on the impl level interface consistency isn't that critical)
119  ResidueImplPtr AppendResidue(const ResidueImplPtr& res, bool deep);
120 
121  ResidueImplPtr InsertResidueBefore(int index, const ResNum& n,
122  const ResidueKey& k);
123  ResidueImplPtr InsertResidueAfter(int index, const ResNum& n,
124  const ResidueKey& k);
130 
132  ResidueImplPtr AppendResidue(const ResidueKey& k, const ResNum& n);
133 
134 
135  // next residue, not necessarily in sequence
136  ResidueImplPtr GetPrev(const ResidueImplPtr& r) const;
137 
139  ResidueImplPtr GetNext(const ResidueImplPtr& r) const;
140 
141  const ResidueImplList& GetResidueList() const;
143  bool InSequence() const;
144 
146  return residue_list_;
147  }
148 
149  Real GetMass() const;
150  geom::Vec3 GetCenterOfMass() const;
152 
155 
156 
159  ResidueImplPtr FindResidue(const ResNum& number) const;
160 
161  AtomImplPtr FindAtom(const ResNum& number,
162  const String& atom_name) const;
163 
165  int GetResidueCount() const;
166 
168  int GetAtomCount() const;
169 
171  int GetBondCount() const;
172 
173  void Apply(EntityVisitor& v);
174 
175  EntityImplPtr GetEntity() const;
176 
177  void DeleteResidue(const ResNum& number);
178 
179  void DeleteResidue(const ResidueImplPtr& residue);
180 
181  void DeleteAllResidues();
182 
183  void ReorderResidues();
184 
185  void RenumberAllResidues(int start, bool keep_spacing);
186 
187  void RenumberAllResidues(const ResNumList& new_numbers);
188 
189  int GetIndex(const ResidueImplPtr& res) const;
191  const ResNum& start,
192  const ResNum& end);
193  int GetIndexForResNum(const ResNum& number) const;
196  void SetInSequence(int index);
197 
198  void UpdateTransformedPos();
199 
200 private:
201  int GetIndexForResNumInSequence(const ResNum& number) const;
202  void UpdateShifts();
203  typedef struct {
204  int start;
205  int shift;
206  } Shift;
207  std::list<Shift> shifts_;
208  EntityImplW ent_;
209  String name_;
210  ResidueImplList residue_list_;
213  bool in_sequence_;
214  ChainType type_;
215  String description_;
216 };
217 
218 }}} // ns
219 
220 #endif
221 
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:40
String GetDescription() const
Get information about a chain.
Definition: chain_impl.hh:110
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
bool IsPolypeptide() const
whether the chain is a polypeptide
Definition: chain_impl.hh:87
boost::shared_ptr< EntityImpl > EntityImplPtr
polydeoxyribonucleotide
Definition: chain_type.hh:42
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:43
void SetDescription(const String desc)
Assign a description to a chain.
Definition: chain_impl.hh:102
ResidueImplPtr GetPrev(const ResidueImplPtr &r) const
bool IsOligosaccharide() const
whether the chain is a polysaccharide
Definition: chain_impl.hh:82
const ResidueImplList & GetResidueList() const
polyribonucleotide
Definition: chain_type.hh:43
ResidueImplList & GetResidueList()
Definition: chain_impl.hh:145
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:76
String GetName() const
base class for the implementation
bool IsPolynucleotide() const
whether the chain is a polynucleotide
Definition: chain_impl.hh:93
bool InSequence() const
whether the residue numbers are in ascending order
polydeoxyribonucleotide/ -ribonucleotide hybrid
Definition: chain_type.hh:46
void RenumberAllResidues(int start, bool keep_spacing)
boost::weak_ptr< EntityImpl > EntityImplW
(L) amino acid sequence
Definition: chain_type.hh:41
geom::Vec3 GetCenterOfAtoms() const
ChainType GetType() const
Get the type of a chain.
Definition: chain_impl.hh:62