Skip to content

Commit

Permalink
added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstenBreuer committed Dec 7, 2023
1 parent f262586 commit 3e9918e
Show file tree
Hide file tree
Showing 22 changed files with 549 additions and 54 deletions.
3 changes: 2 additions & 1 deletion tests/schemapack_/fixtures/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def _get_example_data(name: str) -> DataPack:
return load_datapack(EXAMPLE_DATA_DIR / f"{name}.datapack.yaml")


VALID_MINIMAL_DATA = _get_example_data("valid_minimal")
MINIMAL_DATA = _get_example_data("minimal")
ADVANCED_DATA = _get_example_data("advanced")
INVALID_MINIMAL_DATA = _get_example_data("invalid_minimal")
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "A dataset that is a collection of files.",
"properties": {
"alias": {
"type": "string"
},
"dac_contact": {
"type": "string"
}
},
"required": [
"alias"
],
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "An experiment containing one or multiple samples.",
"properties": {
"alias": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"alias"
],
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "A file is an object that contains information generated from a process, either an Experiment or an Analysis.",
"properties": {
"alias": {
"type": "string"
},
"checksum": {
"type": "string"
},
"filename": {
"type": "string"
},
"format": {
"type": "string"
},
"size": {
"type": "integer"
}
},
"required": [
"alias",
"filename",
"format",
"checksum",
"size"
],
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "A sample used to generate files in the context of an experiment.",
"properties": {
"alias": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"alias"
],
"type": "object"
}
56 changes: 56 additions & 0 deletions tests/schemapack_/fixtures/example_data/advanced.datapack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
datapack: 0.1.0
resources:
File:
file_a:
content:
alias: file_a
filename: file_a.fastq
format: FASTQ
checksum: 1a5ac10ab42911dc0224172c118a326d9a4c03969112a2f3eb1ad971e96e92b8
size: 12321
file_b:
content:
alias: file_b
filename: file_b.fastq
format: FASTQ
checksum: 2b5ac10ab42911dc0224172c118a326d9a4c03969112a2f3eb1ad971e96e92c9
size: 12314
file_c:
content:
alias: file_c
filename: file_c.fastq
format: FASTQ
checksum: a9c24870071da03f78515e6197048f3a2172e90e597e9250cd01a0cb8f0986ed
size: 12123
Dataset:
dataset_1:
content:
alias: dataset_1
dac_contact: dac@example.org
relations:
files:
- file_a
- file_b
- file_c
Sample:
sample_x:
content:
alias: sample_x
relations:
files:
- file_a
- file_b
sample_y:
content:
alias: sample_y
relations:
files:
- file_c
Experiment:
experiment_i:
content:
alias: experiment_i
relations:
samples:
- sample_x
- sample_y
31 changes: 31 additions & 0 deletions tests/schemapack_/fixtures/example_models/advanced.schemapack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# a simple schemapack with the content schemas being embedded
schemapack: 0.1.0
classes:
File:
id:
from_content: alias
content: ../example_content_schemas/File.schema.json
Dataset:
id:
from_content: alias
content: ../example_content_schemas/Dataset.schema.json
relations:
files:
to: File
cardinality: many_to_many
Sample:
id:
from_content: alias
content: ../example_content_schemas/Sample.schema.json
relations:
files:
to: File
cardinality: one_to_many
Experiment:
id:
from_content: alias
content: ../example_content_schemas/Experiment.schema.json
relations:
samples:
to: Sample
cardinality: one_to_many
38 changes: 2 additions & 36 deletions tests/schemapack_/fixtures/example_models/minimal.schemapack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,11 @@ classes:
File:
id:
from_content: alias
content:
"$schema": "http://json-schema.org/draft-07/schema#"
additionalProperties: false
description: A file is an object that contains information generated from a process,
either an Experiment or an Analysis.
properties:
alias:
type: string
checksum:
type: string
filename:
type: string
format:
type: string
size:
type: integer
required:
- alias
- filename
- format
- checksum
- size
type: object
content: ../example_content_schemas/File.schema.json
Dataset:
id:
from_content: alias
content:
"$schema": "http://json-schema.org/draft-07/schema#"
additionalProperties: false
description: A dataset that is a collection of files.
properties:
alias:
type: string
dac_contact:
type: string
required:
- alias
type: object

content: ../example_content_schemas/Dataset.schema.json
relations:
files:
to: File
Expand Down
33 changes: 33 additions & 0 deletions tests/schemapack_/fixtures/example_transformations/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
for the German Human Genome-Phenome Archive (GHGA)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

This directory contains test cases for testing builtin transformation.

Names of sub-directories correspond to the transformation names.
Each sub-sub-directory represents a test case.
A test case is defined by following four files:
- `config.yaml` - the transformation config
- `input.datapack.yaml` - the input data for this transformation, if not present,
the [../example_data/advanced.datapack.yaml](../example_data/advanced.datapack.yaml)
is used
- `input.schemapack.yaml` - the model for the input data, if not present,
the
[../example_models/advanced.schemapack.yaml](../example_models/advanced.schemapack.yaml)
is used
- `transformed.datapack.yaml` - the expected data output of the transformation
- `transformed.schemapack.yaml` - the expected model output of the transformation
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inferred_relations:
Experiment:
files:
path: "Experiment(samples)>Sample(files)>File"
expect_multiple: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
datapack: 0.1.0
resources:
File:
file_a:
content:
alias: file_a
filename: file_a.fastq
format: FASTQ
checksum: 1a5ac10ab42911dc0224172c118a326d9a4c03969112a2f3eb1ad971e96e92b8
size: 12321
file_b:
content:
alias: file_b
filename: file_b.fastq
format: FASTQ
checksum: 2b5ac10ab42911dc0224172c118a326d9a4c03969112a2f3eb1ad971e96e92c9
size: 12314
file_c:
content:
alias: file_c
filename: file_c.fastq
format: FASTQ
checksum: a9c24870071da03f78515e6197048f3a2172e90e597e9250cd01a0cb8f0986ed
size: 12123
Dataset:
dataset_1:
content:
alias: dataset_1
dac_contact: dac@example.org
relations:
files:
- file_a
- file_b
- file_c
Sample:
sample_x:
content:
alias: sample_x
relations:
files:
- file_a
- file_b
sample_y:
content:
alias: sample_y
relations:
files:
- file_c
Experiment:
experiment_i:
content:
alias: experiment_i
relations:
samples:
- sample_x
- sample_y
files: # <-
- file_a
- file_b
- file_c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
schemapack: 0.1.0
classes:
File:
id:
from_content: alias
content: ../example_content_schemas/File.schema.json
Dataset:
id:
from_content: alias
content: ../example_content_schemas/Dataset.schema.json
relations:
files:
to: File
cardinality: many_to_many
Sample:
id:
from_content: alias
content: ../example_content_schemas/Sample.schema.json
relations:
files:
to: File
cardinality: one_to_many
Experiment:
id:
from_content: alias
content: ../example_content_schemas/Experiment.schema.json
relations:
samples:
to: Sample
cardinality: one_to_many
files: # <-
to: File
cardinality: many_to_many
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inferred_relations:
Dataset:
samples:
path: "Dataset(files)>File<(files)Sample"
expected_multiple: true
Loading

0 comments on commit 3e9918e

Please sign in to comment.