OpenStructure
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/info/info_fw.hh>
31 #include <ost/mol/residue_prop.hh>
32 #include <ost/mol/entity_view.hh>
33 #include <ost/mol/residue_view.hh>
34 
35 #include <ost/seq/module_config.hh>
37 namespace ost { namespace seq { namespace impl {
38 
41 
43 typedef boost::shared_ptr<SequenceImpl> SequenceImplPtr;
44 
47 public:
49  static SequenceImplPtr FromString(const String& seq_name,
50  const String& sequence_string);
51 
55  int GetResidueIndex(int pos) const;
56 
59  int GetPos(int residue_index) const;
60 
62  int GetFirstNonGap() const;
63 
65  int GetLastNonGap() const;
66 
67  const String& GetName() const;
68 
69  void SetName(const String& name);
70 
71  void Cut(int start, int n);
72 
73  void ShiftRegion(int start, int end, int amount);
74  const String& GetString() const {
75  return seq_string_;
76  }
78  void SetString(const String& seq);
79 
81  void Replace(const String& str,int start, int end);
82 
84  String GetGaplessString() const;
85 
89  int GetOffset() const;
90 
96  void SetOffset(int offset);
97 
99  int GetLength() const;
104  SequenceImpl(const String& seq_name, const String& sequence_string);
105 
107  char GetOneLetterCode(int position) const;
108 
109  void SetOneLetterCode(int position, char new_char);
115  mol::ResidueView GetResidue(int position) const;
116 
118  mol::EntityView GetAttachedView() const;
119 
123  void AttachView(const mol::EntityView& view);
124 
128  SequenceImplPtr Copy() const;
132  void AttachView(const mol::EntityView& view, const String& chain_name);
133 
135  bool HasAttachedView() const;
136 private:
137 
143  void ShiftsFromSequence();
144 
145 
146  int GetPosNoBounds(int index) const;
147 
148  static bool IsSequenceStringSane(const String& seq_string);
149 
150  typedef struct {
151  int start;
152  int shift;
153  } Shift;
154  String seq_name_;
155  String seq_string_;
156  std::list<Shift> shifts_;
157  bool editing_;
158  int offset_;
159  mol::EntityView attached_view_;
160 };
161 
163 typedef std::vector<SequenceImplPtr> SequenceList;
164 
167  info::InfoGroup& group);
170 
173 
174 }}} //ns
175 #endif
176