Skip to content

Commit

Permalink
add biolink subset test separte from other example tests for ease of …
Browse files Browse the repository at this point in the history
…teaching
  • Loading branch information
sierra-moxon committed Nov 13, 2024
1 parent 1ed75a2 commit aed82cf
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/test_transformer/test_biolink_subsetting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from pathlib import Path
from linkml_runtime.dumpers import yaml_dumper
import pytest
from pprint import pprint
from linkml_map.datamodel.transformer_model import TransformationSpecification
from linkml_map.inference.schema_mapper import SchemaMapper
from linkml_map.session import Session
from linkml_runtime.utils.schemaview import SchemaView
from src.linkml_map.utils.loaders import load_specification
from linkml_map.transformer.transformer import Transformer
from linkml_map.utils.multi_file_transformer import Transformation




def test_biolink_subsetting():
# Test that the subsetting of the Biolink Model is correct
# This test is a placeholder and should be replaced with a real test
repo_root = Path(__file__).resolve().parent.parent
schema_url = "https://raw.githubusercontent.com/biolink/biolink-model/master/biolink-model.yaml"
sv = SchemaView(schema_url)

transform_file = repo_root / "input/examples/biolink/transform/biolink-example-profile.transform.yaml"
# Initialize Session and SchemaBuilder
session = Session()

# Set the source schema in the session
session.set_source_schema(sv)

SUBSET_CLASSES = ["gene",
"disease",
"case to phenotypic feature association",
"gene to disease association",
"gene to phenotypic feature association",
"case",
"phenotypic feature",
]


tr_spec = load_specification(transform_file)
mapper = SchemaMapper()
mapper.source_schemaview = sv

target_schema_obj = mapper.derive_schema(specification=tr_spec,
target_schema_id="biolink-profile",
target_schema_name="BiolinkProfile")

yaml_dumper.dump(target_schema_obj, str("biolink-profile.yaml"))

0 comments on commit aed82cf

Please sign in to comment.