pyobo 0.11.2__py3-none-any.whl → 0.12.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyobo/.DS_Store +0 -0
- pyobo/__init__.py +95 -20
- pyobo/__main__.py +0 -0
- pyobo/api/__init__.py +81 -10
- pyobo/api/alts.py +52 -42
- pyobo/api/combine.py +39 -0
- pyobo/api/edges.py +68 -0
- pyobo/api/hierarchy.py +231 -203
- pyobo/api/metadata.py +14 -19
- pyobo/api/names.py +207 -127
- pyobo/api/properties.py +117 -117
- pyobo/api/relations.py +68 -94
- pyobo/api/species.py +24 -21
- pyobo/api/typedefs.py +11 -11
- pyobo/api/utils.py +66 -13
- pyobo/api/xrefs.py +107 -114
- pyobo/cli/__init__.py +0 -0
- pyobo/cli/cli.py +35 -50
- pyobo/cli/database.py +210 -160
- pyobo/cli/database_utils.py +155 -0
- pyobo/cli/lookup.py +163 -195
- pyobo/cli/utils.py +19 -6
- pyobo/constants.py +102 -3
- pyobo/getters.py +209 -191
- pyobo/gilda_utils.py +52 -250
- pyobo/identifier_utils/__init__.py +33 -0
- pyobo/identifier_utils/api.py +305 -0
- pyobo/identifier_utils/preprocessing.json +873 -0
- pyobo/identifier_utils/preprocessing.py +27 -0
- pyobo/identifier_utils/relations/__init__.py +8 -0
- pyobo/identifier_utils/relations/api.py +162 -0
- pyobo/identifier_utils/relations/data.json +5824 -0
- pyobo/identifier_utils/relations/data_owl.json +57 -0
- pyobo/identifier_utils/relations/data_rdf.json +1 -0
- pyobo/identifier_utils/relations/data_rdfs.json +7 -0
- pyobo/mocks.py +9 -6
- pyobo/ner/__init__.py +9 -0
- pyobo/ner/api.py +72 -0
- pyobo/ner/normalizer.py +33 -0
- pyobo/obographs.py +48 -40
- pyobo/plugins.py +5 -4
- pyobo/py.typed +0 -0
- pyobo/reader.py +1354 -395
- pyobo/reader_utils.py +155 -0
- pyobo/resource_utils.py +42 -22
- pyobo/resources/__init__.py +0 -0
- pyobo/resources/goc.py +75 -0
- pyobo/resources/goc.tsv +188 -0
- pyobo/resources/ncbitaxon.py +4 -5
- pyobo/resources/ncbitaxon.tsv.gz +0 -0
- pyobo/resources/ro.py +3 -2
- pyobo/resources/ro.tsv +0 -0
- pyobo/resources/so.py +0 -0
- pyobo/resources/so.tsv +0 -0
- pyobo/sources/README.md +12 -8
- pyobo/sources/__init__.py +52 -29
- pyobo/sources/agrovoc.py +0 -0
- pyobo/sources/antibodyregistry.py +11 -12
- pyobo/sources/bigg/__init__.py +13 -0
- pyobo/sources/bigg/bigg_compartment.py +81 -0
- pyobo/sources/bigg/bigg_metabolite.py +229 -0
- pyobo/sources/bigg/bigg_model.py +46 -0
- pyobo/sources/bigg/bigg_reaction.py +77 -0
- pyobo/sources/biogrid.py +1 -2
- pyobo/sources/ccle.py +7 -12
- pyobo/sources/cgnc.py +9 -6
- pyobo/sources/chebi.py +1 -1
- pyobo/sources/chembl/__init__.py +9 -0
- pyobo/sources/{chembl.py → chembl/chembl_compound.py} +13 -25
- pyobo/sources/chembl/chembl_target.py +160 -0
- pyobo/sources/civic_gene.py +55 -15
- pyobo/sources/clinicaltrials.py +160 -0
- pyobo/sources/complexportal.py +24 -24
- pyobo/sources/conso.py +14 -22
- pyobo/sources/cpt.py +0 -0
- pyobo/sources/credit.py +1 -9
- pyobo/sources/cvx.py +27 -5
- pyobo/sources/depmap.py +9 -12
- pyobo/sources/dictybase_gene.py +2 -7
- pyobo/sources/drugbank/__init__.py +9 -0
- pyobo/sources/{drugbank.py → drugbank/drugbank.py} +11 -16
- pyobo/sources/{drugbank_salt.py → drugbank/drugbank_salt.py} +3 -8
- pyobo/sources/drugcentral.py +17 -13
- pyobo/sources/expasy.py +31 -34
- pyobo/sources/famplex.py +13 -18
- pyobo/sources/flybase.py +8 -13
- pyobo/sources/gard.py +62 -0
- pyobo/sources/geonames/__init__.py +9 -0
- pyobo/sources/geonames/features.py +28 -0
- pyobo/sources/{geonames.py → geonames/geonames.py} +87 -26
- pyobo/sources/geonames/utils.py +115 -0
- pyobo/sources/gmt_utils.py +6 -7
- pyobo/sources/go.py +20 -13
- pyobo/sources/gtdb.py +154 -0
- pyobo/sources/gwascentral/__init__.py +9 -0
- pyobo/sources/{gwascentral_phenotype.py → gwascentral/gwascentral_phenotype.py} +5 -7
- pyobo/sources/{gwascentral_study.py → gwascentral/gwascentral_study.py} +1 -7
- pyobo/sources/hgnc/__init__.py +9 -0
- pyobo/sources/{hgnc.py → hgnc/hgnc.py} +56 -70
- pyobo/sources/{hgncgenefamily.py → hgnc/hgncgenefamily.py} +8 -18
- pyobo/sources/icd/__init__.py +9 -0
- pyobo/sources/{icd10.py → icd/icd10.py} +35 -37
- pyobo/sources/icd/icd11.py +148 -0
- pyobo/sources/{icd_utils.py → icd/icd_utils.py} +66 -20
- pyobo/sources/interpro.py +4 -9
- pyobo/sources/itis.py +0 -5
- pyobo/sources/kegg/__init__.py +0 -0
- pyobo/sources/kegg/api.py +16 -38
- pyobo/sources/kegg/genes.py +9 -20
- pyobo/sources/kegg/genome.py +1 -7
- pyobo/sources/kegg/pathway.py +9 -21
- pyobo/sources/mesh.py +58 -24
- pyobo/sources/mgi.py +3 -10
- pyobo/sources/mirbase/__init__.py +11 -0
- pyobo/sources/{mirbase.py → mirbase/mirbase.py} +8 -11
- pyobo/sources/{mirbase_constants.py → mirbase/mirbase_constants.py} +0 -0
- pyobo/sources/{mirbase_family.py → mirbase/mirbase_family.py} +4 -8
- pyobo/sources/{mirbase_mature.py → mirbase/mirbase_mature.py} +3 -7
- pyobo/sources/msigdb.py +74 -39
- pyobo/sources/ncbi/__init__.py +9 -0
- pyobo/sources/ncbi/ncbi_gc.py +162 -0
- pyobo/sources/{ncbigene.py → ncbi/ncbigene.py} +18 -19
- pyobo/sources/nih_reporter.py +60 -0
- pyobo/sources/nlm/__init__.py +9 -0
- pyobo/sources/nlm/nlm_catalog.py +48 -0
- pyobo/sources/nlm/nlm_publisher.py +36 -0
- pyobo/sources/nlm/utils.py +116 -0
- pyobo/sources/npass.py +6 -8
- pyobo/sources/omim_ps.py +11 -4
- pyobo/sources/pathbank.py +4 -8
- pyobo/sources/pfam/__init__.py +9 -0
- pyobo/sources/{pfam.py → pfam/pfam.py} +3 -8
- pyobo/sources/{pfam_clan.py → pfam/pfam_clan.py} +2 -7
- pyobo/sources/pharmgkb/__init__.py +15 -0
- pyobo/sources/pharmgkb/pharmgkb_chemical.py +89 -0
- pyobo/sources/pharmgkb/pharmgkb_disease.py +77 -0
- pyobo/sources/pharmgkb/pharmgkb_gene.py +108 -0
- pyobo/sources/pharmgkb/pharmgkb_pathway.py +63 -0
- pyobo/sources/pharmgkb/pharmgkb_variant.py +84 -0
- pyobo/sources/pharmgkb/utils.py +86 -0
- pyobo/sources/pid.py +1 -6
- pyobo/sources/pombase.py +6 -10
- pyobo/sources/pubchem.py +4 -9
- pyobo/sources/reactome.py +5 -11
- pyobo/sources/rgd.py +11 -16
- pyobo/sources/rhea.py +37 -36
- pyobo/sources/ror.py +69 -42
- pyobo/sources/selventa/__init__.py +0 -0
- pyobo/sources/selventa/schem.py +4 -7
- pyobo/sources/selventa/scomp.py +1 -6
- pyobo/sources/selventa/sdis.py +4 -7
- pyobo/sources/selventa/sfam.py +1 -6
- pyobo/sources/sgd.py +6 -11
- pyobo/sources/signor/__init__.py +7 -0
- pyobo/sources/signor/download.py +41 -0
- pyobo/sources/signor/signor_complexes.py +105 -0
- pyobo/sources/slm.py +12 -15
- pyobo/sources/umls/__init__.py +7 -1
- pyobo/sources/umls/__main__.py +0 -0
- pyobo/sources/umls/get_synonym_types.py +20 -4
- pyobo/sources/umls/sty.py +57 -0
- pyobo/sources/umls/synonym_types.tsv +1 -1
- pyobo/sources/umls/umls.py +18 -22
- pyobo/sources/unimod.py +46 -0
- pyobo/sources/uniprot/__init__.py +1 -1
- pyobo/sources/uniprot/uniprot.py +40 -32
- pyobo/sources/uniprot/uniprot_ptm.py +4 -34
- pyobo/sources/utils.py +3 -2
- pyobo/sources/wikipathways.py +7 -10
- pyobo/sources/zfin.py +5 -10
- pyobo/ssg/__init__.py +12 -16
- pyobo/ssg/base.html +0 -0
- pyobo/ssg/index.html +26 -13
- pyobo/ssg/term.html +12 -2
- pyobo/ssg/typedef.html +0 -0
- pyobo/struct/__init__.py +54 -8
- pyobo/struct/functional/__init__.py +1 -0
- pyobo/struct/functional/dsl.py +2572 -0
- pyobo/struct/functional/macros.py +423 -0
- pyobo/struct/functional/obo_to_functional.py +385 -0
- pyobo/struct/functional/ontology.py +272 -0
- pyobo/struct/functional/utils.py +112 -0
- pyobo/struct/reference.py +331 -136
- pyobo/struct/struct.py +1484 -657
- pyobo/struct/struct_utils.py +1078 -0
- pyobo/struct/typedef.py +162 -210
- pyobo/struct/utils.py +12 -5
- pyobo/struct/vocabulary.py +138 -0
- pyobo/utils/__init__.py +0 -0
- pyobo/utils/cache.py +16 -15
- pyobo/utils/io.py +51 -41
- pyobo/utils/iter.py +5 -5
- pyobo/utils/misc.py +41 -53
- pyobo/utils/ndex_utils.py +0 -0
- pyobo/utils/path.py +73 -70
- pyobo/version.py +3 -3
- pyobo-0.12.1.dist-info/METADATA +671 -0
- pyobo-0.12.1.dist-info/RECORD +201 -0
- pyobo-0.12.1.dist-info/WHEEL +4 -0
- {pyobo-0.11.2.dist-info → pyobo-0.12.1.dist-info}/entry_points.txt +1 -0
- pyobo-0.12.1.dist-info/licenses/LICENSE +21 -0
- pyobo/aws.py +0 -162
- pyobo/cli/aws.py +0 -47
- pyobo/identifier_utils.py +0 -142
- pyobo/normalizer.py +0 -232
- pyobo/registries/__init__.py +0 -16
- pyobo/registries/metaregistry.json +0 -507
- pyobo/registries/metaregistry.py +0 -135
- pyobo/sources/icd11.py +0 -105
- pyobo/xrefdb/__init__.py +0 -1
- pyobo/xrefdb/canonicalizer.py +0 -214
- pyobo/xrefdb/priority.py +0 -59
- pyobo/xrefdb/sources/__init__.py +0 -60
- pyobo/xrefdb/sources/biomappings.py +0 -36
- pyobo/xrefdb/sources/cbms2019.py +0 -91
- pyobo/xrefdb/sources/chembl.py +0 -83
- pyobo/xrefdb/sources/compath.py +0 -82
- pyobo/xrefdb/sources/famplex.py +0 -64
- pyobo/xrefdb/sources/gilda.py +0 -50
- pyobo/xrefdb/sources/intact.py +0 -113
- pyobo/xrefdb/sources/ncit.py +0 -133
- pyobo/xrefdb/sources/pubchem.py +0 -27
- pyobo/xrefdb/sources/wikidata.py +0 -116
- pyobo/xrefdb/xrefs_pipeline.py +0 -180
- pyobo-0.11.2.dist-info/METADATA +0 -711
- pyobo-0.11.2.dist-info/RECORD +0 -157
- pyobo-0.11.2.dist-info/WHEEL +0 -5
- pyobo-0.11.2.dist-info/top_level.txt +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Load the manually curated metaregistry."""
|
|
2
|
+
|
|
3
|
+
from functools import lru_cache
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from curies.preprocessing import PreprocessingRules, _load_rules
|
|
7
|
+
|
|
8
|
+
from ..resources.goc import load_goc_map
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"get_rules",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
HERE = Path(__file__).parent.resolve()
|
|
15
|
+
RULES_PATH = HERE.joinpath("preprocessing.json")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@lru_cache(1)
|
|
19
|
+
def get_rules() -> PreprocessingRules:
|
|
20
|
+
"""Get the CURIE/URI string preprocessing rules."""
|
|
21
|
+
rules = _load_rules(RULES_PATH)
|
|
22
|
+
rules.rewrites.full.update(load_goc_map())
|
|
23
|
+
return rules
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
PreprocessingRules.lint_file(RULES_PATH)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""API for grounding relations."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from collections.abc import Mapping
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
from bioregistry import NormalizedNamedReference
|
|
10
|
+
from tqdm import tqdm
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"get_normalized_label",
|
|
14
|
+
"ground_relation",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
HERE = Path(__file__).parent.resolve()
|
|
18
|
+
PATH = HERE.joinpath("data.json")
|
|
19
|
+
URLS = [
|
|
20
|
+
("ro", "http://purl.obolibrary.org/obo/ro.json"),
|
|
21
|
+
(
|
|
22
|
+
"debio",
|
|
23
|
+
"https://raw.githubusercontent.com/biopragmatics/debio/main/releases/current/debio.json",
|
|
24
|
+
),
|
|
25
|
+
("bfo", None),
|
|
26
|
+
("oboinowl", None),
|
|
27
|
+
("bspo", None),
|
|
28
|
+
("iao", None),
|
|
29
|
+
("omo", None),
|
|
30
|
+
("vo", None),
|
|
31
|
+
("obi", None),
|
|
32
|
+
]
|
|
33
|
+
PREFIX_OBO = "http://purl.obolibrary.org/obo/"
|
|
34
|
+
PREFIX_OIO = "http://www.geneontology.org/formats/oboInOwl#"
|
|
35
|
+
|
|
36
|
+
LABELS = {
|
|
37
|
+
"http://www.w3.org/2000/01/rdf-schema#isDefinedBy": "is_defined_by",
|
|
38
|
+
"rdf:type": "type",
|
|
39
|
+
"owl:inverseOf": "inverse_of",
|
|
40
|
+
"skos:exactMatch": "exact_match",
|
|
41
|
+
"rdfs:subClassOf": "is_a",
|
|
42
|
+
"rdfs:subPropertyOf": "subproperty",
|
|
43
|
+
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": "type",
|
|
44
|
+
"obo:has_prefix": "has_unit_prefix", # weird thing from UO
|
|
45
|
+
# FIXME deal with these relations
|
|
46
|
+
"http://purl.obolibrary.org/obo/uberon/core#proximally_connected_to": "proximally_connected_to",
|
|
47
|
+
"http://purl.obolibrary.org/obo/uberon/core#extends_fibers_into": "proximally_connected_to",
|
|
48
|
+
"http://purl.obolibrary.org/obo/uberon/core#channel_for": "proximally_connected_to",
|
|
49
|
+
"http://purl.obolibrary.org/obo/uberon/core#distally_connected_to": "proximally_connected_to",
|
|
50
|
+
"http://purl.obolibrary.org/obo/uberon/core#channels_into": "channels_into",
|
|
51
|
+
"http://purl.obolibrary.org/obo/uberon/core#channels_from": "channels_from",
|
|
52
|
+
"http://purl.obolibrary.org/obo/uberon/core#subdivision_of": "subdivision_of",
|
|
53
|
+
"http://purl.obolibrary.org/obo/uberon/core#protects": "protects",
|
|
54
|
+
"http://purl.obolibrary.org/obo/uberon/core#posteriorly_connected_to": "posteriorly_connected_to",
|
|
55
|
+
"http://purl.obolibrary.org/obo/uberon/core#evolved_from": "evolved_from",
|
|
56
|
+
"http://purl.obolibrary.org/obo/uberon/core#anteriorly_connected_to": "anteriorly_connected_to",
|
|
57
|
+
#
|
|
58
|
+
"obi:0000304": "is_manufactured_by",
|
|
59
|
+
"vo:0003355": "immunizes_against_microbe",
|
|
60
|
+
"bao:0002846": "has_assay_protocol",
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _norm(s: str) -> str:
|
|
65
|
+
return s.replace(" ", "").replace("_", "").replace(":", "").lower()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def ground_relation(s: str) -> NormalizedNamedReference | None:
|
|
69
|
+
"""Ground a string to a RO property."""
|
|
70
|
+
return get_lookups().get(_norm(s))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def get_normalized_label(curie_or_uri: str) -> str | None:
|
|
74
|
+
"""Get a normalized label."""
|
|
75
|
+
rv = LABELS.get(curie_or_uri)
|
|
76
|
+
if rv:
|
|
77
|
+
return rv
|
|
78
|
+
rv = get_curie_to_norm_name().get(curie_or_uri)
|
|
79
|
+
if rv:
|
|
80
|
+
return rv
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@lru_cache(1)
|
|
85
|
+
def get_lookups() -> Mapping[str, NormalizedNamedReference]:
|
|
86
|
+
"""Get lookups for relation ontology properties."""
|
|
87
|
+
d = {}
|
|
88
|
+
for record in json.loads(PATH.read_text()):
|
|
89
|
+
prefix, identifier, label = record["prefix"], record["identifier"], record["label"]
|
|
90
|
+
d[_norm(label)] = NormalizedNamedReference(prefix=prefix, identifier=identifier, name=label)
|
|
91
|
+
for s in record.get("synonyms", []):
|
|
92
|
+
d[_norm(s)] = NormalizedNamedReference(prefix=prefix, identifier=identifier, name=label)
|
|
93
|
+
return d
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def label_norm(s: str) -> str:
|
|
97
|
+
"""Normalize a label string."""
|
|
98
|
+
return s.lower().replace(" ", "_")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@lru_cache(1)
|
|
102
|
+
def get_curie_to_norm_name() -> Mapping[str, str]:
|
|
103
|
+
"""Get a dictionary mapping CURIEs to their normalized names."""
|
|
104
|
+
curie_to_norm_name = {}
|
|
105
|
+
for record in json.loads(PATH.read_text()):
|
|
106
|
+
prefix, identifier, label = record["prefix"], record["identifier"], record["label"]
|
|
107
|
+
curie_to_norm_name[f"{prefix}:{identifier}"] = label_norm(label)
|
|
108
|
+
return curie_to_norm_name
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
HEADER = ["prefix", "identifier", "label", "synonyms"]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def main():
|
|
115
|
+
"""Download and process the relation ontology data."""
|
|
116
|
+
from bioontologies import get_obograph_by_prefix
|
|
117
|
+
from bioontologies.obograph import GraphDocument
|
|
118
|
+
from bioontologies.robot import correct_raw_json
|
|
119
|
+
|
|
120
|
+
rows = []
|
|
121
|
+
for source, url in URLS:
|
|
122
|
+
if url is not None:
|
|
123
|
+
res = requests.get(url, timeout=60)
|
|
124
|
+
res.raise_for_status()
|
|
125
|
+
res_json = res.json()
|
|
126
|
+
correct_raw_json(res_json)
|
|
127
|
+
graph_document = GraphDocument.model_validate(res_json)
|
|
128
|
+
graph = graph_document.guess(source)
|
|
129
|
+
else:
|
|
130
|
+
try:
|
|
131
|
+
results = get_obograph_by_prefix(source)
|
|
132
|
+
graph = results.guess(source)
|
|
133
|
+
except ValueError as e:
|
|
134
|
+
tqdm.write(f"[{source}] error: {e}")
|
|
135
|
+
continue
|
|
136
|
+
for node in tqdm(graph.nodes, desc=source, unit="node"):
|
|
137
|
+
if node.type != "PROPERTY" or not node.name:
|
|
138
|
+
continue
|
|
139
|
+
node.standardize()
|
|
140
|
+
if not node.prefix:
|
|
141
|
+
tqdm.write(f"[{source}] could not parse node: {node.id}")
|
|
142
|
+
continue
|
|
143
|
+
rows.append(
|
|
144
|
+
(
|
|
145
|
+
node.prefix,
|
|
146
|
+
node.identifier,
|
|
147
|
+
node.name,
|
|
148
|
+
tuple(sorted(synonym.value for synonym in node.synonyms)),
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
for p in ["rdf", "rdfs", "owl"]:
|
|
153
|
+
j = json.loads(HERE.joinpath(f"data_{p}.json").read_text())
|
|
154
|
+
rows.extend(tuple(row.get(h, ()) for h in HEADER) for row in j)
|
|
155
|
+
|
|
156
|
+
rows = sorted(set(rows))
|
|
157
|
+
row_dicts = [{k: v for k, v in zip(HEADER, row, strict=False) if v} for row in rows]
|
|
158
|
+
PATH.write_text(json.dumps(row_dicts, indent=2, sort_keys=True))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if __name__ == "__main__":
|
|
162
|
+
main()
|