recmap/lib.rs
1//! Functionality for reading and working with recombination maps.
2//!
3//! [`RecMap`] objects can be created from reading in a HapMap-formatted
4//! recombination map. Note that since the HapMap recombination format does
5//! not include the chromosome lengths, this must be specified too.
6//! A convenience function [`read_seqlens`] is provided to read in TSV-formatted
7//! "genome" files of the chromosome names and lengths.
8//!
9//! Here is a example which loads a recombination map from a HapMap-formatted
10//! recombination map and calculates the total map lengths.
11//!
12//! ```no_run
13//! use recmap::prelude::*;
14//! let seqlens = read_seqlens("hg38_seqlens.tsv")
15//! .expect("could not read seqlens");
16//! let rec_map = RecMap::from_hapmap("decode_2019_map.txt", &seqlens)
17//! .expect("cannot read hapmap");
18//!
19//! for (name, rate_map) in rec_map.iter() {
20//! println!("{}\t{}", name, rate_map.total_map_length().unwrap());
21//! }
22//! ```
23//!
24//! This example can be run on the command line with:
25//!
26//! ```bash
27//! cargo run --example calc_map_lengths -- --seqlens hg38_seqlens.tsv decode_2019_map.txt
28//! ```
29//! One of the most common tasks when working with recombination maps is to
30//! estimate the map position of arbitrary markers, which is usually done by linear
31//! interpolation. `RecMap` provides an easy way to do this for one position
32//! (`RecMap.interpolate_map_position()`) and for many positions, with
33//! `RecMap.interpolate_map_positions()`:
34//!
35//!
36//! ```no_run
37//! use recmap::prelude::*;
38//! let seqlens = read_seqlens("hg38_seqlens.tsv")
39//! .expect("could not read seqlens");
40//! let rec_map = RecMap::from_hapmap("decode_2019_map.txt", &seqlens)
41//! .expect("cannot read hapmap");
42//!
43//! let positions = vec![11975064, 15007450];
44//! rec_map.interpolate_map_positions("chr1", &positions);
45//!
46//! ```
47
48pub mod file;
49mod numeric;
50pub mod recmap;
51
52pub use recmap::{read_seqlens, RateFloat, RecMap, RecMapError, CM_MB_CONVERSION};
53
54pub mod prelude {
55 pub use crate::recmap::{read_seqlens, RateFloat, RecMap, RecMapError, CM_MB_CONVERSION};
56}
57
58#[cfg(test)]
59mod tests {}