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

Integration tests update #22

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions semDiff/mergeEntities.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ def modify_references(self):

for reference in look_for:
if reference in field['items']:

sub_item_iterator = 0
for sub_item in field['items'][reference]:
if '$ref' in sub_item:
field_ref = sub_item['$ref']
field_ref = sub_item['$ref'].replace('#', '')

if field_ref in self.name_mapping:
print(field_ref)
print(self.output['schemas'][schema]['properties'])
self.output['schemas'][schema]['properties'][
reference]['items'][
item]['items'][reference][
sub_item_iterator]['$ref'] = \
self.name_mapping[field_ref] + "#"
sub_item_iterator += 1
Expand Down
11 changes: 10 additions & 1 deletion source/API/apiClient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ The JSONLDschema package offers and API client that provides most of the library
Here we include the documentation of each of the Python classes and properties for the API client.


API client
-------------------------------------------


.. image:: ../_static/classes_api_client.png

.. automodule:: client
:members:
:noindex:


---------------
API utilities
-------------------------------------------


.. image:: ../_static/classes_api_utility.png

.. automodule:: utility
:members:
1 change: 1 addition & 0 deletions source/cedar/cedarIndex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CEDAR Templating Tools

Cedar utilities
-------------------------------------------

.. toctree::
cedarUtilities

Expand Down
12 changes: 9 additions & 3 deletions source/cedar/cedarUtilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ Code documentation for the CEDAR utilities
=============================================


The CEDAR client will provide all the links the the CEDAR API functionality such as get, post and updates on templates,
template elements, folders, instances ect ...
The CEDAR client provides all the links the the CEDAR API functionality such as GET, POST and updates on templates,
template elements, folders, instances, and so on.



.. image:: ../_static/classes_cedar_client.png

.. automodule:: client
:members:

---------------

The schema2cedar classes will help you transform your JSON schemas draft 04 into compatible CEDAR schemas

The schema2cedar classes will help you transform your JSON schemas draft-04 into compatible CEDAR schemas, which can be visualised on the CEDAR Workbench tool.

.. image:: ../_static/classes_cedar_schema2cedar.png

.. automodule:: schema2cedar
:members:
Expand Down
2 changes: 1 addition & 1 deletion source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Welcome to jsonldschema's documentation!
========================================

The JSONLDschema python package offers functionality to support the creation and use of machine-actionable and FAIR (Findable, Accessible, Interoperable and Reusable) metadata models expressed as `JSON-schemas <https://json-schema.org/>`_ for `JSON-LD <http://json-ld.org/>`_ data.
The JSONLDschema python package offers functionality to support the creation and use of machine-actionable and FAIR (Findable, Accessible, Interoperable and Reusable) metadata models expressed as `JSON-schemas <https://json-schema.org/>`_ to generate `JSON-LD <http://json-ld.org/>`_ data.

The approach relies on representing the metadata models as JSON-schemas with additional JSON-LD context files to provide semantic annotations to the model.

Expand Down
17 changes: 17 additions & 0 deletions source/semDiff/semanticComparator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
How to compare and merge set of JSON-LD-schemas: code documentation
====================================================================


Compare entities
-------------------------------------------

.. image:: ../_static/classes_semDiff_compareEntities.png

.. automodule:: compareEntities
:members:
:private-members:
:special-members:


Compare network
-------------------------------------------


.. image:: ../_static/classes_semDiff_compareNetwork.png

.. automodule:: compareNetwork
Expand All @@ -17,13 +26,21 @@ How to compare and merge set of JSON-LD-schemas: code documentation
:special-members:


Full difference
-------------------------------------------


.. image:: ../_static/classes_semDiff_fullDiff.png

.. automodule:: fullDiff
:members:
:private-members:
:special-members:


Merge entities
-------------------------------------------

.. image:: ../_static/classes_semDiff_mergeEntities.png

.. automodule:: mergeEntities
Expand Down
3 changes: 3 additions & 0 deletions source/validation/validationUtilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ How to validate JSON-schemas and instances: code documentation
.. automodule:: miflowcyt_validate
:members:


.. image:: ../_static/classes_validate_miflowcyt_validate.png

.. autoclass:: FlowRepoClient
:members:
6 changes: 3 additions & 3 deletions tests/fullDiffOutput/merges/example_merge.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"items": {
"anyOf": [
{
"$ref": "test1_second_schema.json#"
"$ref": "test1_second_test2_second_merged_schema.json#"
},
{
"$ref": "test1_third_schema.json#"
Expand All @@ -67,10 +67,10 @@
"items": {
"anyOf": [
{
"$ref": "test2_second_schema.json#"
"$ref": "test1_second_test2_second_merged_schema.json#"
},
{
"$ref": "third_schema.json#"
"$ref": "third_merged_schema.json#"
}
]
}
Expand Down
32 changes: 20 additions & 12 deletions tests/integration/make_fulldiff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from semDiff.fullDiff import FullDiffGenerator
import multiprocessing


output_base_path = os.path.join(os.path.dirname(__file__), "../fullDiffOutput/")
Expand All @@ -25,9 +26,9 @@ def make_diff(network1, network2):
MIACA_schema_url = "https://w3id.org/mircat/miaca/schema/miaca_schema.json"
MyFlowCyt_schema_url = "https://w3id.org/mircat/miflowcyt/schema/miflowcyt_schema.json"
MIACA_MIACME_merge_schema_url = \
"https://w3id.org/mircat/miaca_miacme_merge/schema/miaca_schema.json"
"https://w3id.org/mircat/miaca_miacme_merge/schema/miaca_miacme_merged_schema.json"
MIACME_MIACA_merge_schem_url = \
"https://w3id.org/mircat/miacme_miaca_merge/schema/miacme_schema.json"
"https://w3id.org/mircat/miacme_miaca_merge/schema/miacme_miaca_merged_schema.json"

regex = {
"/schema": "/context/obo",
Expand Down Expand Up @@ -55,24 +56,31 @@ def make_diff(network1, network2):
"regex": regex,
"url": MyFlowCyt_schema_url
}

MIACA_MIACME_merge_network = {
"name": "MIACA_MIACME_merge",
"regex": regex2,
"url": MIACA_MIACME_merge_schema_url
}

make_diff(MIACA_network, MIACA_network)
make_diff(MIACA_network, MyFlowCyt_network)
make_diff(MIACA_network, MIACME_network)
processes = [
(MIACA_network, MIACME_network),
(MIACA_network, MyFlowCyt_network),
(MIACA_network, MIACA_network),

(MIACME_network, MIACME_network),
(MIACME_network, MyFlowCyt_network),
(MIACME_network, MIACA_network),

(MyFlowCyt_network, MIACME_network),
(MyFlowCyt_network, MyFlowCyt_network),
(MyFlowCyt_network, MIACA_network)
]

make_diff(MIACME_network, MIACME_network)
make_diff(MIACME_network, MyFlowCyt_network)
make_diff(MIACME_network, MIACA_network)
cpu_count = multiprocessing.cpu_count()
p = multiprocessing.Pool(processes=cpu_count)
result = [p.apply_async(make_diff, args=(x, y)) for (x, y) in processes]

make_diff(MyFlowCyt_network, MyFlowCyt_network)
make_diff(MyFlowCyt_network, MIACME_network)
make_diff(MyFlowCyt_network, MIACA_network)
output = [pp.get() for pp in result]

make_diff(MIACA_MIACME_merge_network, MIACA_network)
make_diff(MIACA_network, MIACA_MIACME_merge_network)
68 changes: 56 additions & 12 deletions tests/integration/test_schema2context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
prepare_input,
create_and_save_contexts,
generate_context_mapping_dict,
generate_labels_from_contexts,
json
)


class TestSchema2Context(unittest.TestCase):

input = dict({
"MIACME": {
"schema_url": "https://w3id.org/mircat/miacme/schema/miacme_schema.json"
},
"MIACA": {
"schema_url": "https://w3id.org/mircat/miaca/schema/miaca_schema.json"
},
"MIFlowCyt": {
"schema_url": "https://w3id.org/mircat/miflowcyt/schema/miflowcyt_schema.json"
}
"MIACME": {
"schema_url": "https://w3id.org/mircat/miacme/schema/miacme_schema.json"
},
"MIACA": {
"schema_url": "https://w3id.org/mircat/miaca/schema/miaca_schema.json"
},
"MIFlowCyt": {
"schema_url": "https://w3id.org/mircat/miflowcyt/schema/miflowcyt_schema.json"
}
})

base = {
Expand Down Expand Up @@ -49,8 +49,52 @@ def test_create_and_save_contexts(self):
def test_generate_mapping_dict(self):
for key in self.input:
mapping, errors = generate_context_mapping_dict(
self.input[key]["schema_url"],
self.regexes, key)
self.input[key]["schema_url"],
self.regexes, key)
print(json.dumps(mapping, indent=4))
print(errors)
self.assertTrue(mapping["networkName"] == key)

def test_generate_labels_from_contexts_1(self):
labels = {}
contexts = {
"cell_line_obo_context.jsonld": {
"@context": {
"obo": "http://purl.obolibrary.org/obo/",
"CellLine": "obo:CLO_0000031",
"@language": "en",
"ID": "obo:IAO_0000578",
"lineQC": "obo:ERO_0001219",
"validation": "obo:ERO_0002025",
"cellLineName": "obo:IAO_0000590",
"modifications": "obo:CLO_0000004",
"passageNo": "obo:EFO_0007061",
"cellSource": "obo:CL_0000000"
}
}
}
generate_labels_from_contexts(contexts, labels)
print(labels)

def test_generate_labels_from_contexts_2(self):
labels = {}
contexts = {
"@context": {
"obo": "http://purl.obolibrary.org/obo/",
"bao": "http://www.bioassayontology.org/bao#",
"ImagingCondition": "obo:FBbi_root_00000000",
"@language": "en",
"timeSeriesInterval": "obo:IAO_0000584",
"imageSequenceType": "obo:NCIT_C69268",
"pixels": "obo:NCIT_C48367",
"observationPeriod": "obo:NCIT_C25616",
"numericalAperture": "obo:NCIT_C44175",
"observationPeriodUnit": "obo:UO_0000003",
"objectiveLens": "obo:ERO_0000453",
"modality": "obo:FBbi_00000222",
"channelDefinition": "bao:BAO_0000184",
"timeSeriesIntervalUnit": "obo:UO_0000003"
}
}
generate_labels_from_contexts(contexts, labels)
print(labels)