-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
80 lines (78 loc) · 2.32 KB
/
lib.rs
File metadata and controls
80 lines (78 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! # dabuild
//!
//! `dabuild` simplifies the access to genome build metadata, including its accession, version,
//! and contigs.
//!
//! We list the most common use cases below.
//!
//! ## Load genome build
//!
//! The [`builds`] module provides several bundled genome builds.
//! Alternatively, you can load a genome build from a Genome Reference Consortium's (GRC) assembly report.
//!
//! See the [`builds`] documentation for more info.
//!
//! ## Use genome build
//!
//! [`GenomeBuild`] is basically a data container and the usage involves accessing the data.
//!
//! We show several examples with the *GRCh38.p13* genome build.
//!
//! ```rust
//! use dabuild::{GenomeBuild, GenomeBuildIdentifier};
//! use dabuild::builds::get_grch38_p13;
//!
//! let build: GenomeBuild = get_grch38_p13();
//! ```
//!
//! ## Check build identifiers
//!
//! We can check the major assembly and the patch of the build:
//!
//! ```rust
//! # use dabuild::{GenomeBuild, GenomeBuildIdentifier};
//! # use dabuild::builds::get_grch38_p13;
//! # let build: GenomeBuild = get_grch38_p13();
//! assert_eq!(build.id().major_assembly(), "GRCh38");
//! assert_eq!(build.id().patch(), Some("p13"));
//! ```
//!
//! ## Access contigs
//!
//! The genome build contains one or more [`Contig`]s.
//!
//! We can iterate over all contigs, e.g. to count them:
//!
//! ```rust
//! # use dabuild::{GenomeBuild, GenomeBuildIdentifier};
//! # use dabuild::builds::get_grch38_p13;
//! # let build: GenomeBuild = get_grch38_p13();
//! let count = build.contigs().count();
//! assert_eq!(count, 640);
//! ```
//!
//! and we can also access a specific [`Contig`] (e.g. for `chrY`) by one of its names:
//!
//! ```rust
//! # use dabuild::{GenomeBuild, GenomeBuildIdentifier};
//! # use dabuild::builds::get_grch38_p13;
//! # let build: GenomeBuild = get_grch38_p13();
//! // Query by name ...
//! let y = build.contig_by_name("Y");
//! assert!(y.is_some());
//!
//! // ... or by the GenBank accession ...
//! let y = build.contig_by_name("CM000686.2");
//! assert!(y.is_some());
//!
//! // ... or by the RefSeq accession ...
//! let y = build.contig_by_name("NC_000024.10");
//! assert!(y.is_some());
//!
//! // ... or by the UCSC identifier.
//! let y = build.contig_by_name("chrY");
//! assert!(y.is_some());
//! ```
pub mod builds;
mod genome;
pub use genome::{Contig, GenomeBuild, GenomeBuildIdentifier};