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-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_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 Replace(const String& str,int start, int end);
86 
88  String GetGaplessString() const;
89 
93  int GetOffset() const;
94 
95  int GetIndex(const String& substr) const;
101  void SetOffset(int offset);
102 
104  int GetLength() const;
109  SequenceImpl(const String& seq_name, const String& sequence_string,
110  const String& role);
111 
113  char GetOneLetterCode(int position) const;
114 
115  void SetOneLetterCode(int position, char new_char);
121  mol::ResidueView GetResidue(int position) const;
122 
124  mol::EntityView GetAttachedView() const;
125 
129  void AttachView(const mol::EntityView& view);
130 
134  SequenceImplPtr Copy() const;
138  void AttachView(const mol::EntityView& view, const String& chain_name);
139 
141  bool HasAttachedView() const;
142 
143  void Append(char olc);
144 
145  char& operator[](size_t index)
146  {
147  return seq_string_[index];
148  }
149  char operator[](size_t index) const
150  {
151  return seq_string_[index];
152  }
153  const String& GetRole() const
154  {
155  return seq_role_;
156  }
157 
158  void SetRole(const String& role)
159  {
160  seq_role_=role;
161  }
162 private:
163 
169  void ShiftsFromSequence();
170 
171 
172  int GetPosNoBounds(int index) const;
173 
174  static bool IsSequenceStringSane(const String& seq_string);
175 
176  typedef struct {
177  int start;
178  int shift;
179  } Shift;
180  String seq_name_;
181  String seq_string_;
182  String seq_role_;
183  std::list<Shift> shifts_;
184  bool editing_;
185  int offset_;
186  mol::EntityView attached_view_;
187 };
188 
190 typedef std::vector<SequenceImplPtr> SequenceList;
191 
192 #if(OST_INFO_ENABLED)
193 
194 SequenceImplPtr DLLEXPORT_OST_SEQ SequenceImplFromInfo(const info::InfoGroup& group);
195 
197 void DLLEXPORT_OST_SEQ SequenceImplToInfo(const SequenceImplPtr& sequence,
198  info::InfoGroup& group);
199 #endif
200 
201 
202 }}} //ns
203 #endif
204