source: trunk/yat/omic/GFF.h @ 2482

Last change on this file since 2482 was 2482, checked in by Peter, 12 years ago

new class GFF. closes #647

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#ifndef theplu_yat_omic_gff
2#define theplu_yat_omic_gff
3
4/*
5  $Id: GFF.h 2482 2011-04-24 22:17:19Z peter $
6
7  Copyright (C) 2011 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include <iosfwd>
26#include <map>
27#include <string>
28#include <vector>
29
30namespace theplu {
31namespace yat {
32namespace omic {
33
34  /**
35     Abstract class for GFF2 and GFF3
36
37     \since New in yat 0.8
38   */
39  class GFF
40  {
41  public:
42    /**
43       \brief Default Constructor
44
45       Constructs an empty GFF. Class need to be loaded with function
46       getline before calling any other functions.
47
48       \see getline(std::istream& is, GFF& gff);
49     */
50    GFF(void);
51
52    /**
53       \brief Destructor
54     */
55    virtual ~GFF(void);
56
57    /**
58       \return attribute value for attribute \a key
59
60       If attribute with key \a key has several values, the values are
61       given appended together comma-separated as it appears in file.
62     */
63    const std::string& attribute(const std::string& key) const;
64
65    /**
66       \return map containing all attributes
67
68       \see attribute(const std::string& key) const
69     */
70    const std::map<std::string, std::string>& attributes(void) const;
71
72    /**
73       \return end string
74     */
75    const std::string& end(void) const;
76
77    /**
78       \return phase string
79     */
80    const std::string& phase(void) const;
81
82    /**
83       \return score string
84     */
85    const std::string& score(void) const;
86
87    /**
88       \return seqid string
89     */
90    const std::string& seqid(void) const;
91
92    /**
93       \return source string
94     */
95    const std::string& source(void) const;
96
97    /**
98       \return start string
99     */
100    const std::string& start(void) const;
101
102    /**
103       \return strand string
104     */
105    const std::string& strand(void) const;
106
107    /**
108       \return type string
109     */
110    const std::string& type(void) const;
111  protected:
112    /**
113       \return vector with the 9 elements
114     */
115    const std::vector<std::string>& vec(void) const;
116    friend std::ostream& operator<<(std::ostream&, const GFF&);
117    // user compiler generated copy
118    //GFF(const GFF& other) {};
119    //GFFBase& operator=(const GFF&);
120  private:
121    friend bool getline(std::istream&, GFF&);
122    virtual void add_attribute(std::map<std::string, std::string>& m,
123                               const std::string&) const=0;
124
125    void create_attributes(std::map<std::string, std::string>& m) const;
126    std::vector<std::string> vec_;
127    std::map<std::string, std::string> attributes_;
128  };
129
130  /**
131     \return true iff a GFF object was loaded successfully
132
133     Empty lines and lines starting with '#' are ignored.
134
135     \relates GFF
136     \since New in yat 0.8
137   */
138  bool getline(std::istream& is, GFF& gff);
139
140  /**
141     \brief output operator for GFF
142
143     \relates GFF
144     \since New in yat 0.8
145   */
146  std::ostream& operator<<(std::ostream& os, const GFF& gff);
147
148}}}
149#endif
Note: See TracBrowser for help on using the repository browser.