Skip to content

Commit f754b60

Browse files
committed
corrected BEL schema, details follow
- moved evidence inside definitions section - moved edge inside graph/properties - fixed evidence JSON pointer in edge metadata - fixed citation/type string enumeration - added BEL test to validate child schema and an example BEL network
1 parent 1a3977b commit f754b60

3 files changed

Lines changed: 580 additions & 78 deletions

File tree

.build/test/test-bel.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'json'
2+
require 'json-schema'
3+
require 'pathname'
4+
require 'pp'
5+
require 'minitest/autorun'
6+
require 'minitest/unit'
7+
8+
class ExtTest < Minitest::Test
9+
10+
def test_validate_schema
11+
root = Pathname(File.dirname(File.expand_path __FILE__)) + '..' + '..' + 'child-schemas'
12+
schema = JSON.parse File.read(root + 'bel-json-graph.schema.json')
13+
errors = JSON::Validator.fully_validate_schema(schema)
14+
15+
assert errors.empty?, errors.join("\n")
16+
17+
root = Pathname(File.dirname(File.expand_path __FILE__)) + '..' + '..'
18+
data = JSON.parse File.open(root + 'examples' + 'test.network.json', 'r:UTF-8', &:read)
19+
errors = JSON::Validator.fully_validate(schema, data, :insert_defaults => true, :errors_as_objects => true)
20+
21+
if ENV['JGS_VERBOSE']
22+
puts "\n\nValidated JSON for example: examples/test.network.json"
23+
pp data
24+
end
25+
26+
assert errors.empty?, errors.join("\n")
27+
end
28+
end
29+
# vim: ts=2 sts=2 sw=2

child-schemas/bel-json-graph.schema.json

Lines changed: 122 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,84 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema",
3-
"oneOf": [{
4-
"type": "object",
5-
"properties": {
6-
"graph": {
7-
"$ref": "#/definitions/graph"
8-
}
9-
},
10-
"additionalProperties": false,
11-
"required": ["graph"]
12-
}, {
13-
"type": "object",
14-
"properties": {
15-
"label": {
16-
"type": "string",
17-
"title": "Graph Set Label",
18-
"description": "Graph Set label",
19-
"name": "graph_set_label"
20-
},
21-
"type": {
22-
"type": "string",
23-
"title": "Type of Graphs in Set",
24-
"description": "Graph types in graph set",
25-
"name": "graph_set_type"
26-
},
27-
"metadata": {
28-
"type": ["object", "null"],
29-
"title": "Graph Set Metadata",
30-
"description": "Graph set metadata",
31-
"name": "graph_set_metadata"
32-
},
33-
"graphs": {
34-
"type": "array",
35-
"items": {
3+
"description": "Graph data description. Please note that all field keys are to be lowercase and use snake-case (e.g. words are separated by underscores like ncbi_tax_id). Some of the metadata fields are not required but are included as exemplars for generating interoperable BEL JGF files. You may need to provide additional validation programmatically to confirm that the metadata you need for your application exists.",
4+
"oneOf": [
5+
{
6+
"type": "object",
7+
"properties": {
8+
"graph": {
369
"$ref": "#/definitions/graph"
3710
}
38-
}
11+
},
12+
"additionalProperties": false,
13+
"required": [
14+
"graph"
15+
]
3916
},
40-
"additionalProperties": false
41-
}],
17+
{
18+
"type": "object",
19+
"properties": {
20+
"label": {
21+
"type": "string",
22+
"title": "Graph Set Label",
23+
"description": "Graph Set label"
24+
},
25+
"type": {
26+
"type": "string",
27+
"title": "Type of Graphs in Set",
28+
"description": "Graph types in graph set"
29+
},
30+
"metadata": {
31+
"type": [
32+
"object",
33+
"null"
34+
],
35+
"title": "Graph Set Metadata",
36+
"description": "Graph set metadata"
37+
},
38+
"graphs": {
39+
"type": "array",
40+
"items": {
41+
"$ref": "#/definitions/graph"
42+
}
43+
}
44+
},
45+
"additionalProperties": false
46+
}
47+
],
4248
"definitions": {
4349
"graph": {
4450
"type": "object",
4551
"additionalProperties": false,
52+
"title": "Graph or Network data",
4653
"properties": {
4754
"label": {
4855
"type": "string",
4956
"title": "Graph Label",
50-
"description": "Graph label",
51-
"name": "graph_label"
57+
"description": "Graph label"
5258
},
5359
"directed": {
54-
"type": ["boolean", "null"],
60+
"type": [
61+
"boolean",
62+
"null"
63+
],
5564
"description": "Directed or undirected graph",
5665
"default": true
5766
},
5867
"type": {
5968
"type": "string",
6069
"title": "Type of Graph",
61-
"description": "Graph type",
62-
"name": "graph_type"
70+
"description": "BEL Versioned Graph type"
6371
},
6472
"metadata": {
65-
"type": ["object", "null"],
73+
"type": [
74+
"object",
75+
"null"
76+
],
6677
"additionalProperties": true,
6778
"properties": {
6879
"ncbi_tax_id": {
6980
"type": "integer",
70-
"title": "NCBI Taxonomy ID - ",
81+
"title": "NCBI Taxonomy ID",
7182
"description": "NCBI Taxonomy ID - http://www.ncbi.nlm.nih.gov/taxonomy"
7283
},
7384
"species_common_name": {
@@ -79,11 +90,18 @@
7990
"type": "string",
8091
"title": "Graph description",
8192
"description": "Graph description"
93+
},
94+
"version": {
95+
"type": "string",
96+
"description": "Version of the graph"
8297
}
8398
}
8499
},
85100
"nodes": {
86-
"type": ["array", "null"],
101+
"type": [
102+
"array",
103+
"null"
104+
],
87105
"items": {
88106
"type": "object",
89107
"additionalProperties": false,
@@ -95,40 +113,42 @@
95113
"type": "string"
96114
},
97115
"metadata": {
98-
"type": ["object", "null"],
116+
"type": [
117+
"object",
118+
"null"
119+
],
99120
"additionalProperties": true,
100121
"properties": {
101-
102-
"x": {
103-
"type": "number",
104-
"title": "X coordinate",
105-
"description": "x coordinate of node location"
106-
},
107-
"y": {
108-
"type": "number",
109-
"title": "Y coordinate",
110-
"description": "y coordinate of node location"
122+
"coordinate": {
123+
"type": "array",
124+
"items": {
125+
"type": "number"
126+
},
127+
"minItems": 2,
128+
"title": "Node coordinates",
129+
"description": "Node coordinates as either an (x, y) or (x, y, z) tuple, the tuple is unbounded to allow additional dimensions to be used in addition to x, y and z coordinates"
111130
},
112-
"z": {
113-
"type": "number",
114-
"title": "Z coordinate",
115-
"description": "z coordinate of node location - not needed for 2D visualizations"
131+
"bel_function_type": {
132+
"type": "string",
133+
"description": "BEL function types such as proteinAbundance, trancriptionalActivity, etc"
116134
}
117135
}
118136
}
119-
},
120-
"required": ["id"]
121-
}
137+
}
138+
},
139+
"required": [
140+
"id"
141+
]
122142
},
123143
"edges": {
124-
"type": ["array", "null"],
144+
"type": [
145+
"array",
146+
"null"
147+
],
125148
"items": {
126149
"type": "object",
127150
"additionalProperties": false,
128151
"properties": {
129-
"id": {
130-
"type": "string"
131-
},
132152
"source": {
133153
"type": "string",
134154
"title": "Source Node",
@@ -145,16 +165,26 @@
145165
"description": "Relationship between nodes in edge - may be directed or undirected"
146166
},
147167
"directed": {
148-
"type": ["boolean", "null"],
168+
"type": [
169+
"boolean",
170+
"null"
171+
],
149172
"default": true
150173
},
151174
"label": {
152175
"type": "string"
153176
},
154177
"metadata": {
155-
"type": ["object", "null"],
178+
"type": [
179+
"object",
180+
"null"
181+
],
156182
"additionalProperties": true,
157183
"properties": {
184+
"causal": {
185+
"type": "boolean",
186+
"description": "True if a BEL causal edge type"
187+
},
158188
"evidences": {
159189
"type": "array",
160190
"items": {
@@ -164,13 +194,20 @@
164194
}
165195
}
166196
},
167-
"required": ["source", "target"]
197+
"required": [
198+
"source",
199+
"target"
200+
]
168201
}
169202
}
170203
}
171204
},
172205
"evidence": {
173206
"type": "object",
207+
"required": [
208+
"bel_statement",
209+
"citation"
210+
],
174211
"properties": {
175212
"bel_statement": {
176213
"type": "string",
@@ -180,24 +217,31 @@
180217
"citation": {
181218
"type": "object",
182219
"properties": {
183-
"reference_type": {
220+
"type": {
184221
"type": "string",
185-
"title": "Reference Type",
186-
"description": "The reference type of this citation."
222+
"enum": [
223+
"PubMed",
224+
"Book",
225+
"Journal",
226+
"Online Resource",
227+
"Other"
228+
],
229+
"title": "Citation Type",
230+
"description": "The citation type"
187231
},
188-
"reference_id": {
232+
"id": {
189233
"type": "string",
190-
"title": "Reference ID",
191-
"description": "Identifier of the reference, e.g. PubMed ID"
234+
"title": "Citation ID",
235+
"description": "Identifier of the citation, e.g. PubMed ID"
192236
},
193237
"name": {
194238
"type": "string",
195-
"title": "Reference Name",
196-
"description": "Name or citation string for the citation."
239+
"title": "Citation Name",
240+
"description": "Name or citation string for the reference."
197241
}
198242
},
199243
"title": "Citation for Edge Evidence",
200-
"description": "Reference to support the evidence presented for the Edge"
244+
"description": "Citation to support the evidence presented for the Edge"
201245
},
202246
"biological_context": {
203247
"type": "object",

0 commit comments

Comments
 (0)