Skip to content

Commit

Permalink
Added another unit test to verify that 'deprecate' value is propagate…
Browse files Browse the repository at this point in the history
…d. Seems to work. Issue perhaps resolved?
  • Loading branch information
RichardBruskiewich committed Nov 7, 2023
1 parent e93c7d2 commit c132302
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 2 deletions.
53 changes: 53 additions & 0 deletions tests/resources/phenio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"graphs": [
{
"nodes": [
{
"id": "http://purl.obolibrary.org/obo/GO_0051370",
"lbl": "obsolete ZASP binding",
"type": "INDIVIDUAL",
"meta": {
"definition": {
"val": "OBSOLETE. Binding to Z-band alternatively spliced PDZ motif protein (ZASP). ZASP is a Z-band protein specifically expressed in heart and skeletal muscle. This protein contains N-terminal PDZ domain and C-terminal LIM domain.",
"xrefs": [
"PMID:10427098",
"PMID:11699871"
]
},
"comments": [
"This term was made obsolete because it represents binding to an individual protein."
],
"synonyms": [
{
"pred": "hasExactSynonym",
"val": "Z-band alternatively spliced PDZ-motif protein binding"
},
{
"pred": "hasExactSynonym",
"val": "ZASP binding"
}
],
"basicPropertyValues": [
{
"pred": "http://purl.obolibrary.org/obo/IAO_0100001",
"val": "GO:0008092"
},
{
"pred": "http://www.geneontology.org/formats/oboInOwl#hasOBONamespace",
"val": "molecular_function"
}
],
"deprecated": true
}
}
],
"edges": [],
"id": "http://purl.obolibrary.org/obo/phenio.owl",
"meta": {
"subsets": [],
"xrefs": [],
"basicPropertyValues": []
}
}
]
}
59 changes: 57 additions & 2 deletions tests/unit/test_source/test_obograph_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import pytest

from kgx.source import ObographSource
from kgx.cli import transform
from kgx.source import ObographSource, TsvSource
from kgx.transformer import Transformer
from tests import RESOURCE_DIR
from tests import RESOURCE_DIR, TARGET_DIR


def test_read_obograph1():
Expand Down Expand Up @@ -130,6 +131,29 @@ def test_read_deprecated_term():
assert n1["deprecated"] is True


def test_read_deprecated_term_phenio():
"""
Read from a Phenio JSON using ObographSource,
to validate capture of "deprecate" status
"""
t = Transformer()
s = ObographSource(t)
g = s.parse(
os.path.join(RESOURCE_DIR, "phenio.json"),
knowledge_source="Phenomics Integrative Ontology",
)
nodes = {}
for rec in g:
if rec:
if len(rec) != 4:
nodes[rec[0]] = rec[1]

n1 = nodes["GO:0051370"]
assert n1["id"] == "GO:0051370"
assert n1["name"] == "obsolete ZASP binding"
assert n1["deprecated"] is True


@pytest.mark.parametrize(
"query",
[
Expand Down Expand Up @@ -228,3 +252,34 @@ def test_error_detection():
t.write_report(None, "Error")
if len(t.get_errors("Warning")) > 0:
t.write_report(None, "Warning")


def test_phenio_obojson_to_tsv():
"""
Testing transitive propagation of node properties
(mainly node 'deprecated' status)
from a Phenio JSON to TSV file format
"""
transform(
inputs=[os.path.join(RESOURCE_DIR, "phenio.json")],
input_format="obojson",
output=os.path.join(TARGET_DIR, "phenio"),
output_format="tsv",
stream=False
)

tin = Transformer()
s = TsvSource(tin)

g = s.parse(filename=os.path.join(TARGET_DIR, "phenio_nodes.tsv"), format="tsv")

nodes = {}
for rec in g:
if rec:
if len(rec) != 4:
nodes[rec[0]] = rec[1]

n1 = nodes["GO:0051370"]
assert n1["id"] == "GO:0051370"
assert n1["name"] == "obsolete ZASP binding"
assert n1["deprecated"] is True

0 comments on commit c132302

Please sign in to comment.