yat  0.21pre
VcfHeader.h
1 #ifndef theplu_yat_omic_vcf_header
2 #define theplu_yat_omic_vcf_header
3 
4 // $Id: VcfHeader.h 3999 2020-10-08 23:22:32Z peter $
5 
6 /*
7  Copyright (C) 2018, 2019, 2020 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 
110  void erase(size_t line);
111 
115  const std::string& header(void) const;
116 
120  void header(const std::string& header);
121 
125  const std::string& line(size_t i) const;
126 
130  std::string key(size_t line) const;
131 
144  void nicify(void);
145 
149  std::string value(size_t line) const;
150 
156  std::string value(size_t line, const std::string& key) const;
157 
161  size_t size(void) const;
162 
169  const std::vector<std::string>& samples(void) const;
170 
174  void samples(const std::vector<std::string>& s);
175 
176  private:
177  friend std::ostream& operator<<(std::ostream& os, const VcfHeader& b);
178  std::vector<std::string> lines_;
179  mutable std::vector<std::string> samples_;
180 
181  void add(const std::string& key,
182  const std::string& ID, const std::string& number,
183  const std::string& type, const std::string& description);
184  void key_value(size_t line, std::string& key, std::string& value) const;
185  // remove line with ##KEY=<ID=id*
186  void remove(const std::string& key, const std::string& id);
187 
188  // functor used in nicify
189  struct Compare
190  {
191  bool operator()(const std::string& lhs, const std::string& rhs) const;
192  private:
193  int index(const std::string& s) const;
194  bool match(const std::string& s, const std::string& prefix) const;
195  };
196  };
197 
203  std::ostream& operator<<(std::ostream&, const VcfHeader& header);
204 
205 }}}
206 
207 #endif
bool is(const std::string &s)
check if string is convertible to (numerical) type T
Definition: utility.h:733
void erase(size_t line)
erase line line
void add(const std::string &key, const std::string &value)
std::string key(size_t line) 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[])
Definition: VcfHeader.h:34
size_t size(void) const
VcfHeader(const std::string &version)
Constructor.
const std::string & line(size_t i) const
void add_format(const std::string &ID, const std::string &number, const std::string &type, const std::string &description)
const std::vector< std::string > & samples(void) const
std::string version(void)
const std::string & header(void) const
void add_program_version(const std::string &prog, const std::string &version)
std::string value(size_t line) const

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14