OpenStructure
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)
120 
122  const ResidueKey& k);
124  const ResidueKey& k);
130 
133 
134 
135  // next residue, not necessarily in sequence
137 
140 
143  bool InSequence() const;
144 
146  return residue_list_;
147  }
148 
149  Real GetMass() 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 
174 
176 
177  void DeleteResidue(const ResNum& number);
178 
179  void DeleteResidue(const ResidueImplPtr& residue);
180 
182 
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 
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 
axis-aligned cuboid
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
base class for the implementation
EntityVisitor interface.
bool IsPolypeptide() const
whether the chain is a polypeptide
Definition: chain_impl.hh:87
EntityImplPtr GetEntity() const
bool IsPolymer() const
whether the chain is a polymer
Definition: chain_impl.hh:68
void SetDescription(const String desc)
Assign a description to a chain.
Definition: chain_impl.hh:102
void RenumberAllResidues(const ResNumList &new_numbers)
ResidueImplPtr GetPrev(const ResidueImplPtr &r) const
ResidueImplPtr GetNext(const ResidueImplPtr &r) const
previous residue, not necessarily in sequence
void DeleteResidue(const ResNum &number)
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...
ResidueImplPtr AppendResidue(const ResidueImplPtr &res, bool deep)
append new residue with exactly the same parameters as res, but no atoms and bonds
void RenumberAllResidues(int start, bool keep_spacing)
int GetIndexForResNum(const ResNum &number) const
bool IsPolynucleotide() const
whether the chain is a polynucleotide
Definition: chain_impl.hh:93
const ResidueImplList & GetResidueList() const
ResidueImplPtr AppendResidue(const ResidueKey &k)
Append residue at end of chain.
ResidueImplPtr InsertResidueBefore(int index, const ResNum &n, const ResidueKey &k)
String GetDescription() const
Get information about a chain.
Definition: chain_impl.hh:110
ResidueImplList & GetResidueList()
Definition: chain_impl.hh:145
geom::AlignedCuboid GetBounds() const
returns the axis-aligned bounding box of the entity
void DeleteResidue(const ResidueImplPtr &residue)
AtomImplPtr FindAtom(const ResNum &number, const String &atom_name) const
int GetAtomCount() const
Get number of atoms of this chain.
void SetInSequence(int index)
checks if the residue with that index breaks the in_sequence property and updates it accordingly
ResidueImplPtr InsertResidueAfter(int index, const ResNum &n, const ResidueKey &k)
ChainImpl(const EntityImplPtr &e, const String &name)
bool InSequence() const
whether the residue numbers are in ascending order
geom::Vec3 GetCenterOfMass() const
ChainType GetType() const
Get the type of a chain.
Definition: chain_impl.hh:62
void AssignSecondaryStructure(SecStructure ss, const ResNum &start, const ResNum &end)
void SetType(const ChainType type)
Assign a type to a chain.
Definition: chain_impl.hh:54
bool IsOligosaccharide() const
whether the chain is a polysaccharide
Definition: chain_impl.hh:82
int GetIndex(const ResidueImplPtr &res) const
void Apply(EntityVisitor &v)
int GetBondCount() const
Get number of bonds of this chain.
int GetResidueCount() const
Get number of residues of this chain.
void SetName(const String &new_name)
geom::Vec3 GetCenterOfAtoms() const
ResidueImplPtr AppendResidue(const ResidueKey &k, const ResNum &n)
Append residue at end of chain.
bool IsPolysaccharide() const
whether the chain is a polysaccharide
Definition: chain_impl.hh:76
float Real
Definition: base.hh:44
std::string String
Definition: base.hh:54
ImageStateConstModOPAlgorithm< ShiftFnc > Shift
Definition: alg_shift.hh:73
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
boost::weak_ptr< EntityImpl > EntityImplW
std::vector< ResidueImplPtr > ResidueImplList
boost::shared_ptr< EntityImpl > EntityImplPtr
pointer_it< T > end(const std::vector< T > &values)
boost::shared_ptr< ResidueImpl > ResidueImplPtr
std::vector< ResNum > ResNumList
String ResidueKey
@ CHAINTYPE_POLY_RN
polyribonucleotide
Definition: chain_type.hh:43
@ CHAINTYPE_CYCLIC_PSEUDO_PEPTIDE
cyclic-pseudo-peptide
Definition: chain_type.hh:50
@ CHAINTYPE_POLY_PEPTIDE_DN_RN
peptide nucleic acid
Definition: chain_type.hh:51
@ CHAINTYPE_POLY_SAC_L
polysaccharide(L)
Definition: chain_type.hh:45
@ CHAINTYPE_BRANCHED
carbohydrate
Definition: chain_type.hh:52
@ CHAINTYPE_OLIGOSACCHARIDE
Definition: chain_type.hh:53
@ CHAINTYPE_POLY_SAC_D
polysaccharide(D)
Definition: chain_type.hh:44
@ CHAINTYPE_POLY_PEPTIDE_L
(L) amino acid sequence
Definition: chain_type.hh:41
@ CHAINTYPE_POLY_DN
polydeoxyribonucleotide
Definition: chain_type.hh:42
@ CHAINTYPE_POLY
polymer
Definition: chain_type.hh:37
@ CHAINTYPE_POLY_PEPTIDE_D
(D) amino acid sequence
Definition: chain_type.hh:40
@ CHAINTYPE_POLY_DN_RN
polydeoxyribonucleotide/ -ribonucleotide hybrid
Definition: chain_type.hh:46
Definition: base.dox:1
Secondary structure types as defined by DSSP. For convenience, the enum values match the characters u...