OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sequence_handle.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_SEQ_SEQUENCE_HANDLE_HH
20 #define OST_SEQ_SEQUENCE_HANDLE_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 
26 #include <ost/base.hh>
27 #include <ost/generic_property.hh>
28 #include <ost/config.hh>
29 #if(OST_INFO_ENABLED)
30 #include <ost/info/info_fw.hh>
31 #endif
32 #include <ost/seq/module_config.hh>
33 
34 #include <ost/mol/residue_view.hh>
35 #include <ost/mol/entity_view.hh>
36 
38 
39 namespace ost { namespace seq {
40 
41 class SequenceHandle;
42 class AlignmentHandle;
43 
49  public ConstGenericPropContainer<ConstSequenceHandle> {
50 public:
52  friend class AlignmentHandle;
53  friend class ConstSequenceList;
54  friend class SequenceList;
55 
56  typedef String::const_iterator iterator;
57 
62 
66  int GetResidueIndex(int pos) const;
67 
70  int GetPos(int residue_index) const;
71 
73  int GetFirstNonGap() const;
74 
76  int GetLastNonGap() const;
77 
81  const String& GetName() const;
82 
86  const String& GetString() const;
87 
89  String GetGaplessString() const;
90 
94  int GetOffset() const;
95 
97  int GetLength() const;
98 
100  int GetIndex(const String& substr) const;
101 
103  char GetOneLetterCode(int position) const;
104 
110  mol::ResidueView GetResidue(int position) const;
111 
114  mol::EntityView GetAttachedView() const;
115 
118  SequenceHandle Copy() const;
119 
123  bool HasAttachedView() const;
124 
125  const String& GetRole() const;
126 
127  bool operator==(const ConstSequenceHandle& rhs) const;
128  bool operator!=(const ConstSequenceHandle& rhs) const;
129 
130  char operator[](int index) const;
131 
132  iterator begin() const { return this->GetString().begin(); }
133  iterator end() const { return this->GetString().end(); }
134 
136  bool IsValid() const;
138 protected:
139  GenericPropContainerImpl* GpImpl();
140 
141  const GenericPropContainerImpl* GpImpl() const;
142 public:
144  impl::SequenceImplPtr& Impl() const;
145 private:
146  void CheckValidity() const;
147  mutable impl::SequenceImplPtr impl_;
148 };
149 
163 //
173  public GenericPropContainer<SequenceHandle> {
174 public:
175  typedef String::const_iterator iterator;
177  friend class SequenceList;
178 
179  friend class AlignmentHandle;
180  friend class ConstSequenceList;
181 
185  int GetResidueIndex(int pos) const;
186 
189  int GetPos(int residue_index) const;
190 
192  int GetFirstNonGap() const;
193 
195  int GetLastNonGap() const;
196 
200  const String& GetName() const;
201 
205  const String& GetString() const;
206 
208  String GetGaplessString() const;
209 
213  int GetOffset() const;
214 
216  int GetLength() const;
217 
219  char GetOneLetterCode(int position) const;
220 
222  int GetIndex(const String& substr) const;
223 
229  mol::ResidueView GetResidue(int position) const;
230 
233  mol::EntityView GetAttachedView() const;
234 
237  void Normalise();
238 
241  SequenceHandle Copy() const;
242 
246  bool HasAttachedView() const;
247 
248  bool operator==(const SequenceHandle& rhs) const;
249  bool operator!=(const SequenceHandle& rhs) const;
250 
252  bool IsValid() const;
253 
257  SequenceHandle();
258 
260  void SetName(const String& name);
261 
263  void SetString(const String& seq);
264 
270  void SetOffset(int offset);
271 
275  void AttachView(const mol::EntityView& view);
276 
277  void SetOneLetterCode(int position, char new_char);
278 
279  char operator[](size_t index) const;
280 
281  iterator begin() const { return this->GetString().begin(); }
282  iterator end() const { return this->GetString().end(); }
283 
284  void Append(char olc);
285 
286  operator ConstSequenceHandle() const;
290  void AttachView(const mol::EntityView& view, const String& chain_name);
291 
294 
295  const String& GetRole() const;
296 
297  void SetRole(const String& role) const;
298 
299  impl::SequenceImplPtr& Impl() const;
300 
301  GenericPropContainerImpl* GpImpl();
302 
303  const GenericPropContainerImpl* GpImpl() const;
304 private:
305  void CheckValidity() const;
306  mutable impl::SequenceImplPtr impl_;
307 };
308 
309 SequenceHandle DLLEXPORT_OST_SEQ CreateSequence(const String& name,
310  const String& seq,
311  const String& role="UNKNOWN");
312 #if(OST_INFO_ENABLED)
313 void DLLEXPORT_OST_SEQ SequenceToInfo(const ConstSequenceHandle& sequence,
315  info::InfoGroup& group);
316 
318 SequenceHandle DLLEXPORT_OST_SEQ SequenceFromInfo(info::InfoGroup& group);
319 #endif
320 
321 
322 DLLEXPORT_OST_SEQ std::ostream& operator<<(std::ostream& os,
323  const ConstSequenceHandle& sequence);
324 
325 bool DLLEXPORT_OST_SEQ Match(const ConstSequenceHandle& s1,
326  const ConstSequenceHandle& s2);
327 
328 bool DLLEXPORT_OST_SEQ Match(const String& s1,
329  const String& s2);
330 }}
331 
332 #endif
#define DLLEXPORT_OST_SEQ
mutable sequence handle.
bool DLLEXPORT_OST_SEQ Match(const ConstSequenceHandle &s1, const ConstSequenceHandle &s2)
SequenceHandle DLLEXPORT_OST_SEQ CreateSequence(const String &name, const String &seq, const String &role="UNKNOWN")
DLLEXPORT_OST_SEQ std::ostream & operator<<(std::ostream &os, const AlignedColumn &col)
std::string String
Definition: base.hh:54
bool DLLEXPORT_OST_GEOM operator==(const Line2 &l1, const Line2 &l2)
list of immutable sequences.
DLLEXPORT_OST_IMG_BASE bool operator!=(const ImageHandle &lhs, const ConstImageHandle &rhs)
boost::shared_ptr< SequenceImpl > SequenceImplPtr
list of sequences.
definition of EntityView
Definition: entity_view.hh:86
String::const_iterator iterator
base class for the implementation
representation of a multiple sequence alignemnt consisting of two or more sequences ...
base class for the handler classes
String::const_iterator iterator