A template for a class that reads BEAGLE data and is capable of writing it to a stream as a likelihood genotype matrix.
More...
#include <jade.bgl_reader.hpp>
|
| basic_bgl_reader (std::istream &in) |
| Initializes a new instance of the class. More...
|
|
std::string | str () const |
|
void | write (std::ostream &out) const |
| Writes the BEAGLE data to the specified output stream as a likelihood genotype matrix. More...
|
|
void | write (char const *const path) |
| Writes the BEAGLE data to the specified output file. More...
|
|
void | write (const std::string &path) |
| Writes the BEAGLE data to the specified output file. More...
|
|
template<typename TValue>
class jade::basic_bgl_reader< TValue >
A template for a class that reads BEAGLE data and is capable of writing it to a stream as a likelihood genotype matrix.
Definition at line 19 of file jade.bgl_reader.hpp.
◆ value_type
template<typename TValue >
◆ basic_bgl_reader()
template<typename TValue >
Initializes a new instance of the class.
- Parameters
-
Definition at line 28 of file jade.bgl_reader.hpp.
35 std::getline(in, temp);
37 throw error() <<
"failed to read header of beagle data.";
39 std::istringstream header_in (temp);
40 while (header_in >> temp)
42 if (_rows < 3 || _rows % 3 != 0)
43 throw error() <<
"invalid number of columns "
44 <<
"in beagle header: " << _rows;
46 _rows = (_rows - 3) / 3;
58 <<
"cannot read first allele for marker '"
59 << marker <<
"' on line " << _cols + 1
64 <<
"cannot read second allele for marker '"
65 << marker <<
"' on line " << _cols + 1
68 for (
size_t i = 0; i < _rows; i++)
70 for (
size_t j = 0; j < 3; j++)
76 <<
"encountered invalid percentage in column "
77 << 3 + i * 3 + j <<
" for marker '" << marker
78 <<
"' on line " << _cols + 1
80 _buf.push_back(value);
85 throw error() <<
"invalid data on line " << _cols + 1
88 const auto ch = in.peek();
89 if (ch >= 0 && ch !=
'\n')
91 <<
"expected end of line but encountered "
92 << _format(ch) <<
" on line "
93 << _cols + 1 <<
" of beagle data";
◆ str()
template<typename TValue >
- Returns
- A string representation of this instance.
Definition at line 103 of file jade.bgl_reader.hpp.
105 std::ostringstream out;
◆ write() [1/3]
template<typename TValue >
Writes the BEAGLE data to the specified output file.
- Parameters
-
Definition at line 161 of file jade.bgl_reader.hpp.
164 assert(path !=
nullptr);
165 std::ofstream out (path);
167 throw error() <<
"error opening '" << path <<
"' for writing";
◆ write() [2/3]
template<typename TValue >
Writes the BEAGLE data to the specified output file.
- Parameters
-
Definition at line 174 of file jade.bgl_reader.hpp.
◆ write() [3/3]
template<typename TValue >
Writes the BEAGLE data to the specified output stream as a likelihood genotype matrix.
- Parameters
-
Definition at line 114 of file jade.bgl_reader.hpp.
120 out <<
"0 0" << std::endl;
124 const auto r3 = _rows * 3;
125 const auto cr3 = _cols * _rows * 3;
127 auto grp_ptr = _buf.data();
128 const auto grp_end = grp_ptr + 3;
131 out << _rows <<
' ' << _cols << std::endl;
133 auto row_ptr = grp_ptr;
134 const auto row_end = row_ptr + r3;
135 while (row_ptr != row_end)
137 auto col_ptr = row_ptr;
138 const auto col_end = col_ptr + cr3;
143 if (col_ptr == col_end)
152 if (++grp_ptr == grp_end)
The documentation for this class was generated from the following file: