A library for working with phylogenetic and population genetic data.
v0.27.0
hts_file.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_FORMATS_HTS_FILE_H_
2 #define GENESIS_POPULATION_FORMATS_HTS_FILE_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2021 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lczech@carnegiescience.edu>
23  Department of Plant Biology, Carnegie Institution For Science
24  260 Panama Street, Stanford, CA 94305, USA
25 */
26 
34 #ifdef GENESIS_HTSLIB
35 
36 #include <string>
37 
38 extern "C" {
39  // #include <htslib/hts.h>
40 
41  struct htsFile;
42 }
43 
44 // =================================================================================================
45 // HTS File
46 // =================================================================================================
47 
48 namespace genesis {
49 namespace population {
50 
56 class HtsFile
57 {
58 public:
59 
60  // -------------------------------------------------------------------------
61  // Constructors and Rule of Five
62  // -------------------------------------------------------------------------
63 
67  HtsFile() = default;
68 
75  explicit HtsFile(
76  std::string const& file_name,
77  std::string const& mode = "r"
78  );
79 
80  ~HtsFile();
81 
82  HtsFile( HtsFile const& ) = delete;
83  HtsFile( HtsFile&& other );
84 
85  HtsFile& operator= ( HtsFile const& ) = delete;
86  HtsFile& operator= ( HtsFile&& other );
87 
88  // -------------------------------------------------------------------------
89  // Accessors
90  // -------------------------------------------------------------------------
91 
92  std::string const& file_name() const
93  {
94  return file_name_;
95  }
96 
97  ::htsFile* data()
98  {
99  return hts_file_;
100  }
101 
107  std::string format_description() const;
108 
114  std::string format_extension() const;
115 
116  // -------------------------------------------------------------------------
117  // Data Members
118  // -------------------------------------------------------------------------
119 
120 private:
121 
122  std::string file_name_ = "";
123  ::htsFile* hts_file_ = nullptr;
124 };
125 
126 } // namespace population
127 } // namespace genesis
128 
129 #endif // htslib guard
130 #endif // include guard
genesis::population::HtsFile::HtsFile
HtsFile()=default
Create an empty instance, with no file attached.
genesis::population::HtsFile::format_extension
std::string format_extension() const
Return the file format extension.
Definition: hts_file.cpp:104
genesis::population::HtsFile::format_description
std::string format_description() const
Return a human-readable description of the file format.
Definition: hts_file.cpp:95
genesis::population::HtsFile::file_name
std::string const & file_name() const
Definition: hts_file.hpp:92
genesis::population::HtsFile::data
::htsFile * data()
Definition: hts_file.hpp:97
genesis::population::HtsFile::operator=
HtsFile & operator=(HtsFile const &)=delete
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::population::HtsFile::~HtsFile
~HtsFile()
Definition: hts_file.cpp:62
genesis::population::HtsFile
Wrap an ::htsFile struct.
Definition: hts_file.hpp:56