pyobo 0.10.12__py3-none-any.whl → 0.11.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/__init__.py +0 -2
- pyobo/__main__.py +0 -2
- pyobo/api/__init__.py +0 -2
- pyobo/api/alts.py +6 -7
- pyobo/api/hierarchy.py +14 -15
- pyobo/api/metadata.py +3 -4
- pyobo/api/names.py +31 -32
- pyobo/api/properties.py +6 -7
- pyobo/api/relations.py +12 -11
- pyobo/api/species.py +5 -6
- pyobo/api/typedefs.py +1 -3
- pyobo/api/utils.py +61 -5
- pyobo/api/xrefs.py +4 -5
- pyobo/aws.py +3 -5
- pyobo/cli/__init__.py +0 -2
- pyobo/cli/aws.py +0 -2
- pyobo/cli/cli.py +0 -4
- pyobo/cli/database.py +1 -3
- pyobo/cli/lookup.py +0 -2
- pyobo/cli/utils.py +0 -2
- pyobo/constants.py +0 -33
- pyobo/getters.py +19 -26
- pyobo/gilda_utils.py +9 -10
- pyobo/identifier_utils.py +10 -10
- pyobo/mocks.py +5 -6
- pyobo/normalizer.py +24 -24
- pyobo/obographs.py +3 -3
- pyobo/plugins.py +3 -4
- pyobo/py.typed +0 -0
- pyobo/reader.py +19 -21
- pyobo/registries/__init__.py +0 -2
- pyobo/registries/metaregistry.py +6 -8
- pyobo/resource_utils.py +1 -3
- pyobo/resources/__init__.py +0 -2
- pyobo/resources/ncbitaxon.py +2 -3
- pyobo/resources/ro.py +2 -4
- pyobo/sources/README.md +15 -0
- pyobo/sources/__init__.py +0 -2
- pyobo/sources/agrovoc.py +3 -3
- pyobo/sources/antibodyregistry.py +2 -3
- pyobo/sources/biogrid.py +4 -4
- pyobo/sources/ccle.py +3 -4
- pyobo/sources/cgnc.py +1 -3
- pyobo/sources/chebi.py +2 -4
- pyobo/sources/chembl.py +1 -3
- pyobo/sources/civic_gene.py +2 -3
- pyobo/sources/complexportal.py +3 -5
- pyobo/sources/conso.py +2 -4
- pyobo/sources/cpt.py +1 -3
- pyobo/sources/credit.py +1 -1
- pyobo/sources/cvx.py +1 -3
- pyobo/sources/depmap.py +3 -4
- pyobo/sources/dictybase_gene.py +1 -3
- pyobo/sources/drugbank.py +6 -7
- pyobo/sources/drugbank_salt.py +3 -4
- pyobo/sources/drugcentral.py +5 -7
- pyobo/sources/expasy.py +11 -12
- pyobo/sources/famplex.py +3 -5
- pyobo/sources/flybase.py +2 -4
- pyobo/sources/geonames.py +1 -1
- pyobo/sources/gmt_utils.py +5 -6
- pyobo/sources/go.py +4 -6
- pyobo/sources/gwascentral_phenotype.py +1 -3
- pyobo/sources/gwascentral_study.py +2 -3
- pyobo/sources/hgnc.py +6 -7
- pyobo/sources/hgncgenefamily.py +2 -4
- pyobo/sources/icd10.py +3 -4
- pyobo/sources/icd11.py +3 -4
- pyobo/sources/icd_utils.py +6 -7
- pyobo/sources/interpro.py +3 -5
- pyobo/sources/itis.py +1 -3
- pyobo/sources/kegg/__init__.py +0 -2
- pyobo/sources/kegg/api.py +3 -4
- pyobo/sources/kegg/genes.py +3 -4
- pyobo/sources/kegg/genome.py +1 -3
- pyobo/sources/kegg/pathway.py +5 -6
- pyobo/sources/mesh.py +19 -21
- pyobo/sources/mgi.py +1 -3
- pyobo/sources/mirbase.py +4 -6
- pyobo/sources/mirbase_constants.py +0 -2
- pyobo/sources/mirbase_family.py +1 -3
- pyobo/sources/mirbase_mature.py +1 -3
- pyobo/sources/msigdb.py +4 -5
- pyobo/sources/ncbigene.py +3 -5
- pyobo/sources/npass.py +1 -3
- pyobo/sources/omim_ps.py +1 -3
- pyobo/sources/pathbank.py +3 -5
- pyobo/sources/pfam.py +1 -3
- pyobo/sources/pfam_clan.py +1 -3
- pyobo/sources/pid.py +3 -5
- pyobo/sources/pombase.py +1 -3
- pyobo/sources/pubchem.py +2 -3
- pyobo/sources/reactome.py +2 -4
- pyobo/sources/rgd.py +2 -3
- pyobo/sources/rhea.py +7 -8
- pyobo/sources/ror.py +3 -2
- pyobo/sources/selventa/__init__.py +0 -2
- pyobo/sources/selventa/schem.py +1 -3
- pyobo/sources/selventa/scomp.py +1 -3
- pyobo/sources/selventa/sdis.py +1 -3
- pyobo/sources/selventa/sfam.py +1 -3
- pyobo/sources/sgd.py +1 -3
- pyobo/sources/slm.py +1 -3
- pyobo/sources/umls/__init__.py +0 -2
- pyobo/sources/umls/__main__.py +0 -2
- pyobo/sources/umls/get_synonym_types.py +1 -1
- pyobo/sources/umls/umls.py +2 -4
- pyobo/sources/uniprot/__init__.py +0 -2
- pyobo/sources/uniprot/uniprot.py +4 -4
- pyobo/sources/uniprot/uniprot_ptm.py +6 -5
- pyobo/sources/utils.py +3 -5
- pyobo/sources/wikipathways.py +1 -3
- pyobo/sources/zfin.py +2 -3
- pyobo/ssg/__init__.py +3 -2
- pyobo/struct/__init__.py +0 -2
- pyobo/struct/reference.py +13 -15
- pyobo/struct/struct.py +102 -96
- pyobo/struct/typedef.py +9 -10
- pyobo/struct/utils.py +0 -2
- pyobo/utils/__init__.py +0 -2
- pyobo/utils/cache.py +14 -6
- pyobo/utils/io.py +9 -10
- pyobo/utils/iter.py +5 -6
- pyobo/utils/misc.py +1 -3
- pyobo/utils/ndex_utils.py +6 -7
- pyobo/utils/path.py +4 -5
- pyobo/version.py +3 -5
- pyobo/xrefdb/__init__.py +0 -2
- pyobo/xrefdb/canonicalizer.py +27 -18
- pyobo/xrefdb/priority.py +0 -2
- pyobo/xrefdb/sources/__init__.py +3 -4
- pyobo/xrefdb/sources/biomappings.py +0 -2
- pyobo/xrefdb/sources/cbms2019.py +0 -2
- pyobo/xrefdb/sources/chembl.py +0 -2
- pyobo/xrefdb/sources/compath.py +1 -3
- pyobo/xrefdb/sources/famplex.py +3 -5
- pyobo/xrefdb/sources/gilda.py +0 -2
- pyobo/xrefdb/sources/intact.py +5 -5
- pyobo/xrefdb/sources/ncit.py +1 -3
- pyobo/xrefdb/sources/pubchem.py +2 -5
- pyobo/xrefdb/sources/wikidata.py +2 -4
- pyobo/xrefdb/xrefs_pipeline.py +15 -16
- {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/LICENSE +1 -1
- pyobo-0.11.0.dist-info/METADATA +723 -0
- pyobo-0.11.0.dist-info/RECORD +171 -0
- {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/WHEEL +1 -1
- pyobo-0.11.0.dist-info/entry_points.txt +2 -0
- pyobo-0.10.12.dist-info/METADATA +0 -499
- pyobo-0.10.12.dist-info/RECORD +0 -169
- pyobo-0.10.12.dist-info/entry_points.txt +0 -15
- {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/top_level.txt +0 -0
pyobo/sources/mgi.py
CHANGED
pyobo/sources/mirbase.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for miRBase."""
|
|
4
2
|
|
|
5
3
|
import gzip
|
|
6
4
|
import logging
|
|
7
|
-
from
|
|
5
|
+
from collections.abc import Iterable, Mapping
|
|
8
6
|
|
|
9
7
|
from tqdm.auto import tqdm
|
|
10
8
|
|
|
@@ -48,7 +46,7 @@ def get_obo(force: bool = False) -> Obo:
|
|
|
48
46
|
return MiRBaseGetter(force=force)
|
|
49
47
|
|
|
50
48
|
|
|
51
|
-
def get_terms(version: str, force: bool = False) ->
|
|
49
|
+
def get_terms(version: str, force: bool = False) -> list[Term]:
|
|
52
50
|
"""Parse miRNA data from filepath and convert it to dictionary."""
|
|
53
51
|
_assert_frozen_version(version)
|
|
54
52
|
url = f"{BASE_URL}/miRNA.dat.gz"
|
|
@@ -77,7 +75,7 @@ def _prepare_organisms(version: str, force: bool = False):
|
|
|
77
75
|
return {division: (taxonomy_id, name) for _, division, name, _tree, taxonomy_id in df.values}
|
|
78
76
|
|
|
79
77
|
|
|
80
|
-
def _prepare_aliases(version: str, force: bool = False) -> Mapping[str,
|
|
78
|
+
def _prepare_aliases(version: str, force: bool = False) -> Mapping[str, list[str]]:
|
|
81
79
|
_assert_frozen_version(version)
|
|
82
80
|
url = f"{BASE_URL}/aliases.txt.gz"
|
|
83
81
|
df = ensure_df(PREFIX, url=url, sep="\t", version=version, force=force)
|
|
@@ -94,7 +92,7 @@ def _process_definitions_lines(
|
|
|
94
92
|
organisms = _prepare_organisms(version, force=force)
|
|
95
93
|
aliases = _prepare_aliases(version, force=force)
|
|
96
94
|
|
|
97
|
-
groups:
|
|
95
|
+
groups: list[list[str]] = []
|
|
98
96
|
|
|
99
97
|
for line in lines: # TODO replace with itertools.groupby
|
|
100
98
|
if line.startswith("ID"):
|
pyobo/sources/mirbase_family.py
CHANGED
pyobo/sources/mirbase_mature.py
CHANGED
pyobo/sources/msigdb.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Parsers for MSig."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from collections.abc import Iterable
|
|
5
|
+
from typing import Optional
|
|
8
6
|
|
|
7
|
+
from lxml.etree import ElementTree
|
|
9
8
|
from tqdm.auto import tqdm
|
|
10
9
|
|
|
11
10
|
from ..struct import Obo, Reference, Term, has_participant
|
|
@@ -137,7 +136,7 @@ def iter_terms(version: str, force: bool = False) -> Iterable[Term]:
|
|
|
137
136
|
def _get_definition(attrib) -> Optional[str]:
|
|
138
137
|
rv = attrib["DESCRIPTION_FULL"].strip() or attrib["DESCRIPTION_BRIEF"].strip() or None
|
|
139
138
|
if rv is not None:
|
|
140
|
-
return rv.replace(r"\d", "").replace(r"\s", "")
|
|
139
|
+
return rv.replace(r"\d", "").replace(r"\s", "")
|
|
141
140
|
return None
|
|
142
141
|
|
|
143
142
|
|
pyobo/sources/ncbigene.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for Entrez."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
|
-
from
|
|
4
|
+
from collections.abc import Iterable, Mapping
|
|
7
5
|
|
|
8
6
|
import bioregistry
|
|
9
7
|
import pandas as pd
|
|
@@ -47,7 +45,7 @@ GENE_INFO_COLUMNS = [
|
|
|
47
45
|
]
|
|
48
46
|
|
|
49
47
|
|
|
50
|
-
def get_ncbigene_ids() ->
|
|
48
|
+
def get_ncbigene_ids() -> set[str]:
|
|
51
49
|
"""Get the Entrez name mapping."""
|
|
52
50
|
df = _get_ncbigene_subset(["GeneID"])
|
|
53
51
|
return set(df["GeneID"])
|
|
@@ -68,7 +66,7 @@ def _get_ncbigene_info_subset(usecols) -> Mapping[str, str]:
|
|
|
68
66
|
return dict(df.values)
|
|
69
67
|
|
|
70
68
|
|
|
71
|
-
def _get_ncbigene_subset(usecols:
|
|
69
|
+
def _get_ncbigene_subset(usecols: list[str]) -> pd.DataFrame:
|
|
72
70
|
df = ensure_df(
|
|
73
71
|
PREFIX,
|
|
74
72
|
url=GENE_INFO_URL,
|
pyobo/sources/npass.py
CHANGED
pyobo/sources/omim_ps.py
CHANGED
pyobo/sources/pathbank.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for PathBank."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
4
|
from collections import defaultdict
|
|
7
|
-
from
|
|
5
|
+
from collections.abc import Iterable, Mapping
|
|
8
6
|
|
|
9
7
|
import pandas as pd
|
|
10
8
|
from tqdm.auto import tqdm
|
|
@@ -98,7 +96,7 @@ def get_proteins_df(version: str, force: bool = False) -> pd.DataFrame:
|
|
|
98
96
|
return proteins_df
|
|
99
97
|
|
|
100
98
|
|
|
101
|
-
def get_protein_mapping(version: str, force: bool = False) -> Mapping[str,
|
|
99
|
+
def get_protein_mapping(version: str, force: bool = False) -> Mapping[str, set[Reference]]:
|
|
102
100
|
"""Make the protein mapping."""
|
|
103
101
|
proteins_df = get_proteins_df(version=version, force=force)
|
|
104
102
|
smpdb_id_to_proteins = defaultdict(set)
|
|
@@ -122,7 +120,7 @@ def get_metabolite_df(version: str, force: bool = False) -> pd.DataFrame:
|
|
|
122
120
|
)
|
|
123
121
|
|
|
124
122
|
|
|
125
|
-
def get_metabolite_mapping(version: str, force: bool = False) -> Mapping[str,
|
|
123
|
+
def get_metabolite_mapping(version: str, force: bool = False) -> Mapping[str, set[Reference]]:
|
|
126
124
|
"""Make the metabolite mapping."""
|
|
127
125
|
metabolites_df = get_metabolite_df(version=version, force=force)
|
|
128
126
|
smpdb_id_to_metabolites = defaultdict(set)
|
pyobo/sources/pfam.py
CHANGED
pyobo/sources/pfam_clan.py
CHANGED
pyobo/sources/pid.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for NCI PID."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
4
|
from collections import defaultdict
|
|
7
|
-
from
|
|
5
|
+
from collections.abc import Iterable, Mapping
|
|
8
6
|
|
|
9
7
|
import pandas as pd
|
|
10
8
|
|
|
@@ -45,7 +43,7 @@ def get_obo() -> Obo:
|
|
|
45
43
|
return PIDGetter()
|
|
46
44
|
|
|
47
45
|
|
|
48
|
-
def iter_networks(use_tqdm: bool = False, force: bool = False) -> Iterable[
|
|
46
|
+
def iter_networks(use_tqdm: bool = False, force: bool = False) -> Iterable[tuple[str, CX]]:
|
|
49
47
|
"""Iterate over NCI PID networks."""
|
|
50
48
|
yield from ensure_ndex_network_set(
|
|
51
49
|
PREFIX, NDEX_NETWORK_SET_UUID, use_tqdm=use_tqdm, force=force
|
|
@@ -117,7 +115,7 @@ def get_curation_df() -> pd.DataFrame:
|
|
|
117
115
|
return df[["Text from NDEx", "Type", "Namespace", "Identifier"]]
|
|
118
116
|
|
|
119
117
|
|
|
120
|
-
def get_remapping() -> Mapping[str,
|
|
118
|
+
def get_remapping() -> Mapping[str, list[tuple[str, str]]]:
|
|
121
119
|
"""Get a mapping from text to list of HGNC id/symbols."""
|
|
122
120
|
curation_df = get_curation_df()
|
|
123
121
|
rv = defaultdict(list)
|
pyobo/sources/pombase.py
CHANGED
pyobo/sources/pubchem.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for PubChem Compound."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
|
-
from
|
|
4
|
+
from collections.abc import Iterable, Mapping
|
|
5
|
+
from typing import Optional
|
|
7
6
|
|
|
8
7
|
import pandas as pd
|
|
9
8
|
from bioregistry.utils import removeprefix
|
pyobo/sources/reactome.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for Reactome."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
4
|
from collections import defaultdict
|
|
5
|
+
from collections.abc import Iterable, Mapping
|
|
7
6
|
from functools import lru_cache
|
|
8
|
-
from typing import Iterable, Mapping, Set
|
|
9
7
|
|
|
10
8
|
import pandas as pd
|
|
11
9
|
from tqdm.auto import tqdm
|
|
@@ -122,7 +120,7 @@ def iter_terms(version: str, force: bool = False) -> Iterable[Term]:
|
|
|
122
120
|
|
|
123
121
|
|
|
124
122
|
@lru_cache(maxsize=1)
|
|
125
|
-
def get_protein_to_pathways() -> Mapping[str,
|
|
123
|
+
def get_protein_to_pathways() -> Mapping[str, set[str]]:
|
|
126
124
|
"""Get a mapping from proteins to the pathways they're in."""
|
|
127
125
|
protein_to_pathways = defaultdict(set)
|
|
128
126
|
x = get_id_multirelations_mapping("reactome", has_participant)
|
pyobo/sources/rgd.py
CHANGED
pyobo/sources/rhea.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for Rhea."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
|
-
from
|
|
4
|
+
from collections.abc import Iterable
|
|
5
|
+
from typing import TYPE_CHECKING, Optional
|
|
7
6
|
|
|
8
7
|
import pystow
|
|
9
8
|
|
|
@@ -71,7 +70,7 @@ def ensure_rhea_rdf(version: Optional[str] = None, force: bool = False) -> "rdfl
|
|
|
71
70
|
version,
|
|
72
71
|
url=RHEA_RDF_GZ_URL,
|
|
73
72
|
force=force,
|
|
74
|
-
parse_kwargs=
|
|
73
|
+
parse_kwargs={"format": "xml"},
|
|
75
74
|
)
|
|
76
75
|
|
|
77
76
|
|
|
@@ -103,10 +102,10 @@ def iter_terms(version: str, force: bool = False) -> Iterable[Term]:
|
|
|
103
102
|
)
|
|
104
103
|
names = {str(identifier): str(name) for _, identifier, name in result}
|
|
105
104
|
|
|
106
|
-
terms:
|
|
107
|
-
master_to_left:
|
|
108
|
-
master_to_right:
|
|
109
|
-
master_to_bi:
|
|
105
|
+
terms: dict[str, Term] = {}
|
|
106
|
+
master_to_left: dict[str, str] = {}
|
|
107
|
+
master_to_right: dict[str, str] = {}
|
|
108
|
+
master_to_bi: dict[str, str] = {}
|
|
110
109
|
|
|
111
110
|
directions = ensure_df(
|
|
112
111
|
PREFIX,
|
pyobo/sources/ror.py
CHANGED
|
@@ -4,7 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import zipfile
|
|
7
|
-
from
|
|
7
|
+
from collections.abc import Iterable
|
|
8
|
+
from typing import Any
|
|
8
9
|
|
|
9
10
|
import bioregistry
|
|
10
11
|
import zenodo_client
|
|
@@ -62,7 +63,7 @@ class RORGetter(Obo):
|
|
|
62
63
|
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
def __post_init__(self):
|
|
66
|
+
def __post_init__(self):
|
|
66
67
|
self.data_version, _url, _path = _get_info()
|
|
67
68
|
super().__post_init__()
|
|
68
69
|
|
pyobo/sources/selventa/schem.py
CHANGED
pyobo/sources/selventa/scomp.py
CHANGED
pyobo/sources/selventa/sdis.py
CHANGED
pyobo/sources/selventa/sfam.py
CHANGED
pyobo/sources/sgd.py
CHANGED
pyobo/sources/slm.py
CHANGED
pyobo/sources/umls/__init__.py
CHANGED
pyobo/sources/umls/__main__.py
CHANGED
pyobo/sources/umls/umls.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for UMLS.
|
|
4
2
|
|
|
5
3
|
Run with ``python -m pyobo.sources.umls``
|
|
@@ -8,7 +6,7 @@ Run with ``python -m pyobo.sources.umls``
|
|
|
8
6
|
import itertools as itt
|
|
9
7
|
import operator
|
|
10
8
|
from collections import defaultdict
|
|
11
|
-
from
|
|
9
|
+
from collections.abc import Iterable, Mapping
|
|
12
10
|
|
|
13
11
|
import bioregistry
|
|
14
12
|
import pandas as pd
|
|
@@ -67,7 +65,7 @@ def get_obo() -> Obo:
|
|
|
67
65
|
return UMLSGetter()
|
|
68
66
|
|
|
69
67
|
|
|
70
|
-
def get_semantic_types() -> Mapping[str,
|
|
68
|
+
def get_semantic_types() -> Mapping[str, set[str]]:
|
|
71
69
|
"""Get UMLS semantic types for each term."""
|
|
72
70
|
dd = defaultdict(set)
|
|
73
71
|
with open_umls_semantic_types() as file:
|
pyobo/sources/uniprot/uniprot.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for UniProt."""
|
|
4
2
|
|
|
3
|
+
from collections.abc import Iterable
|
|
5
4
|
from operator import attrgetter
|
|
6
5
|
from pathlib import Path
|
|
7
|
-
from typing import
|
|
6
|
+
from typing import Optional, cast
|
|
8
7
|
|
|
9
8
|
from tqdm.auto import tqdm
|
|
10
9
|
|
|
@@ -57,6 +56,7 @@ class UniProtGetter(Obo):
|
|
|
57
56
|
gene_product_of,
|
|
58
57
|
molecularly_interacts_with,
|
|
59
58
|
derives_from,
|
|
59
|
+
located_in,
|
|
60
60
|
]
|
|
61
61
|
|
|
62
62
|
def iter_terms(self, force: bool = False) -> Iterable[Term]:
|
|
@@ -154,7 +154,7 @@ def iter_terms(version: Optional[str] = None) -> Iterable[Term]:
|
|
|
154
154
|
yield term
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
def _parse_go(go_terms) ->
|
|
157
|
+
def _parse_go(go_terms) -> list[Reference]:
|
|
158
158
|
rv = []
|
|
159
159
|
if go_terms:
|
|
160
160
|
for go_term in go_terms.split(";"):
|
|
@@ -27,7 +27,8 @@ DR Cross-reference to external Optional; once or more
|
|
|
27
27
|
|
|
28
28
|
import itertools as itt
|
|
29
29
|
from collections import defaultdict
|
|
30
|
-
from
|
|
30
|
+
from collections.abc import Iterable, Mapping
|
|
31
|
+
from typing import Optional
|
|
31
32
|
|
|
32
33
|
from tqdm.auto import tqdm
|
|
33
34
|
|
|
@@ -63,18 +64,18 @@ def iter_terms(force: bool = False) -> Iterable[Term]:
|
|
|
63
64
|
path = ensure_path(PREFIX, url=URL, force=force)
|
|
64
65
|
with open(path) as file:
|
|
65
66
|
lines = list(file)
|
|
66
|
-
it: Iterable[
|
|
67
|
+
it: Iterable[tuple[str, str]] = ((line[:2], line[2:].strip()) for line in lines[47:-5])
|
|
67
68
|
for i, (_, term_lines) in enumerate(itt.groupby(it, key=lambda p: p[0] == "//")):
|
|
68
69
|
term = _parse(i, term_lines)
|
|
69
70
|
if term:
|
|
70
71
|
yield term
|
|
71
72
|
|
|
72
73
|
|
|
73
|
-
def _parse(i, lines: Iterable[
|
|
74
|
-
dd_:
|
|
74
|
+
def _parse(i, lines: Iterable[tuple[str, str]]) -> Optional[Term]:
|
|
75
|
+
dd_: defaultdict[str, list[str]] = defaultdict(list)
|
|
75
76
|
for key, value in lines:
|
|
76
77
|
dd_[key].append(value)
|
|
77
|
-
dd: Mapping[str,
|
|
78
|
+
dd: Mapping[str, list[str]] = dict(dd_)
|
|
78
79
|
|
|
79
80
|
if "//" in dd:
|
|
80
81
|
return None
|
pyobo/sources/utils.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Utilities for converters."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
|
-
from
|
|
4
|
+
from collections.abc import Mapping
|
|
7
5
|
|
|
8
6
|
from ..utils.io import multisetdict
|
|
9
7
|
|
|
@@ -15,7 +13,7 @@ __all__ = [
|
|
|
15
13
|
logger = logging.getLogger(__name__)
|
|
16
14
|
|
|
17
15
|
|
|
18
|
-
def get_go_mapping(path: str, prefix: str) -> Mapping[str,
|
|
16
|
+
def get_go_mapping(path: str, prefix: str) -> Mapping[str, set[tuple[str, str]]]:
|
|
19
17
|
"""Get a GO mapping file."""
|
|
20
18
|
with open(path) as file:
|
|
21
19
|
return multisetdict(
|
|
@@ -23,7 +21,7 @@ def get_go_mapping(path: str, prefix: str) -> Mapping[str, Set[Tuple[str, str]]]
|
|
|
23
21
|
)
|
|
24
22
|
|
|
25
23
|
|
|
26
|
-
def process_go_mapping_line(line: str, prefix: str) ->
|
|
24
|
+
def process_go_mapping_line(line: str, prefix: str) -> tuple[str, tuple[str, str]]:
|
|
27
25
|
"""Process a GO mapping line."""
|
|
28
26
|
line1 = line[len(f"{prefix}:") :]
|
|
29
27
|
line2, go_id = line1.rsplit(";", 1)
|
pyobo/sources/wikipathways.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
1
|
"""Converter for WikiPathways."""
|
|
4
2
|
|
|
5
3
|
import logging
|
|
6
4
|
import urllib.error
|
|
7
|
-
from
|
|
5
|
+
from collections.abc import Iterable
|
|
8
6
|
|
|
9
7
|
from .gmt_utils import parse_wikipathways_gmt
|
|
10
8
|
from ..constants import SPECIES_REMAPPING
|
pyobo/sources/zfin.py
CHANGED
pyobo/ssg/__init__.py
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import itertools as itt
|
|
4
4
|
from collections import defaultdict
|
|
5
|
+
from collections.abc import Sequence
|
|
5
6
|
from operator import attrgetter
|
|
6
7
|
from pathlib import Path
|
|
7
|
-
from typing import Optional,
|
|
8
|
+
from typing import Optional, Union
|
|
8
9
|
|
|
9
10
|
import bioregistry
|
|
10
11
|
from bioregistry.constants import BIOREGISTRY_DEFAULT_BASE_URL
|
|
@@ -37,7 +38,7 @@ def make_site(
|
|
|
37
38
|
metaregistry_metaprefix: Optional[str] = None,
|
|
38
39
|
metaregistry_name: Optional[str] = None,
|
|
39
40
|
metaregistry_base_url: Optional[str] = None,
|
|
40
|
-
show_properties_in_manifest: Optional[Sequence[
|
|
41
|
+
show_properties_in_manifest: Optional[Sequence[tuple[str, str]]] = None,
|
|
41
42
|
) -> None:
|
|
42
43
|
"""Make a website in the given directory.
|
|
43
44
|
|