-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathkegg_mappings.py
38 lines (30 loc) · 1.22 KB
/
kegg_mappings.py
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
"""Generate mappings to Gilda from given PyOBO prefixes."""
from collections.abc import Iterable
import gilda
import gilda.grounder
from pyobo.sources.kegg.api import ensure_list_pathways
from tqdm import tqdm
from biomappings.resources import PredictionTuple, append_prediction_tuples
from biomappings.utils import get_script_url
def iterate_kegg_matches() -> Iterable[PredictionTuple]:
"""Iterate over predictions from KEGG Pathways to GO and MeSH."""
provenance = get_script_url(__file__)
id_name_mapping = ensure_list_pathways()
for identifier, name in tqdm(id_name_mapping.items(), desc="Mapping KEGG Pathways"):
for scored_match in gilda.ground(name):
if scored_match.term.db.lower() not in {"go", "mesh"}:
continue
yield (
"kegg.pathway",
identifier,
name,
"skos:exactMatch",
scored_match.term.db.lower(),
scored_match.term.id,
scored_match.term.entry_name,
"semapv:LexicalMatching",
scored_match.score,
provenance,
)
if __name__ == "__main__":
append_prediction_tuples(iterate_kegg_matches())