-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathgenerate_vaccine_mappings.py
More file actions
46 lines (39 loc) · 1.54 KB
/
generate_vaccine_mappings.py
File metadata and controls
46 lines (39 loc) · 1.54 KB
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
"""Generate vaccine mappings."""
import click
import pyobo
import ssslm
from bioregistry import NormalizedNamableReference
from curies.vocabulary import exact_match, lexical_matching_process
from pyobo.sources.cpt import iter_terms
from sssom_pydantic import MappingTool, SemanticMapping
from biomappings import append_lexical_predictions
from biomappings.resources import append_predictions
from biomappings.utils import get_script_url
@click.command()
def main() -> None:
"""Generate vaccine mappings."""
provenance = get_script_url(__file__)
append_lexical_predictions("cvx", ["mesh", "cpt", "vo"], mapping_tool=provenance)
append_lexical_predictions("cpt", ["mesh", "vo"], mapping_tool=provenance)
preds = []
grounder: ssslm.Grounder[NormalizedNamableReference] = pyobo.get_grounder(
["mesh", "vo"], versions=["2023", None]
)
for term in iter_terms():
texts = [term.name, *(s.name for s in term.synonyms)]
for text in texts:
if not text:
continue
for scored_match in grounder.get_matches(text + " vaccine"):
pred = SemanticMapping(
subject=term.reference,
predicate=exact_match,
object=scored_match.reference,
justification=lexical_matching_process,
confidence=0.9,
mapping_tool=MappingTool(name=provenance),
)
preds.append(pred)
append_predictions(preds)
if __name__ == "__main__":
main()