Skip to content

Commit

Permalink
OMIM included & formerly refactor
Browse files Browse the repository at this point in the history
- Update: Made OMIM_INCLUDED & OMIM_FORMERLY synonymType
- Update: Renamed these to UPPER_SNAKE_CASE
- Update: Retained includedEntryInOMIM as annotation property on synonyms
- Add: Missing property declarations
- Deleted: rdfs:comment related to 'included'
- Refactor: Added abstraction: add_included_synonym()
- Add: *.obo to .gitignore. This file type will only be used ad hoc to examine outputs in .obo form.
  • Loading branch information
joeflack4 committed Jan 4, 2025
1 parent 6a68607 commit 1ab69db
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ allelicVariants.tsv

# Outputs
/*.json
/*.obo
/*.owl
/*.tsv
/*.ttl
Expand Down
54 changes: 35 additions & 19 deletions omim2obo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ def add_subclassof_restriction_with_evidence_and_source(
add_axiom_annotations(graph, on, RDFS['subClassOf'], b, annotation_pred_vals)


def add_included_synonym(graph: Graph, omim_uri: URIRef, synonym: str, is_symbol=False, is_formerly=False):
"""Add title or symbol as synonym"""
annotations = [
(oboInOwl.hasSynonymType, URIRef(MONDONS['OMIM_INCLUDED'])),
(oboInOwl.source, Literal('MONDO:includedEntryInOMIM')),
]
if is_symbol:
annotations.append((oboInOwl.hasSynonymType, OMO['0003000']))
if is_formerly:
annotations.append((oboInOwl.hasSynonymType, URIRef(MONDONS['OMIM_FORMERLY'])))
add_triple_and_optional_annotations(graph, omim_uri, oboInOwl.hasExactSynonym, synonym, annotations)


# Classes
class DeterministicBNode(BNode):
"""Overrides BNode to create a deterministic ID"""
Expand Down Expand Up @@ -201,11 +214,27 @@ def omim2obo(use_cache: bool = False):
# Populate graph
# - Non-OMIM triples
graph.add((URIRef('http://purl.obolibrary.org/obo/mondo/omim.owl'), RDF.type, OWL.Ontology))
graph.add((URIRef(oboInOwl.hasSynonymType), RDF.type, OWL.AnnotationProperty))
graph.add((URIRef(MONDONS.includedEntryInOMIM), RDF.type, OWL.AnnotationProperty))

graph.add((URIRef(oboInOwl.source), RDF.type, OWL.AnnotationProperty))
graph.add((URIRef(OMO['0003000']), RDF.type, OWL.AnnotationProperty))
graph.add((BIOLINK['has_evidence'], RDF.type, OWL.AnnotationProperty))
graph.add((URIRef(oboInOwl.SynonymTypeProperty), RDF.type, OWL.AnnotationProperty))
graph.add((URIRef(oboInOwl.hasSynonymType), RDF.type, OWL.AnnotationProperty))
# TODO: Correct? This is how looks in mondo.owl:
# <owl:AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasSynonymType">
# <owl:AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty">
graph.add((URIRef(MONDONS.includedEntryInOMIM), RDF.type, OWL.AnnotationProperty))

graph.add((URIRef(MONDONS.OMIM_INCLUDED), RDFS.subPropertyOf, oboInOwl.SynonymTypeProperty))
graph.add((URIRef(MONDONS.OMIM_FORMERLY), RDFS.subPropertyOf, oboInOwl.SynonymTypeProperty))
# TODO: Correct? Here's how MONDONS.ABBREVIATION looks in mondo.owl:
# <owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/mondo#ABBREVIATION">
# <rdfs:subPropertyOf rdf:resource="http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty"/>
# - It looks like I don't need to make a declaration that connects hasSynonymType to SynonymTypeProperty.
# And I don't see it done in https://github.com/geneontology/go-ontology/blob/master/contrib/oboInOwl.obo either;
# not sure if that's the best source to look. Maybe ontology parsers just know based on spelling conventions.
# - Surprised its not: <oboInOwl:SynonymTypeProperty rdf:about="http://purl.obolibrary.org/obo/mondo#ABBREVIATION">

graph.add((TAX_URI, RDF.type, OWL.Class))
graph.add((TAX_URI, RDFS.label, Literal(TAX_LABEL)))

Expand Down Expand Up @@ -236,7 +265,6 @@ def omim2obo(use_cache: bool = False):
get_alt_and_included_titles_and_symbols(alt_titles_str)
included_titles, included_symbols, former_included_titles, former_included_symbols = \
get_alt_and_included_titles_and_symbols(inc_titles_str)
included_is_included = included_titles or included_symbols # redundant. can't be included symbol w/out title

# Recapitalize acronyms in titles
all_abbrevs: Set[str] = \
Expand Down Expand Up @@ -291,29 +319,17 @@ def omim2obo(use_cache: bool = False):
[(OWL.deprecated, Literal(True)), (oboInOwl.hasSynonymType, OMO['0003000'])])

# Add 'included' entries
# - comment
if included_is_included:
included_comment = "This term has one or more labels that end with ', INCLUDED'."
graph.add((omim_uri, RDFS['comment'], Literal(included_comment)))
# - titles
for title in included_titles:
graph.add((omim_uri, URIRef(MONDONS.omim_included), Literal(title)))
add_included_synonym(graph, omim_uri, title)
# - symbols
for symbol in included_symbols:
add_triple_and_optional_annotations(graph, omim_uri, URIRef(MONDONS.omim_included), symbol, [
# Though these are abbreviations, MONDONS.omim_included is not a synonym type, so can't add axiom:
# (oboInOwl.hasSynonymType, OMO['0003000'])
])
add_included_synonym(graph, omim_uri, symbol, is_symbol=True)
# - deprecated, 'former'
for title in former_included_titles:
add_triple_and_optional_annotations(graph, omim_uri, URIRef(MONDONS.omim_included), title,
[(OWL.deprecated, Literal(True))])
add_included_synonym(graph, omim_uri, title, is_formerly=True)
for symbol in former_included_symbols:
add_triple_and_optional_annotations(graph, omim_uri, URIRef(MONDONS.omim_included), symbol, [
(OWL.deprecated, Literal(True)),
# Though these are abbreviations, MONDONS.omim_included is not a synonym type, so can't add axiom:
# (oboInOwl.hasSynonymType, OMO['0003000'])
])
add_included_synonym(graph, omim_uri, symbol, is_symbol=True, is_formerly=True)

# Gene ID
# Why is 'skos:exactMatch' appropriate for disease::gene relationships? - joeflack4 2022/06/06
Expand Down

0 comments on commit 1ab69db

Please sign in to comment.