yat  0.17.3pre
VcfHeader.h
1 #ifndef theplu_yat_omic_vcf_header
2 #define theplu_yat_omic_vcf_header
3 
4 // $Id: VcfHeader.h 3855 2020-01-02 01:11:34Z peter $
5 
6 /*
7  Copyright (C) 2018, 2019 Peter Johansson
8 
9  The yat library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 3 of the
12  License, or (at your option) any later version.
13 
14  The yat library 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 GNU
17  General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with yat. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include <iosfwd>
24 #include <string>
25 #include <vector>
26 
27 namespace theplu {
28 namespace yat {
29 namespace omic {
30 
34  class VcfHeader
35  {
36  public:
42  VcfHeader(const std::string& version);
43 
48  VcfHeader(std::istream& is);
49 
53  void add(const std::string& key, const std::string& value);
54 
61  void add(const std::string& key, const std::string& ID, int number,
62  const std::string& type, const std::string& description);
63 
73  void add_info(const std::string& ID, const std::string& number,
74  const std::string& type, const std::string& description);
75 
85  void add_format(const std::string& ID, const std::string& number,
86  const std::string& type, const std::string& description);
87 
92  void add_program_command(int argc, char* argv[]);
93 
98  void add_program_version(const std::string& prog,
99  const std::string& version);
100 
104  const std::string& header(void) const;
105 
109  void header(const std::string& header);
110 
114  const std::string& line(size_t i) const;
115 
119  std::string key(size_t line) const;
120 
124  void nicify(void);
125 
129  std::string value(size_t line) const;
130 
136  std::string value(size_t line, const std::string& key) const;
137 
141  size_t size(void) const;
142 
149  const std::vector<std::string>& samples(void) const;
150 
154  void samples(const std::vector<std::string>& s);
155 
156  private:
157  friend std::ostream& operator<<(std::ostream& os, const VcfHeader& b);
158  std::vector<std::string> lines_;
159  mutable std::vector<std::string> samples_;
160 
161  void add(const std::string& key,
162  const std::string& ID, const std::string& number,
163  const std::string& type, const std::string& description);
164  void key_value(size_t line, std::string& key, std::string& value) const;
165  // remove line with ##KEY=<ID=id*
166  void remove(const std::string& key, const std::string& id);
167 
168  // functor used in nicify
169  struct Compare
170  {
171  bool operator()(const std::string& lhs, const std::string& rhs) const;
172  private:
173  int index(const std::string& s) const;
174  bool match(const std::string& s, const std::string& prefix) const;
175  };
176  };
177 
183  std::ostream& operator<<(std::ostream&, const VcfHeader& header);
184 
185 }}}
186 
187 #endif
bool is(const std::string &s)
check if string is convertible to (numerical) type T
Definition: utility.h:550
void add(const std::string &key, const std::string &value)
const std::string & header(void) const
The Department of Theoretical Physics namespace as we define it.
void add_info(const std::string &ID, const std::string &number, const std::string &type, const std::string &description)
void add_program_command(int argc, char *argv[])
const std::string & line(size_t i) const
Definition: VcfHeader.h:34
VcfHeader(const std::string &version)
Constructor.
void add_format(const std::string &ID, const std::string &number, const std::string &type, const std::string &description)
std::string value(size_t line) const
std::string key(size_t line) const
size_t size(void) const
std::string version(void)
const std::vector< std::string > & samples(void) const
void add_program_version(const std::string &prog, const std::string &version)

Generated on Thu Aug 27 2020 03:33:18 for yat by  doxygen 1.8.11