Sample SNPs
Fast ordered sampling of rows from large text or binary files. Special cases for DNA variant files (.bed, VCF, HapMap, etc).
|
HMP file input class. More...
#include <varfiles.hpp>
Public Member Functions | |
HmpFileI () | |
Default constructor. | |
HmpFileI (const string &fileName) | |
File name constructor. More... | |
HmpFileI (const HmpFileI &in)=default | |
Copy constructor. | |
HmpFileI & | operator= (const HmpFileI &in)=default |
Copy assignment. | |
HmpFileI (HmpFileI &&in)=default | |
Move constructor. | |
HmpFileI & | operator= (HmpFileI &&in)=default |
Move assignment. | |
~HmpFileI () | |
Destructor. | |
void | open () |
Open stream to read. | |
void | sample (HmpFileO &out, const uint64_t &n) |
Sample SNPs and save to HMP file. More... | |
uint64_t | nsnp () |
Number of SNPs in the object. | |
Protected Member Functions | |
uint64_t | _numLines () |
Get number of SNPs in the HMP file. More... | |
HMP file input class.
Reads HMP files, skipping or copying the header as necessary.
HmpFileI::HmpFileI | ( | const string & | fileName | ) |
File name constructor.
[in] | fileName | file name including extension |
|
protected |
Get number of SNPs in the HMP file.
Assumes Unix-like line endings. Header is not counted.
void HmpFileI::sample | ( | HmpFileO & | out, |
const uint64_t & | n | ||
) |
Sample SNPs and save to HMP file.
Sample \(n\) SNPs without replacement from the file represented by the current object and save to the out
object. Uses Vitter's [3] method. Number of samples has to be smaller that the number of SNPs in the file.
[in] | out | output object |
[in] | n | number of SNPs to sample |