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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Contains functions for getting pre-defined contexts
use crate::;
/// Get the latest [OBO Foundry context](https://purl.obolibrary.org/meta/obo_context.jsonld).
///
/// The OBO Foundry context is a simple prefix map stored in a JSON-LD file.
/// It contains OBO Foundry preferred prefixes and OBO PURL expansions,
/// but no synonyms.
///
/// # Examples
///
/// ```rust
/// use curies::sources::{get_obo_converter};
/// use tokio::runtime;
///
/// let rt = runtime::Runtime::new().expect("Failed to create Tokio runtime");
/// let converter = rt.block_on(async {
/// get_obo_converter().await
/// }).expect("Failed to create the converter");
///
/// let uri = converter.expand("DOID:1234").unwrap();
/// assert_eq!(uri, "http://purl.obolibrary.org/obo/DOID_1234");
///
/// let unregistered_uri = converter.expand("missing.prefix:0000001");
/// assert!(unregistered_uri.is_err());
///
/// let curie = converter.compress("http://purl.obolibrary.org/obo/DOID_1234").unwrap();
/// assert_eq!(curie, "DOID:1234");
///
/// let unregistered_curie = converter.compress("http://example.org/missing.prefix:0000001");
/// assert!(unregistered_curie.is_err());
/// ```
pub async
/// Get the Prefix Commons-maintained [Monarch Initiative
/// context](https://github.com/prefixcommons/prefixcommons-py/blob/master/prefixcommons/registry/monarch_context.jsonld)
///
/// The Monarch Initiative context is a simple prefix map stored in a JSON-LD file.
/// It contains a project-specific mix of prefixes from GO, OBO, and Identifiers.org.
///
/// Note, this is not a carefully constructed context, as there are overlapping entries
/// such as:
///
/// - TrEMBL and `http://purl.uniprot.org/uniprot/`
/// - SwissProt and `http://identifiers.org/SwissProt:`
/// - UniProtKB" and `http://identifiers.org/uniprot/`
///
/// # Examples
///
/// ```rust
/// use curies::sources::{get_monarch_converter};
/// use tokio::runtime;
///
/// let rt = runtime::Runtime::new().expect("Failed to create Tokio runtime");
/// let converter = rt.block_on(async {
/// get_monarch_converter().await
/// }).expect("Failed to create the converter");
///
/// let uri = converter.expand("CHEBI:24867").unwrap();
/// assert_eq!(uri, "http://purl.obolibrary.org/obo/CHEBI_24867");
///
/// let unregistered_uri = converter.expand("addgene:50943");
/// assert!(unregistered_uri.is_err(), "AddGene is not registered in the Monarch context");
///
/// let curie = converter.compress("http://purl.obolibrary.org/obo/CHEBI_24867").unwrap();
/// assert_eq!(curie, "CHEBI:24867");
///
/// let unregistered_curie = converter.compress("http://addgene.org/50943");
/// assert!(unregistered_curie.is_err(), "AddGene is not registered in the Monarch context");
/// ```
pub async
/// Get the Prefix Commons-maintained [Gene Ontology (GO)
/// context](https://github.com/prefixcommons/prefixcommons-py/blob/master/prefixcommons/registry/go_context.jsonld)
///
/// The Gene Ontology context is a simple prefix map stored in a JSON-LD file.
/// It contains prefixes corresponding to semantic spaces that are useful for
/// modeling the molecular functions, cellular components, and biological processes
/// that genes take part in.
///
/// # Examples
///
/// ```rust
/// use curies::sources::{get_go_converter};
/// use tokio::runtime;
///
/// let rt = runtime::Runtime::new().expect("Failed to create Tokio runtime");
/// let converter = rt.block_on(async {
/// get_go_converter().await
/// }).expect("Failed to create the converter");
///
/// let uri = converter.expand("NCBIGene:100010").unwrap();
/// assert_eq!(uri, "http://identifiers.org/ncbigene/100010");
///
/// let unregistered_uri = converter.expand("DOID:1234");
/// assert!(unregistered_uri.is_err(), "DOID is not registered in the GO context");
///
/// let curie = converter.compress("http://identifiers.org/ncbigene/100010").unwrap();
/// assert_eq!(curie, "NCBIGene:100010");
///
/// let unregistered_curie = converter.compress("http://purl.obolibrary.org/obo/DOID_1234");
/// assert!(unregistered_curie.is_err(), "DOID is not registered in the GO context");
/// ```
pub async
/// Get the BioRegistry extended prefix map.
///
/// # Examples
///
/// ```rust
/// use curies::sources::get_bioregistry_converter;
/// use tokio::runtime;
///
/// let rt = runtime::Runtime::new().expect("Failed to create Tokio runtime");
/// let converter = rt.block_on(async {
/// get_bioregistry_converter().await
/// }).expect("Failed to create the converter");
///
/// let uri = converter.expand("NCBIGene:100010").unwrap();
/// assert_eq!(uri, "https://www.ncbi.nlm.nih.gov/gene/100010");
/// ```
pub async