Skip to content

Commit

Permalink
Merge pull request #62 from elixir-europe/dev
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
theisuru committed Feb 20, 2023
2 parents e5778da + 8c16376 commit f3329bf
Show file tree
Hide file tree
Showing 17 changed files with 895 additions and 23 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The biovalidator currently supports JSON Schema draft-06/07/2019-09.
- Changes to arguments accepted at the startup
- `--json` renamed to `--data`
- Added `--ref`, `--port`, `--baseUrl`, `pidPath`
- Support for new keyword `isValidIdentifier`. Validate accessions/IDs using identifiers.org API.

## Contents
- [Getting Started](#getting-started)
Expand All @@ -27,6 +28,7 @@ The biovalidator currently supports JSON Schema draft-06/07/2019-09.
- [isChildTermOf](#ischildtermof)
- [isValidTerm](#isvalidterm)
- [isValidTaxonomy](#isvalidtaxonomy)
- [isValidIdentifier](#isvalididentifier)
- [Running in Docker](#running-in-docker)
- [License](#license)

Expand Down Expand Up @@ -232,6 +234,8 @@ The biovalidator supports four extended keywords for ontology and taxonomy valid
This custom keyword *evaluates if an ontology term is child of another*. This keyword is applied to a string (CURIE) and **passes validation if the term is a child of the term defined in the schema**.
The keyword requires one or more **parent terms** *(classes)* and **ontology ids** *(ontologies)*, both of which should exist in [OLS - Ontology Lookup Service](https://www.ebi.ac.uk/ols).

* **ontologies** should be present in EBI OLS and are case-sensitive (most of the OLS ontologies are in lower case)

This keyword works by doing an asynchronous call to the [OLS API](https://www.ebi.ac.uk/ols/api/) that will respond with the required information to know if a given term is child of another.
Being an async validation step, whenever used in a schema, the schema must have the flag: `"$async": true` in its object root.

Expand Down Expand Up @@ -351,6 +355,64 @@ Data:
}
```

### isValidIdentifier
Evaluates if a given *identifier* has a correct format using identifiers.org resolution API. The keyword is applicable to the `string` data type.

The keyword will do an asynchronous call to the [identifier.org API](https://resolver.api.identifiers.org/) to resolve the URL for the given CURIE.
Being an async validation step, whenever used in a schema, the schema must have the flag: `"$async": true` in its object root.

The keyword has two properties: `prefixes` and `prefix`. Only one of them is allowed in a block and `prefix` will take the priority in case both are provided.
- `prefix` define one namespace/prefix for the expected identifier/accession. In the data, field should only contain the ID/accession without the namespace.
- `prefixes` define a set of allowed namespaces/prefixes. In the data, field should contain a valid CURIE (namespace:id format)

:warning: At the moment only the format of the identifier/accession is checked against the identifier.org. Therefore, this does not guarantee the existence of the data record.

#### isValidIdentifier example 1
Schema:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$async": true,
"properties": {
"SampleId": {
"type": "string",
"isValidIdentifier": {
"prefix": "biosample"
}
}
}
}
```
Data:
```json
{
"SampleId": "SAMEA2397676"
}
```

#### isValidIdentifier example 2
Schema:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$async": true,
"properties": {
"resourceId": {
"type": "string",
"isValidIdentifier": {
"prefixes": ["biosample", "arrayexpress"]
}
}
}
}
```
Data:
```json
{
"resourceId": "biosample:SAMEA2397676"
}
```

## Running in Docker
A Dockerized version of biovalidator is available on [quay.io](https://quay.io/repository/ebi-ait/biovalidator).
This image can be used to run the validator without cloning this repository.
Expand Down
4 changes: 4 additions & 0 deletions examples/objects/isValidIdentifier-single-prefix_pass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sampleName": "test sample",
"SampleId": "SAMEA2397676"
}
4 changes: 4 additions & 0 deletions examples/objects/isValidIdentifier_fail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sampleName": "test sample",
"SampleId": "biosample:INVALID_ID"
}
4 changes: 4 additions & 0 deletions examples/objects/isValidIdentifier_fail_namespace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sampleName": "test sample",
"SampleId": "arrayexpress:E-MEXP-1712"
}
4 changes: 4 additions & 0 deletions examples/objects/isValidIdentifier_pass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sampleName": "test sample",
"SampleId": "biosample:SAMEA2397676"
}
1 change: 1 addition & 0 deletions examples/schemas/biosamples-schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "test/biosamples/schema",
"title": "Sample",
"description": "A BioSamples sample.",

Expand Down
27 changes: 27 additions & 0 deletions examples/schemas/isValidIdentifier-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$id": "http://subs/isValidIdentifier-schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Test schema for BioSample accession",
"$async": true,
"additionalProperties": false,
"required": [
"SampleId"
],
"title": "disease_ontology",
"properties": {
"sampleName": {
"description": "The text for the term as the user provides it.",
"type": "string"
},
"SampleId": {
"description": "An optional ontology reference in format where prefix_ indicates which ontology",
"type": "string",
"isValidIdentifier": {
"prefixes": [
"biosample"
]
}
}
},
"type": "object"
}
25 changes: 25 additions & 0 deletions examples/schemas/isValidIdentifier-single-prefix-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$id": "http://subs/isValidIdentifier-schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Test schema for BioSample accession",
"$async": true,
"additionalProperties": false,
"required": [
"SampleId"
],
"title": "disease_ontology",
"properties": {
"sampleName": {
"description": "The text for the term as the user provides it.",
"type": "string"
},
"SampleId": {
"description": "An optional ontology reference in format where prefix_ indicates which ontology",
"type": "string",
"isValidIdentifier": {
"prefix": "biosample"
}
}
},
"type": "object"
}
Loading

0 comments on commit f3329bf

Please sign in to comment.