pyobo 0.11.2__py3-none-any.whl → 0.12.0__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 -113
- 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 +108 -114
- pyobo/cli/__init__.py +0 -0
- pyobo/cli/cli.py +35 -50
- pyobo/cli/database.py +183 -161
- pyobo/{xrefdb/xrefs_pipeline.py → cli/database_utils.py} +54 -73
- pyobo/cli/lookup.py +163 -195
- pyobo/cli/utils.py +19 -6
- pyobo/constants.py +102 -3
- pyobo/getters.py +196 -118
- pyobo/gilda_utils.py +79 -200
- pyobo/identifier_utils/__init__.py +41 -0
- pyobo/identifier_utils/api.py +296 -0
- pyobo/identifier_utils/model.py +130 -0
- pyobo/identifier_utils/preprocessing.json +812 -0
- pyobo/identifier_utils/preprocessing.py +61 -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 +43 -39
- pyobo/plugins.py +5 -4
- pyobo/py.typed +0 -0
- pyobo/reader.py +1358 -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 +0 -5
- 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 +3 -8
- 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 +10 -3
- 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 +270 -0
- pyobo/struct/functional/utils.py +112 -0
- pyobo/struct/reference.py +331 -136
- pyobo/struct/struct.py +1413 -643
- 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 +13 -11
- pyobo/utils/io.py +17 -31
- pyobo/utils/iter.py +5 -5
- pyobo/utils/misc.py +41 -53
- pyobo/utils/ndex_utils.py +0 -0
- pyobo/utils/path.py +76 -70
- pyobo/version.py +3 -3
- {pyobo-0.11.2.dist-info → pyobo-0.12.0.dist-info}/METADATA +228 -229
- pyobo-0.12.0.dist-info/RECORD +202 -0
- pyobo-0.12.0.dist-info/WHEEL +4 -0
- {pyobo-0.11.2.dist-info → pyobo-0.12.0.dist-info}/entry_points.txt +1 -0
- pyobo-0.12.0.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-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
pyobo/.DS_Store
ADDED
|
Binary file
|
pyobo/__init__.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"""A python package for handling and generating OBO."""
|
|
2
2
|
|
|
3
|
-
from .api import (
|
|
3
|
+
from .api import (
|
|
4
4
|
get_alts_to_id,
|
|
5
5
|
get_ancestors,
|
|
6
6
|
get_children,
|
|
7
7
|
get_definition,
|
|
8
8
|
get_descendants,
|
|
9
|
+
get_edges,
|
|
10
|
+
get_edges_df,
|
|
9
11
|
get_filtered_properties_df,
|
|
10
12
|
get_filtered_properties_mapping,
|
|
11
13
|
get_filtered_properties_multimapping,
|
|
@@ -20,15 +22,25 @@ from .api import ( # noqa: F401
|
|
|
20
22
|
get_id_synonyms_mapping,
|
|
21
23
|
get_id_to_alts,
|
|
22
24
|
get_ids,
|
|
25
|
+
get_literal_mappings,
|
|
26
|
+
get_literal_mappings_df,
|
|
27
|
+
get_literal_mappings_subset,
|
|
28
|
+
get_literal_properties,
|
|
29
|
+
get_literal_properties_df,
|
|
30
|
+
get_mappings_df,
|
|
31
|
+
get_metadata,
|
|
23
32
|
get_name,
|
|
24
33
|
get_name_by_curie,
|
|
25
34
|
get_name_id_mapping,
|
|
35
|
+
get_object_properties,
|
|
36
|
+
get_object_properties_df,
|
|
26
37
|
get_obsolete,
|
|
27
38
|
get_primary_curie,
|
|
28
39
|
get_primary_identifier,
|
|
29
40
|
get_properties,
|
|
30
41
|
get_properties_df,
|
|
31
42
|
get_property,
|
|
43
|
+
get_references,
|
|
32
44
|
get_relation,
|
|
33
45
|
get_relation_mapping,
|
|
34
46
|
get_relations_df,
|
|
@@ -43,26 +55,89 @@ from .api import ( # noqa: F401
|
|
|
43
55
|
has_ancestor,
|
|
44
56
|
is_descendent,
|
|
45
57
|
)
|
|
46
|
-
from .getters import get_ontology
|
|
47
|
-
from .
|
|
48
|
-
from .
|
|
49
|
-
from .
|
|
50
|
-
from .plugins import ( # noqa: F401
|
|
58
|
+
from .getters import get_ontology
|
|
59
|
+
from .ner import get_grounder, ground
|
|
60
|
+
from .obographs import parse_results_from_obo
|
|
61
|
+
from .plugins import (
|
|
51
62
|
has_nomenclature_plugin,
|
|
52
63
|
iter_nomenclature_plugins,
|
|
53
64
|
run_nomenclature_plugin,
|
|
54
65
|
)
|
|
55
|
-
from .reader import from_obo_path, from_obonet
|
|
56
|
-
from .struct import Obo, Reference, Synonym, SynonymTypeDef, Term, TypeDef
|
|
57
|
-
from .utils.path import ensure_path
|
|
58
|
-
from .version import get_version
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
from .reader import from_obo_path, from_obonet
|
|
67
|
+
from .struct import Obo, Reference, Synonym, SynonymTypeDef, Term, TypeDef, default_reference
|
|
68
|
+
from .utils.path import ensure_path
|
|
69
|
+
from .version import get_version
|
|
70
|
+
|
|
71
|
+
__all__ = [
|
|
72
|
+
"Obo",
|
|
73
|
+
"Reference",
|
|
74
|
+
"Synonym",
|
|
75
|
+
"SynonymTypeDef",
|
|
76
|
+
"Term",
|
|
77
|
+
"TypeDef",
|
|
78
|
+
"default_reference",
|
|
79
|
+
"ensure_path",
|
|
80
|
+
"from_obo_path",
|
|
81
|
+
"from_obonet",
|
|
82
|
+
"get_alts_to_id",
|
|
83
|
+
"get_ancestors",
|
|
84
|
+
"get_children",
|
|
85
|
+
"get_definition",
|
|
86
|
+
"get_descendants",
|
|
87
|
+
"get_edges",
|
|
88
|
+
"get_edges_df",
|
|
89
|
+
"get_filtered_properties_df",
|
|
90
|
+
"get_filtered_properties_mapping",
|
|
91
|
+
"get_filtered_properties_multimapping",
|
|
92
|
+
"get_filtered_relations_df",
|
|
93
|
+
"get_filtered_xrefs",
|
|
94
|
+
"get_graph",
|
|
95
|
+
"get_grounder",
|
|
96
|
+
"get_hierarchy",
|
|
97
|
+
"get_id_definition_mapping",
|
|
98
|
+
"get_id_multirelations_mapping",
|
|
99
|
+
"get_id_name_mapping",
|
|
100
|
+
"get_id_species_mapping",
|
|
101
|
+
"get_id_synonyms_mapping",
|
|
102
|
+
"get_id_to_alts",
|
|
103
|
+
"get_ids",
|
|
104
|
+
"get_literal_mappings",
|
|
105
|
+
"get_literal_mappings_df",
|
|
106
|
+
"get_literal_mappings_subset",
|
|
107
|
+
"get_literal_properties",
|
|
108
|
+
"get_literal_properties_df",
|
|
109
|
+
"get_mappings_df",
|
|
110
|
+
"get_metadata",
|
|
111
|
+
"get_name",
|
|
112
|
+
"get_name_by_curie",
|
|
113
|
+
"get_name_id_mapping",
|
|
114
|
+
"get_object_properties",
|
|
115
|
+
"get_object_properties_df",
|
|
116
|
+
"get_obsolete",
|
|
117
|
+
"get_ontology",
|
|
118
|
+
"get_primary_curie",
|
|
119
|
+
"get_primary_identifier",
|
|
120
|
+
"get_properties",
|
|
121
|
+
"get_properties_df",
|
|
122
|
+
"get_property",
|
|
123
|
+
"get_references",
|
|
124
|
+
"get_relation",
|
|
125
|
+
"get_relation_mapping",
|
|
126
|
+
"get_relations_df",
|
|
127
|
+
"get_species",
|
|
128
|
+
"get_sssom_df",
|
|
129
|
+
"get_subhierarchy",
|
|
130
|
+
"get_synonyms",
|
|
131
|
+
"get_typedef_df",
|
|
132
|
+
"get_version",
|
|
133
|
+
"get_xref",
|
|
134
|
+
"get_xrefs",
|
|
135
|
+
"get_xrefs_df",
|
|
136
|
+
"ground",
|
|
137
|
+
"has_ancestor",
|
|
138
|
+
"has_nomenclature_plugin",
|
|
139
|
+
"is_descendent",
|
|
140
|
+
"iter_nomenclature_plugins",
|
|
141
|
+
"parse_results_from_obo",
|
|
142
|
+
"run_nomenclature_plugin",
|
|
143
|
+
]
|
pyobo/__main__.py
CHANGED
|
File without changes
|
pyobo/api/__init__.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"""High-level API for accessing content."""
|
|
2
2
|
|
|
3
|
-
from .alts import (
|
|
3
|
+
from .alts import (
|
|
4
4
|
get_alts_to_id,
|
|
5
5
|
get_id_to_alts,
|
|
6
6
|
get_primary_curie,
|
|
7
7
|
get_primary_identifier,
|
|
8
8
|
)
|
|
9
|
-
from .
|
|
9
|
+
from .combine import get_literal_mappings_subset
|
|
10
|
+
from .edges import get_edges, get_edges_df, get_graph
|
|
11
|
+
from .hierarchy import (
|
|
10
12
|
get_ancestors,
|
|
11
13
|
get_children,
|
|
12
14
|
get_descendants,
|
|
@@ -15,41 +17,110 @@ from .hierarchy import ( # noqa: F401
|
|
|
15
17
|
has_ancestor,
|
|
16
18
|
is_descendent,
|
|
17
19
|
)
|
|
18
|
-
from .metadata import get_metadata
|
|
19
|
-
from .names import (
|
|
20
|
+
from .metadata import get_metadata
|
|
21
|
+
from .names import (
|
|
20
22
|
get_definition,
|
|
21
23
|
get_id_definition_mapping,
|
|
22
24
|
get_id_name_mapping,
|
|
23
25
|
get_id_synonyms_mapping,
|
|
24
26
|
get_ids,
|
|
27
|
+
get_literal_mappings,
|
|
28
|
+
get_literal_mappings_df,
|
|
25
29
|
get_name,
|
|
26
30
|
get_name_by_curie,
|
|
27
31
|
get_name_id_mapping,
|
|
28
32
|
get_obsolete,
|
|
33
|
+
get_obsolete_references,
|
|
34
|
+
get_references,
|
|
29
35
|
get_synonyms,
|
|
30
36
|
)
|
|
31
|
-
from .properties import (
|
|
37
|
+
from .properties import (
|
|
32
38
|
get_filtered_properties_df,
|
|
33
39
|
get_filtered_properties_mapping,
|
|
34
40
|
get_filtered_properties_multimapping,
|
|
41
|
+
get_literal_properties,
|
|
42
|
+
get_literal_properties_df,
|
|
43
|
+
get_object_properties,
|
|
44
|
+
get_object_properties_df,
|
|
35
45
|
get_properties,
|
|
36
46
|
get_properties_df,
|
|
37
47
|
get_property,
|
|
38
48
|
)
|
|
39
|
-
from .relations import (
|
|
49
|
+
from .relations import (
|
|
40
50
|
get_filtered_relations_df,
|
|
41
|
-
get_graph,
|
|
42
51
|
get_id_multirelations_mapping,
|
|
43
52
|
get_relation,
|
|
44
53
|
get_relation_mapping,
|
|
45
54
|
get_relations_df,
|
|
46
55
|
)
|
|
47
|
-
from .species import get_id_species_mapping, get_species
|
|
48
|
-
from .typedefs import get_typedef_df
|
|
49
|
-
from .xrefs import (
|
|
56
|
+
from .species import get_id_species_mapping, get_species
|
|
57
|
+
from .typedefs import get_typedef_df
|
|
58
|
+
from .xrefs import (
|
|
50
59
|
get_filtered_xrefs,
|
|
60
|
+
get_mappings_df,
|
|
51
61
|
get_sssom_df,
|
|
52
62
|
get_xref,
|
|
53
63
|
get_xrefs,
|
|
54
64
|
get_xrefs_df,
|
|
55
65
|
)
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
"get_alts_to_id",
|
|
69
|
+
"get_ancestors",
|
|
70
|
+
"get_children",
|
|
71
|
+
"get_definition",
|
|
72
|
+
"get_descendants",
|
|
73
|
+
"get_edges",
|
|
74
|
+
"get_edges_df",
|
|
75
|
+
"get_equivalent",
|
|
76
|
+
"get_filtered_properties_df",
|
|
77
|
+
"get_filtered_properties_mapping",
|
|
78
|
+
"get_filtered_properties_multimapping",
|
|
79
|
+
"get_filtered_relations_df",
|
|
80
|
+
"get_filtered_xrefs",
|
|
81
|
+
"get_graph",
|
|
82
|
+
"get_hierarchy",
|
|
83
|
+
"get_id_definition_mapping",
|
|
84
|
+
"get_id_multirelations_mapping",
|
|
85
|
+
"get_id_name_mapping",
|
|
86
|
+
"get_id_species_mapping",
|
|
87
|
+
"get_id_synonyms_mapping",
|
|
88
|
+
"get_id_to_alts",
|
|
89
|
+
"get_ids",
|
|
90
|
+
"get_literal_mappings",
|
|
91
|
+
"get_literal_mappings_df",
|
|
92
|
+
"get_literal_mappings_subset",
|
|
93
|
+
"get_literal_properties",
|
|
94
|
+
"get_literal_properties_df",
|
|
95
|
+
"get_mappings_df",
|
|
96
|
+
"get_metadata",
|
|
97
|
+
"get_name",
|
|
98
|
+
"get_name_by_curie",
|
|
99
|
+
"get_name_id_mapping",
|
|
100
|
+
"get_object_properties",
|
|
101
|
+
"get_object_properties_df",
|
|
102
|
+
"get_obsolete",
|
|
103
|
+
"get_obsolete_references",
|
|
104
|
+
"get_ontology",
|
|
105
|
+
"get_primary_curie",
|
|
106
|
+
"get_primary_identifier",
|
|
107
|
+
"get_priority_curie",
|
|
108
|
+
"get_properties",
|
|
109
|
+
"get_properties_df",
|
|
110
|
+
"get_property",
|
|
111
|
+
"get_references",
|
|
112
|
+
"get_relation",
|
|
113
|
+
"get_relation_mapping",
|
|
114
|
+
"get_relations_df",
|
|
115
|
+
"get_species",
|
|
116
|
+
"get_sssom_df",
|
|
117
|
+
"get_subhierarchy",
|
|
118
|
+
"get_synonyms",
|
|
119
|
+
"get_typedef_df",
|
|
120
|
+
"get_version",
|
|
121
|
+
"get_xref",
|
|
122
|
+
"get_xrefs",
|
|
123
|
+
"get_xrefs_df",
|
|
124
|
+
"has_ancestor",
|
|
125
|
+
"is_descendent",
|
|
126
|
+
]
|
pyobo/api/alts.py
CHANGED
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from collections.abc import Mapping
|
|
5
5
|
from functools import lru_cache
|
|
6
|
-
from typing import Optional
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
import curies
|
|
8
|
+
from pydantic import ValidationError
|
|
9
|
+
from typing_extensions import Unpack
|
|
10
|
+
|
|
11
|
+
from .utils import _get_pi, get_version_from_kwargs
|
|
12
|
+
from ..constants import GetOntologyKwargs, check_should_cache, check_should_force
|
|
9
13
|
from ..getters import get_ontology
|
|
10
|
-
from ..identifier_utils import
|
|
14
|
+
from ..identifier_utils import wrap_norm_prefix
|
|
11
15
|
from ..utils.cache import cached_multidict
|
|
12
|
-
from ..utils.path import
|
|
16
|
+
from ..utils.path import CacheArtifact, get_cache_path
|
|
13
17
|
|
|
14
18
|
__all__ = [
|
|
15
|
-
"get_id_to_alts",
|
|
16
19
|
"get_alts_to_id",
|
|
20
|
+
"get_id_to_alts",
|
|
17
21
|
"get_primary_curie",
|
|
18
22
|
"get_primary_identifier",
|
|
19
23
|
]
|
|
@@ -27,25 +31,22 @@ NO_ALTS = {
|
|
|
27
31
|
|
|
28
32
|
@lru_cache
|
|
29
33
|
@wrap_norm_prefix
|
|
30
|
-
def get_id_to_alts(
|
|
31
|
-
prefix: str, *, force: bool = False, version: Optional[str] = None
|
|
32
|
-
) -> Mapping[str, list[str]]:
|
|
34
|
+
def get_id_to_alts(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> Mapping[str, list[str]]:
|
|
33
35
|
"""Get alternate identifiers."""
|
|
34
36
|
if prefix in NO_ALTS:
|
|
35
37
|
return {}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
path = prefix_cache_join(prefix, name="alt_ids.tsv", version=version)
|
|
40
|
-
header = [f"{prefix}_id", "alt_id"]
|
|
39
|
+
version = get_version_from_kwargs(prefix, kwargs)
|
|
40
|
+
path = get_cache_path(prefix, CacheArtifact.alts, version=version)
|
|
41
41
|
|
|
42
|
-
@cached_multidict(
|
|
42
|
+
@cached_multidict(
|
|
43
|
+
path=path,
|
|
44
|
+
header=[f"{prefix}_id", "alt_id"],
|
|
45
|
+
cache=check_should_cache(kwargs),
|
|
46
|
+
force=check_should_force(kwargs),
|
|
47
|
+
)
|
|
43
48
|
def _get_mapping() -> Mapping[str, list[str]]:
|
|
44
|
-
|
|
45
|
-
logger.info(f"[{prefix}] forcing reload for alts")
|
|
46
|
-
else:
|
|
47
|
-
logger.info("[%s] no cached alts found. getting from OBO loader", prefix)
|
|
48
|
-
ontology = get_ontology(prefix, force=force, version=version)
|
|
49
|
+
ontology = get_ontology(prefix, **kwargs)
|
|
49
50
|
return ontology.get_id_alts_mapping()
|
|
50
51
|
|
|
51
52
|
return _get_mapping()
|
|
@@ -53,40 +54,49 @@ def get_id_to_alts(
|
|
|
53
54
|
|
|
54
55
|
@lru_cache
|
|
55
56
|
@wrap_norm_prefix
|
|
56
|
-
def get_alts_to_id(
|
|
57
|
-
prefix: str, *, force: bool = False, version: Optional[str] = None
|
|
58
|
-
) -> Mapping[str, str]:
|
|
57
|
+
def get_alts_to_id(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> Mapping[str, str]:
|
|
59
58
|
"""Get alternative id to primary id mapping."""
|
|
60
59
|
return {
|
|
61
|
-
alt: primary
|
|
62
|
-
for primary, alts in get_id_to_alts(prefix, force=force, version=version).items()
|
|
63
|
-
for alt in alts
|
|
60
|
+
alt: primary for primary, alts in get_id_to_alts(prefix, **kwargs).items() for alt in alts
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
|
|
67
|
-
def get_primary_curie(
|
|
64
|
+
def get_primary_curie(
|
|
65
|
+
prefix: str | curies.Reference | curies.ReferenceTuple,
|
|
66
|
+
identifier: str | None = None,
|
|
67
|
+
/,
|
|
68
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
69
|
+
) -> str | None:
|
|
68
70
|
"""Get the primary curie for an entity."""
|
|
69
|
-
prefix, identifier
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
reference = _get_pi(prefix, identifier)
|
|
72
|
+
try:
|
|
73
|
+
primary_identifier = get_primary_identifier(reference, **kwargs)
|
|
74
|
+
except (ValueError, ValidationError):
|
|
75
|
+
if kwargs.get("strict"):
|
|
76
|
+
raise
|
|
77
|
+
# this happens on invalid prefix. maybe revise?
|
|
78
|
+
return None
|
|
79
|
+
return f"{reference.prefix}:{primary_identifier}"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_primary_identifier(
|
|
83
|
+
prefix: str | curies.Reference | curies.ReferenceTuple,
|
|
84
|
+
identifier: str | None = None,
|
|
85
|
+
/,
|
|
86
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
87
|
+
) -> str:
|
|
78
88
|
"""Get the primary identifier for an entity.
|
|
79
89
|
|
|
80
90
|
:param prefix: The name of the resource
|
|
81
91
|
:param identifier: The identifier to look up
|
|
92
|
+
|
|
82
93
|
:returns: the canonical identifier based on alt id lookup
|
|
83
94
|
|
|
84
|
-
Returns the original identifier if there are no alts available or if there's no
|
|
95
|
+
Returns the original identifier if there are no alts available or if there's no
|
|
96
|
+
mapping.
|
|
85
97
|
"""
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
alts_to_id = get_alts_to_id(prefix,
|
|
90
|
-
|
|
91
|
-
return alts_to_id[identifier]
|
|
92
|
-
return identifier
|
|
98
|
+
t = _get_pi(prefix, identifier)
|
|
99
|
+
if t.prefix in NO_ALTS: # TODO later expand list to other namespaces with no alts
|
|
100
|
+
return t.identifier
|
|
101
|
+
alts_to_id = get_alts_to_id(t.prefix, **kwargs)
|
|
102
|
+
return alts_to_id.get(t.identifier, t.identifier)
|
pyobo/api/combine.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Functions that combine other API aspects."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
|
|
5
|
+
import curies
|
|
6
|
+
import ssslm
|
|
7
|
+
from typing_extensions import Unpack
|
|
8
|
+
|
|
9
|
+
from pyobo.api.hierarchy import get_descendants
|
|
10
|
+
from pyobo.api.names import get_literal_mappings
|
|
11
|
+
from pyobo.constants import GetOntologyKwargs
|
|
12
|
+
from pyobo.struct import Reference
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"get_literal_mappings_subset",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_literal_mappings_subset(
|
|
20
|
+
prefix: str,
|
|
21
|
+
ancestors: curies.Reference | Sequence[curies.Reference],
|
|
22
|
+
*,
|
|
23
|
+
skip_obsolete: bool = False,
|
|
24
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
25
|
+
) -> list[ssslm.LiteralMapping]:
|
|
26
|
+
"""Get a subset of literal mappings under the given ancestors."""
|
|
27
|
+
if isinstance(ancestors, curies.Reference):
|
|
28
|
+
ancestors = [ancestors]
|
|
29
|
+
|
|
30
|
+
subset: set[Reference] = {
|
|
31
|
+
descendant
|
|
32
|
+
for ancestor in ancestors
|
|
33
|
+
for descendant in get_descendants(ancestor, **kwargs) or []
|
|
34
|
+
}
|
|
35
|
+
return [
|
|
36
|
+
literal_mapping
|
|
37
|
+
for literal_mapping in get_literal_mappings(prefix, skip_obsolete=skip_obsolete, **kwargs)
|
|
38
|
+
if literal_mapping.reference in subset
|
|
39
|
+
]
|
pyobo/api/edges.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""High-level API for edges."""
|
|
2
|
+
|
|
3
|
+
import networkx as nx
|
|
4
|
+
import pandas as pd
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
from typing_extensions import Unpack
|
|
7
|
+
|
|
8
|
+
from pyobo.api.names import get_ids
|
|
9
|
+
from pyobo.api.utils import get_version_from_kwargs
|
|
10
|
+
from pyobo.constants import (
|
|
11
|
+
GetOntologyKwargs,
|
|
12
|
+
check_should_cache,
|
|
13
|
+
check_should_force,
|
|
14
|
+
check_should_use_tqdm,
|
|
15
|
+
)
|
|
16
|
+
from pyobo.getters import get_ontology
|
|
17
|
+
|
|
18
|
+
from ..struct import Reference
|
|
19
|
+
from ..utils.cache import cached_df
|
|
20
|
+
from ..utils.path import CacheArtifact, get_cache_path
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"get_edges",
|
|
24
|
+
"get_edges_df",
|
|
25
|
+
"get_graph",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_graph(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> nx.DiGraph:
|
|
30
|
+
"""Get the relation graph."""
|
|
31
|
+
rv = nx.MultiDiGraph()
|
|
32
|
+
for s in get_ids(prefix, **kwargs):
|
|
33
|
+
rv.add_node(f"{prefix}:{s}")
|
|
34
|
+
df = get_edges_df(prefix=prefix, **kwargs)
|
|
35
|
+
for s, p, o in df.values:
|
|
36
|
+
rv.add_edge(s, p, key=o)
|
|
37
|
+
return rv
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_edges_df(prefix, **kwargs: Unpack[GetOntologyKwargs]) -> pd.DataFrame:
|
|
41
|
+
"""Get a dataframe of edges triples."""
|
|
42
|
+
version = get_version_from_kwargs(prefix, kwargs)
|
|
43
|
+
path = get_cache_path(prefix, CacheArtifact.edges, version=version)
|
|
44
|
+
|
|
45
|
+
@cached_df(
|
|
46
|
+
path=path, dtype=str, force=check_should_force(kwargs), cache=check_should_cache(kwargs)
|
|
47
|
+
)
|
|
48
|
+
def _df_getter() -> pd.DataFrame:
|
|
49
|
+
return get_ontology(prefix, **kwargs).get_edges_df(use_tqdm=check_should_use_tqdm(kwargs))
|
|
50
|
+
|
|
51
|
+
return _df_getter()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get_edges(
|
|
55
|
+
prefix, **kwargs: Unpack[GetOntologyKwargs]
|
|
56
|
+
) -> list[tuple[Reference, Reference, Reference]]:
|
|
57
|
+
"""Get a list of edge triples."""
|
|
58
|
+
df = get_edges_df(prefix, **kwargs)
|
|
59
|
+
return [
|
|
60
|
+
(Reference.from_curie(s), Reference.from_curie(p), Reference.from_curie(o))
|
|
61
|
+
for s, p, o in tqdm(
|
|
62
|
+
df.values,
|
|
63
|
+
desc=f"[{prefix}] parsing edges",
|
|
64
|
+
unit="edge",
|
|
65
|
+
unit_scale=True,
|
|
66
|
+
disable=not check_should_use_tqdm(kwargs),
|
|
67
|
+
)
|
|
68
|
+
]
|