OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sequence_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_SEQUENCE_HH
20 #define OST_SEQUENCE_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 #include <ost/message.hh>
26 #include <list>
27 
28 #include <boost/shared_ptr.hpp>
29 #include <ost/generic_property.hh>
30 #include <ost/config.hh>
31 #if(OST_INFO_ENABLED)
32 #include <ost/info/info_fw.hh>
33 #endif
34 #include <ost/mol/residue_prop.hh>
35 #include <ost/mol/entity_view.hh>
36 #include <ost/mol/residue_view.hh>
37 
38 #include <ost/seq/module_config.hh>
40 namespace ost { namespace seq { namespace impl {
41 
44 
46 typedef boost::shared_ptr<SequenceImpl> SequenceImplPtr;
47 
50 public:
52  static SequenceImplPtr FromString(const String& seq_name,
53  const String& sequence_string,
54  const String& role="UNKNOWN");
55 
59  int GetResidueIndex(int pos) const;
60 
63  int GetPos(int residue_index) const;
64 
66  int GetFirstNonGap() const;
67 
69  int GetLastNonGap() const;
70 
71  const String& GetName() const;
72 
73  void SetName(const String& name);
74 
75  void Cut(int start, int n);
76 
77  void ShiftRegion(int start, int end, int amount);
78  const String& GetString() const {
79  return seq_string_;
80  }
82  void SetString(const String& seq);
83 
85  void Normalise();
86 
88  void Replace(const String& str,int start, int end);
89 
91  String GetGaplessString() const;
92 
96  int GetOffset() const;
97 
98  int GetIndex(const String& substr) const;
104  void SetOffset(int offset);
105 
107  int GetLength() const;
112  SequenceImpl(const String& seq_name, const String& sequence_string,
113  const String& role);
114 
116  char GetOneLetterCode(int position) const;
117 
118  void SetOneLetterCode(int position, char new_char);
124  mol::ResidueView GetResidue(int position) const;
125 
127  mol::EntityView GetAttachedView() const;
128 
132  void AttachView(const mol::EntityView& view);
133 
137  SequenceImplPtr Copy() const;
141  void AttachView(const mol::EntityView& view, const String& chain_name);
142 
144  bool HasAttachedView() const;
145 
146  void Append(char olc);
147 
148  char& operator[](size_t index)
149  {
150  return seq_string_[index];
151  }
152  char operator[](size_t index) const
153  {
154  return seq_string_[index];
155  }
156  const String& GetRole() const
157  {
158  return seq_role_;
159  }
160 
161  void SetRole(const String& role)
162  {
163  seq_role_=role;
164  }
165 private:
166 
172  void ShiftsFromSequence();
173 
174 
175  int GetPosNoBounds(int index) const;
176 
177  static bool IsSequenceStringSane(const String& seq_string);
178 
179  typedef struct {
180  int start;
181  int shift;
182  } Shift;
183  String seq_name_;
184  String seq_string_;
185  String seq_role_;
186  std::list<Shift> shifts_;
187  bool editing_;
188  int offset_;
189  mol::EntityView attached_view_;
190 };
191 
193 typedef std::vector<SequenceImplPtr> SequenceList;
194 
195 #if(OST_INFO_ENABLED)
196 SequenceImplPtr DLLEXPORT_OST_SEQ SequenceImplFromInfo(const info::InfoGroup& group);
198 
200 void DLLEXPORT_OST_SEQ SequenceImplToInfo(const SequenceImplPtr& sequence,
201  info::InfoGroup& group);
202 #endif
203 
204 
205 }}} //ns
206 #endif
207 
#define DLLEXPORT_OST_SEQ
char operator[](size_t index) const
ImageStateConstModOPAlgorithm< ShiftFnc > Shift
Definition: alg_shift.hh:73
std::string String
Definition: base.hh:54
const String & GetString() const
const String & GetRole() const
pointer_it< T > end(const std::vector< T > &values)
std::vector< SequenceImplPtr > SequenceList
char & operator[](size_t index)
boost::shared_ptr< SequenceImpl > SequenceImplPtr
void SetRole(const String &role)
definition of EntityView
Definition: entity_view.hh:86
base class for the implementation