Minimac4
|
A reader and interpolator for genetic map files. More...
#include <recombination.hpp>
Classes | |
struct | record |
A single line entry from the genetic map file. More... | |
Public Member Functions | |
genetic_map_file (const std::string &map_file_path, const std::string &chrom) | |
Constructs a genetic_map_file object for reading recombination map data. | |
bool | good () const |
Check whether the genetic map file was loaded successfully. | |
operator bool () const | |
Implicit conversion to bool for validity checking. | |
double | interpolate_centimorgan (std::size_t variant_pos) |
Interpolate the genetic map position (in centimorgans) for a variant. | |
A reader and interpolator for genetic map files.
The genetic_map_file
class provides an interface to read recombination rate data from a genetic map file and interpolate genetic distances (in centimorgans) for arbitrary variant positions.
The file may be in one of two formats:
chrom pos cM
chrom <discard> cM pos
Only entries corresponding to the specified target chromosome are processed.
genetic_map_file::genetic_map_file | ( | const std::string & | map_file_path, |
const std::string & | chrom ) |
Constructs a genetic_map_file object for reading recombination map data.
This constructor opens a genetic map file and prepares it for iterating over recombination map records associated with a specific chromosome.
The constructor:
#
).prev_rec_
and cur_rec_
) for iteration.map_file_path | Path to the genetic map file. |
chrom | Chromosome identifier to extract records for. |
good_ = false
).good()
before use.Example:
|
inline |
Check whether the genetic map file was loaded successfully.
This function returns the internal state flag that indicates whether the constructor succeeded in opening and preparing the file.
double genetic_map_file::interpolate_centimorgan | ( | std::size_t | variant_pos | ) |
Interpolate the genetic map position (in centimorgans) for a variant.
Given a genomic coordinate (basepair position), this method estimates the corresponding centimorgan (cM) value using linear interpolation between records in the genetic map file. The interpolation relies on two adjacent map records (prev_rec_
and cur_rec_
).
variant_pos | The genomic coordinate (basepair position) of the variant. |
good_ == false
), returns NaN.basepair_cm
). Interpret with caution.
|
inline |
Implicit conversion to bool for validity checking.
Provides a shorthand way to test whether the object is in a usable state. Equivalent to calling good().
Example: