Load External Schema¶
Currently, biothings_schema pyton package can handle 3 types of input:
A JSON document represented as a python dict
A URL to the JSON/YAML document
A file path to the JSON/YAML document
Use Python Dictionary as Input¶
biothings_schema python package accepts a JSON document as its input
In [1]: from biothings_schema import Schema
In [2]: schema = {
"@context": {
"bts": "http://schema.biothings.io/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "http://schema.org/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
{
"@id": "bts:BiologicalEntity",
"@type": "rdfs:Class",
"rdfs:comment": "biological entity",
"rdfs:label": "BiologicalEntity",
"rdfs:subClassOf": {
"@id": "schema:Thing"
},
"schema:isPartOf": {
"@id": "http://schema.biothings.io"
}
},
{
"@id": "bts:affectsAbundanceOf",
"@type": "rdf:Property",
"rdfs:comment": "affects abundance of",
"rdfs:label": "affectsAbundanceOf",
"schema:domainIncludes": {
"@id": "bts:BiologicalEntity"
},
"schema:isPartOf": {
"@id": "http://schema.biothings.io"
},
"schema:rangeIncludes": {
"@id": "bts:BiologicalEntity"
}
}
],
"@id": "http://schema.biothings.io/#0.1"
}
In [3]: se = Schema(schema=schema)
Use URL as Input¶
biothings_schema python package also accepts URL as its input. The data loaded from the URL must be either a JSON document or a YAML document.
In [1]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'
In [2]: se = Schema(schema=schema_url)
Use Local File Path as Input¶
biothings_schema python package also accepts local file path as its input. The data loaded from the local file path must be either a JSON document or a YAML document.
In [1]: schema_path = '../data/schema.jsonld'
In [2]: se = Schema(schema=schema_path)