Skip to content

Commit

Permalink
Merge pull request #2 from Knowledge-Graph-Hub/schema_and_test_tweaks
Browse files Browse the repository at this point in the history
minor changes to schema and test merge.yaml to get a passing test
  • Loading branch information
hrshdhgd authored Aug 6, 2024
2 parents c76f7d3 + 976faae commit 5177ead
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kg_microbe_merge/schema/merge_datamodel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Auto generated from merge_schema.yaml by pythongen.py version: 0.0.1
# Generation date: 2024-08-05T20:11:15
# Generation date: 2024-08-06T07:55:55
# Schema: KGMergeSchema
#
# id: http://example.org/kg-merge-schema
Expand Down
6 changes: 2 additions & 4 deletions kg_microbe_merge/schema/merge_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ classes:
description: Source graphs to be merged
multivalued: true
range: SourceGraph
inlined_as_list: true
operations:
description: Operations to perform on the merged graph
range: Operations
Expand All @@ -64,7 +65,7 @@ classes:
input:
description: Input files for the source graph
range: InputFiles

InputFiles:
description: Input files for the source graph
attributes:
Expand All @@ -73,7 +74,6 @@ classes:
filename:
description: List of filenames for the input files
multivalued: true
inlined_as_list: true

Operations:
description: Details of an operation to perform on the merged graph
Expand All @@ -94,11 +94,9 @@ classes:
node_facet_properties:
description: List of node facet properties
multivalued: true
inlined_as_list: true
edge_facet_properties:
description: List of edge facet properties
multivalued: true
inlined_as_list: true

Destination:
description: Details of a destination for the merged graph
Expand Down
53 changes: 53 additions & 0 deletions tests/data/test_merge_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
configuration:
output_directory: data/merged
checkpoint: false
curie_map:
# define non-canonical CURIE to IRI mappings (for RDF)
node_properties:
# define predicates that are to be treated as direct node properties (for RDF)
predicate_mappings:
# map non-canonical predicates to a property name (for RDF)
property_types:
# define the type for non-canonical properties for RDF export

merged_graph:
name: kg-microbe graph
source:
- name: "NCBITaxon"
input:
format: tsv
filename:
- data/transformed/ontologies/ncbitaxon_nodes.tsv
- data/transformed/ontologies/ncbitaxon_edges.tsv
- name: "CHEBI"
input:
format: tsv
filename:
- data/transformed/ontologies/chebi_nodes.tsv
- data/transformed/ontologies/chebi_edges.tsv
- name: "ENVO"
input:
format: tsv
filename:
- data/transformed/ontologies/envo_nodes.tsv
- data/transformed/ontologies/envo_edges.tsv
- name: "GO"
input:
format: tsv
filename:
- data/transformed/ontologies/go_nodes.tsv
- data/transformed/ontologies/go_edges.tsv
operations:
- name: kgx.graph_operations.summarize_graph.generate_graph_stats
args:
graph_name: kg-microbe graph
filename: merged_graph_stats.yaml
node_facet_properties:
- provided_by
edge_facet_properties:
- provided_by
- source
destination:
- format: tsv
compression: tar.gz
filename: merged-kg
22 changes: 22 additions & 0 deletions tests/test_merge_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Data test."""
import os
import glob
import unittest

from linkml_runtime.loaders import yaml_loader
from kg_microbe_merge.schema.merge_datamodel import MergeKG

ROOT = os.path.join(os.path.dirname(__file__), '..')
DATA_DIR = os.path.join(ROOT, "tests", "data")

EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR, 'test_merge_schema.yaml'))


class TestData(unittest.TestCase):
"""Test data and datamodel."""

def test_data(self):
"""Data test."""
for path in EXAMPLE_FILES:
obj = yaml_loader.load(path, target_class=MergeKG)
assert obj

0 comments on commit 5177ead

Please sign in to comment.