Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

included / formerly refactor #167

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions omim2obo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ 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):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several important changes

Trying to to open threads often. But I felt these were really important changes I should mention here.

Nico though it made sense for OMIM_INCLUDED and OMIM_FORMERLY to be synonym types, and Trish and I have started to discuss at meetings but haven't had time to fully dive in. If these changes are too much, I can undo.

  1. These are synonym types now
  2. The spelling/caps are now different
  3. If they are synonym types, that means I need to be adding synonyms for OMIM_INCLUDED, which we weren't doing before. This is kind of a major change. I chose hasRelatedSynonym.
  4. owl:deprecated was being added for OMIM_FORMERLY now I think does not make sense to add to hasRelatedSynonym, so I removed it. We could also use MONDO:DEPRECATED, but I think that maybe OIMIM_FORMERLY stands on its own for explanation and might not need any additional annotations.

"""Add title or symbol as synonym"""
annotations = [
(oboInOwl.hasSynonymType, URIRef(MONDONS['OMIM_INCLUDED'])),
]
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.hasRelatedSynonym, synonym, annotations)


# Classes
class DeterministicBNode(BNode):
"""Overrides BNode to create a deterministic ID"""
Expand Down Expand Up @@ -201,11 +213,15 @@ 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(oboInOwl.source), RDF.type, OWL.AnnotationProperty))
graph.add((URIRef(MONDONS.omim_included), 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))
graph.add((URIRef(MONDONS.OMIM_INCLUDED), RDFS.subPropertyOf, oboInOwl.SynonymTypeProperty))
graph.add((URIRef(MONDONS.OMIM_FORMERLY), RDFS.subPropertyOf, oboInOwl.SynonymTypeProperty))

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

Expand Down Expand Up @@ -236,7 +252,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 +306,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