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 
109 
110  ResidueImplPtr InsertResidueBefore(int index, const ResNum& n,
111  const ResidueKey& k);
112  ResidueImplPtr InsertResidueAfter(int index, const ResNum& n,
113  const ResidueKey& k);
119 
121  ResidueImplPtr AppendResidue(const ResidueKey& k, const ResNum& n);
122 
123  // next residue, not necessarily in sequence
124  ResidueImplPtr GetPrev(const ResidueImplPtr& r) const;
125 
127  ResidueImplPtr GetNext(const ResidueImplPtr& r) const;
128 
129  const ResidueImplList& GetResidueList() const;
131  bool InSequence() const;
132 
134  return residue_list_;
135  }
136 
137  Real GetMass() const;
138  geom::Vec3 GetCenterOfMass() const;
140 
143 
144 
147  ResidueImplPtr FindResidue(const ResNum& number) const;
148 
149  AtomImplPtr FindAtom(const ResNum& number,
150  const String& atom_name) const;
151 
153  int GetResidueCount() const;
154 
156  int GetAtomCount() const;
157 
159  int GetBondCount() const;
160 
161  void Apply(EntityVisitor& v);
162 
163  EntityImplPtr GetEntity() const;
164 
165  void DeleteResidue(const ResNum& number);
166 
167  void DeleteResidue(const ResidueImplPtr& residue);
168 
169  void DeleteAllResidues();
170 
171  void ReorderResidues();
172 
173  void RenumberAllResidues(int start, bool keep_spacing);
174 
175  int GetIndex(const ResidueImplPtr& res) const;
177  const ResNum& start,
178  const ResNum& end);
179  int GetIndexForResNum(const ResNum& number) const;
182  void SetInSequence(int index);
183 
184 private:
185  int GetIndexForResNumInSequence(const ResNum& number) const;
186  void UpdateShifts();
187  typedef struct {
188  int start;
189  int shift;
190  } Shift;
191  std::list<Shift> shifts_;
192  EntityImplW ent_;
193  String name_;
194  ResidueImplList residue_list_;
197  bool in_sequence_;
198  ChainType type_;
199  String description_;
200 };
201 
202 }}} // ns
203 
204 #endif
205