libsequence  1.9.5
Seq.hpp
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu
4 
5 Remove the brackets to email me.
6 
7 This file is part of libsequence.
8 
9 libsequence is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 libsequence is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 long with libsequence. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef SEQ_H
25 #define SEQ_H
26 
39 #include <iosfwd>
40 #include <string>
41 #include <exception>
42 #include <utility>
43 
44 namespace Sequence
45 {
46  class Seq
47  {
48  public:
49  std::string name, seq;
50  Seq(void);
51  template <typename T>
52  Seq(T &&name_, T &&seq_)
53  : name(std::forward<T>(name_)), seq(std::forward<T>(seq_))
54  {
55  }
56  Seq(const char * n, const char * s)
57  : name(n),seq(s)
58  {
59  }
60  Seq(const Seq &seq) = default;
61  Seq(Seq &&seq) = default;
62  virtual ~Seq() {}
64  std::string GetName(void) const;
66  std::string GetSeq(void) const;
68  std::string substr(std::string::size_type beg,
69  std::string::size_type len) const;
71  std::string substr(std::string::size_type beg) const;
77  typedef std::string::iterator iterator;
83  typedef std::string::const_iterator const_iterator;
84  typedef std::string::reference reference;
85  typedef std::string::const_reference const_reference;
86  typedef std::string::size_type size_type;
87  iterator begin();
88  iterator end();
89  const_iterator begin() const;
90  const_iterator end() const;
91  const_iterator cbegin() const;
92  const_iterator cend() const;
93  void Revcom(void);
94  void Subseq(const unsigned &, const unsigned &);
95  void Complement(void);
96  size_type length(void) const;
97  size_type size(void) const;
98  size_type UngappedLength(void) const;
99  bool IsGapped(void) const;
100  reference operator[](const size_type &i);
101  const_reference operator[](const size_type &i) const;
102  bool operator==(const Seq &rhs) const;
103  bool operator!=(const Seq &rhs) const;
104  Seq &operator=(const Seq &rhs) = default;
105  Seq &operator=(Seq &&rhs) = default;
106  operator std::string() const;
107  const char *c_str(void) const;
111  virtual std::istream &read(std::istream &s) = 0;
115  virtual std::ostream &print(std::ostream &s) const = 0;
116  };
117 
124  std::ostream &operator<<(std::ostream &s, const Seq &c);
131  std::istream &operator>>(std::istream &s, Seq &c);
132 }
133 #endif
bool operator!=(const Seq &rhs) const
Definition: Seq.cc:107
Abstract interface to sequence objects.
Definition: Seq.hpp:46
void Complement(void)
Definition: Seq.cc:163
std::string::const_iterator const_iterator
Definition: Seq.hpp:83
void Subseq(const unsigned &, const unsigned &)
Definition: Seq.cc:147
size_type size(void) const
Definition: Seq.cc:67
const char * c_str(void) const
Definition: Seq.cc:243
The namespace in which this library resides.
std::string GetSeq(void) const
iterator begin()
Definition: Seq.cc:189
void Revcom(void)
Definition: Seq.cc:175
virtual std::ostream & print(std::ostream &s) const =0
std::ostream & operator<<(std::ostream &s, const AlignStream< T > &c)
virtual std::istream & read(std::istream &s)=0
iterator end()
Definition: Seq.cc:198
const_iterator cbegin() const
Definition: Seq.cc:225
std::string substr(std::string::size_type beg, std::string::size_type len) const
Definition: Seq.cc:40
size_type length(void) const
Definition: Seq.cc:58
size_type UngappedLength(void) const
Definition: Seq.cc:126
std::istream & operator>>(std::istream &s, AlignStream< T > &c)
bool IsGapped(void) const
Definition: Seq.cc:137
Seq(void)
Definition: Seq.cc:32
const_iterator cend() const
Definition: Seq.cc:234
bool operator==(const Seq &rhs) const
Definition: Seq.cc:96
std::string::iterator iterator
Definition: Seq.hpp:77
reference operator[](const size_type &i)
Definition: Seq.cc:75
std::string GetName(void) const