From 7d80152930be7e67a63ee648f9a0b0ac56c3dbce Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Thu, 14 Nov 2024 10:33:08 -0800 Subject: [PATCH] lint --- .../test_biolink_subsetting.py | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/tests/test_transformer/test_biolink_subsetting.py b/tests/test_transformer/test_biolink_subsetting.py index 69d140d..3a15fc6 100644 --- a/tests/test_transformer/test_biolink_subsetting.py +++ b/tests/test_transformer/test_biolink_subsetting.py @@ -1,16 +1,20 @@ from pathlib import Path +from pprint import pprint from typing import List +from linkml_runtime.dumpers import yaml_dumper +from linkml_runtime.utils.formatutils import camelcase, underscore +from linkml_runtime.utils.schemaview import SchemaView from pytest import fixture -from linkml_runtime.dumpers import yaml_dumper -from linkml_map.datamodel.transformer_model import TransformationSpecification, ClassDerivation, SlotDerivation +from linkml_map.datamodel.transformer_model import ( + ClassDerivation, + SlotDerivation, + 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_runtime.utils.formatutils import camelcase, underscore -from pprint import pprint REPO_ROOT = Path(__file__).resolve().parent.parent @@ -25,10 +29,9 @@ def get_biolink_class_derivations(sv, subset_classes) -> dict: """ # Example implementation to fetch class definitions # This should be replaced with the actual implementation - class_derivations ={} + class_derivations = {} for class_name in subset_classes: - class_derivation = ClassDerivation(populated_from=class_name, - name=camelcase(class_name)) + class_derivation = ClassDerivation(populated_from=class_name, name=camelcase(class_name)) induced_slots = sv.class_induced_slots(class_name) for slot in induced_slots: slot_derivation = SlotDerivation(populated_from=slot.name, name=underscore(slot.name)) @@ -49,13 +52,16 @@ def biolink_schema(): sv = SchemaView(schema_url) return sv + def test_biolink_subsetting_manual(biolink_schema): """ Test to subset the Biolink schema manually :param biolink_schema: Fixture to load Biolink schema """ - transform_file = REPO_ROOT / "input/examples/biolink/transform/biolink-example-profile.transform.yaml" + transform_file = ( + REPO_ROOT / "input/examples/biolink/transform/biolink-example-profile.transform.yaml" + ) # Initialize Session and SchemaBuilder session = Session() @@ -66,10 +72,11 @@ def test_biolink_subsetting_manual(biolink_schema): mapper = SchemaMapper() mapper.source_schemaview = biolink_schema - target_schema_obj = mapper.derive_schema(specification=tr_spec, - target_schema_id="biolink-profile", - target_schema_name="BiolinkProfile") - + 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")) @@ -95,14 +102,15 @@ def test_biolink_subset_auto(biolink_schema): # Set the source schema in the session session.set_source_schema(biolink_schema) - SUBSET_CLASSES = ["gene", - "disease", - "case to phenotypic feature association", - "gene to disease association", - "gene to phenotypic feature association", - "case", - "phenotypic feature", - ] + SUBSET_CLASSES = [ + "gene", + "disease", + "case to phenotypic feature association", + "gene to disease association", + "gene to phenotypic feature association", + "case", + "phenotypic feature", + ] class_derivations = get_biolink_class_derivations(biolink_schema, SUBSET_CLASSES) @@ -111,9 +119,9 @@ def test_biolink_subset_auto(biolink_schema): mapper = SchemaMapper() mapper.source_schemaview = biolink_schema - target_schema_obj = mapper.derive_schema(specification=ts, - target_schema_id="biolink-profile", - target_schema_name="BiolinkProfile") + target_schema_obj = mapper.derive_schema( + specification=ts, target_schema_id="biolink-profile", target_schema_name="BiolinkProfile" + ) yaml_dumper.dump(target_schema_obj, str("biolink-subset.yaml")) @@ -124,5 +132,3 @@ def test_biolink_subset_auto(biolink_schema): print() for slot_name in transformed_sv.all_slots(): print(slot_name) - -