OpenStructure
sequence_list_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_SEQ_SEQUENCE_LIST_IMPL_HH
20 #define OST_SEQ_SEQUENCE_LIST_IMPL_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 #include <vector>
26 #include <boost/shared_ptr.hpp>
29 
30 namespace ost { namespace seq { namespace impl {
31 
34 public:
38 
40  void AddSequence(const SequenceImplPtr& sequence);
42  int GetCount() const { return list_.size(); }
43 
45  unsigned int index = static_cast<unsigned int>(i);
46  if (index<list_.size()) {
47  return list_[index];
48  }
49  throw std::out_of_range("Index not covered SequenceList");
50  }
51 
52  const SequenceImplPtr& GetSequence(unsigned int i) const {
53  unsigned int index = static_cast<unsigned int>(i);
54  if (index<list_.size()) {
55  return list_[index];
56  }
57  throw std::out_of_range("Index not covered SequenceList");
58  }
59 
60 
61  void RemoveSequence(int index);
62  int GetPos(int seq_index, int residue_index) const;
63 
64  int GetResidueIndex(int seq_index, int pos) const;
65 
66  SequenceImplPtr FindSequence(const String& name) const;
67 
68  String ToString(int width=80) const;
69 
70  SequenceListImplPtr Slice(int first, int n) const;
71  int GetMinLength() const;
72 
73 
74  int GetMaxLength() const;
75 
76  bool SequencesHaveEqualLength() const
77  {
78  return this->GetMaxLength()==this->GetMinLength();
79  }
80 
81  Real GetCoverage(int seq_index) const;
82 
83  SequenceListImplPtr Copy() const;
84 
85  Iterator Begin() { return list_.begin(); }
86  Iterator End() { return list_.end(); }
87  ConstIterator Begin() const { return list_.begin(); }
88  ConstIterator End() const { return list_.end(); }
89 
90 
91 private:
92  std::vector<SequenceImplPtr> list_;
93 };
94 
99  info::InfoGroup& group);
100 
105 
106 }}}
107 
108 #endif