yat  0.16.4pre
VcfHeader.h
1 #ifndef theplu_yat_omic_vcf_header
2 #define theplu_yat_omic_vcf_header
3 
4 // $Id: VcfHeader.h 3760 2018-10-18 04:43:18Z peter $
5 
6 /*
7  Copyright (C) 2018 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 
79  void add_format(const std::string& ID, const std::string& number,
80  const std::string& type, const std::string& description);
81 
86  void add_program_command(int argc, char* argv[]);
87 
92  void add_program_version(const std::string& prog,
93  const std::string& version);
94 
98  const std::string& header(void) const;
99 
103  void header(const std::string& header);
104 
108  const std::string& line(size_t i) const;
109 
113  std::string key(size_t line) const;
114 
118  void nicify(void);
119 
123  std::string value(size_t line) const;
124 
130  std::string value(size_t line, const std::string& key) const;
131 
135  size_t size(void) const;
136 
143  const std::vector<std::string>& samples(void) const;
144 
148  void samples(const std::vector<std::string>& s);
149 
150  private:
151  friend std::ostream& operator<<(std::ostream& os, const VcfHeader& b);
152  std::vector<std::string> lines_;
153  mutable std::vector<std::string> samples_;
154 
155  void add(const std::string& key,
156  const std::string& ID, const std::string& number,
157  const std::string& type, const std::string& description);
158  void key_value(size_t line, std::string& key, std::string& value) const;
159  // remove line with ##KEY=<ID=id*
160  void remove(const std::string& key, const std::string& id);
161 
162  // functor used in nicify
163  struct Compare
164  {
165  bool operator()(const std::string& lhs, const std::string& rhs) const;
166  private:
167  int index(const std::string& s) const;
168  bool match(const std::string& s, const std::string& prefix) const;
169  };
170  };
171 
177  std::ostream& operator<<(std::ostream&, const VcfHeader& header);
178 
179 }}}
180 
181 #endif
bool is(const std::string &s)
check if string is convertible to (numerical) type T
Definition: utility.h:541
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 Dec 12 2019 03:12:08 for yat by  doxygen 1.8.11