openbel-api 0.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gemspec +65 -0
  3. data/CHANGELOG.md +22 -0
  4. data/INSTALL.md +19 -0
  5. data/INSTALL_RUBY.md +107 -0
  6. data/LICENSE +191 -0
  7. data/README.md +208 -0
  8. data/app/openbel/api/app.rb +83 -0
  9. data/app/openbel/api/config.rb +45 -0
  10. data/app/openbel/api/config.ru +3 -0
  11. data/app/openbel/api/helpers/pager.rb +109 -0
  12. data/app/openbel/api/middleware/auth.rb +112 -0
  13. data/app/openbel/api/resources/adapters/basic_json.rb +52 -0
  14. data/app/openbel/api/resources/annotation.rb +141 -0
  15. data/app/openbel/api/resources/base.rb +16 -0
  16. data/app/openbel/api/resources/completion.rb +89 -0
  17. data/app/openbel/api/resources/evidence.rb +115 -0
  18. data/app/openbel/api/resources/evidence_transform.rb +143 -0
  19. data/app/openbel/api/resources/function.rb +98 -0
  20. data/app/openbel/api/resources/match_result.rb +79 -0
  21. data/app/openbel/api/resources/namespace.rb +174 -0
  22. data/app/openbel/api/routes/annotations.rb +168 -0
  23. data/app/openbel/api/routes/authenticate.rb +108 -0
  24. data/app/openbel/api/routes/base.rb +326 -0
  25. data/app/openbel/api/routes/datasets.rb +519 -0
  26. data/app/openbel/api/routes/evidence.rb +330 -0
  27. data/app/openbel/api/routes/expressions.rb +560 -0
  28. data/app/openbel/api/routes/functions.rb +41 -0
  29. data/app/openbel/api/routes/namespaces.rb +382 -0
  30. data/app/openbel/api/routes/root.rb +39 -0
  31. data/app/openbel/api/schemas.rb +34 -0
  32. data/app/openbel/api/schemas/annotation_collection.schema.json +20 -0
  33. data/app/openbel/api/schemas/annotation_resource.schema.json +36 -0
  34. data/app/openbel/api/schemas/annotation_value_collection.schema.json +21 -0
  35. data/app/openbel/api/schemas/annotation_value_resource.schema.json +35 -0
  36. data/app/openbel/api/schemas/completion_collection.schema.json +21 -0
  37. data/app/openbel/api/schemas/completion_resource.schema.json +146 -0
  38. data/app/openbel/api/schemas/evidence.schema.json +198 -0
  39. data/app/openbel/api/schemas/evidence_collection.schema.json +98 -0
  40. data/app/openbel/api/schemas/evidence_resource.schema.json +29 -0
  41. data/app/openbel/api/schemas/namespace_value_collection.schema.json +21 -0
  42. data/app/openbel/api/schemas/namespace_value_resource.schema.json +43 -0
  43. data/app/openbel/api/util.rb +11 -0
  44. data/bin/openbel-api +78 -0
  45. data/bin/openbel-config +46 -0
  46. data/config/async_evidence.rb +12 -0
  47. data/config/async_jena.rb +14 -0
  48. data/config/config.yml +31 -0
  49. data/config/server_config.rb +184 -0
  50. data/lib/openbel/api/cache/cache.rb +30 -0
  51. data/lib/openbel/api/config/config.rb +33 -0
  52. data/lib/openbel/api/evidence/api.rb +39 -0
  53. data/lib/openbel/api/evidence/facet_api.rb +18 -0
  54. data/lib/openbel/api/evidence/facet_filter.rb +83 -0
  55. data/lib/openbel/api/evidence/mongo.rb +247 -0
  56. data/lib/openbel/api/evidence/mongo_facet.rb +105 -0
  57. data/lib/openbel/api/helpers/dependency_graph.rb +52 -0
  58. data/lib/openbel/api/model/rdf_resource.rb +74 -0
  59. data/lib/openbel/api/plugin/cache/kyotocabinet.rb +85 -0
  60. data/lib/openbel/api/plugin/configure_plugins.rb +97 -0
  61. data/lib/openbel/api/plugin/evidence/evidence.rb +58 -0
  62. data/lib/openbel/api/plugin/plugin.rb +99 -0
  63. data/lib/openbel/api/plugin/plugin_manager.rb +20 -0
  64. data/lib/openbel/api/plugin/plugin_repository.rb +60 -0
  65. data/lib/openbel/api/storage/cache_proxy.rb +74 -0
  66. data/lib/openbel/api/storage/triple_storage.rb +43 -0
  67. metadata +379 -0
@@ -0,0 +1,34 @@
1
+ require 'pathname'
2
+ require 'multi_json'
3
+ require 'json_schema'
4
+
5
+ module OpenBEL
6
+ module Schemas
7
+
8
+ COMPILED_SCHEMAS = {}
9
+ SCHEMA_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'schemas')
10
+ SUFFIX = ".schema.json"
11
+
12
+ def validate(data, type)
13
+ _get_schema(type).validate(data)
14
+ end
15
+
16
+ private
17
+
18
+ def _get_schema(type)
19
+ schemas = @@compiled ||= {}
20
+ schemas[type] ||= _compile_schema(type)
21
+ end
22
+
23
+ def _compile_schema(type)
24
+ path = (Pathname(SCHEMA_DIR) + "#{type}#{SUFFIX}").to_s
25
+ if File.exists? path
26
+ schema_data = MultiJson.load File.read(path)
27
+ JsonSchema.parse!(schema_data)
28
+ else
29
+ fail IOError.new "No schema file for type: #{type} at path: #{path}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "description": "DESCRIBE ANNOTATION COLLECTION",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "annotation_collection"
8
+ ],
9
+ "properties": {
10
+ "annotation_collection": {
11
+ "type": "array",
12
+ "minItems": 0,
13
+ "title": "",
14
+ "description": "",
15
+ "items": {
16
+ "$ref":"http://next.belframework.org/schemas/annotation_resource.schema.json"
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Annotation",
4
+ "description": "A vocabulary of terms for describing evidence resources.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "annotation"
9
+ ],
10
+ "properties": {
11
+ "annotation": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "rdf_uri",
16
+ "name",
17
+ "prefix",
18
+ "domain"
19
+ ],
20
+ "properties": {
21
+ "rdf_uri": {
22
+ "type": "string"
23
+ },
24
+ "name": {
25
+ "type": "string"
26
+ },
27
+ "prefix": {
28
+ "type": "string"
29
+ },
30
+ "domain": {
31
+ "type": "string"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Annotation Value Collection",
4
+ "description": "A collection of annotation value resources.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "annotation_value_collection"
9
+ ],
10
+ "properties": {
11
+ "annotation_value_collection": {
12
+ "type": "array",
13
+ "minItems": 0,
14
+ "title": "",
15
+ "description": "",
16
+ "items": {
17
+ "$ref":"http://next.belframework.org/schemas/annotation_value_resource.schema.json"
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Annotation Value Resource",
4
+ "description": "A single annotation value within a BEL Annotation.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "annotation_value"
9
+ ],
10
+ "properties": {
11
+ "annotation_value": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "type",
16
+ "identifier",
17
+ "name"
18
+ ],
19
+ "properties": {
20
+ "type": {
21
+ "type": "string"
22
+ },
23
+ "identifier": {
24
+ "type": "string"
25
+ },
26
+ "name": {
27
+ "type": "string"
28
+ },
29
+ "match_text": {
30
+ "type": "string"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Completion Collection",
4
+ "description": "A collection of BEL expression completions.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "completion_collection"
9
+ ],
10
+ "properties": {
11
+ "completion_collection": {
12
+ "type": "array",
13
+ "minItems": 0,
14
+ "title": "",
15
+ "description": "",
16
+ "items": {
17
+ "$ref":"http://next.belframework.org/schemas/completion_resource.schema.json#/properties/completion"
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,146 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Completion Resource",
4
+ "description": "A completion of a BEL expression.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "completion"
9
+ ],
10
+ "properties": {
11
+ "completion": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "type",
16
+ "label",
17
+ "value",
18
+ "highlight",
19
+ "actions"
20
+ ],
21
+ "properties": {
22
+ "type": {
23
+ "enum": [
24
+ "function",
25
+ "namespace_prefix",
26
+ "namespace_value"
27
+ ]
28
+ },
29
+ "label": {
30
+ "type": "string"
31
+ },
32
+ "value": {
33
+ "type": "string"
34
+ },
35
+ "highlight": {
36
+ "oneOf": [
37
+ {
38
+ "type": "null"
39
+ },
40
+ {
41
+ "type": "object",
42
+ "required": [
43
+ "start_position",
44
+ "end_position",
45
+ "range_type"
46
+ ],
47
+ "properties": {
48
+ "start_position": {
49
+ "type": "integer"
50
+ },
51
+ "end_position": {
52
+ "type": "integer"
53
+ },
54
+ "range_type": {
55
+ "enum": [
56
+ "exclusive",
57
+ "inclusive"
58
+ ]
59
+ }
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ "actions": {
65
+ "type": "array",
66
+ "items": {
67
+ "oneOf": [
68
+ {
69
+ "type": "object",
70
+ "required": [
71
+ "delete"
72
+ ],
73
+ "properties": {
74
+ "delete": {
75
+ "type": "object",
76
+ "required": [
77
+ "start_position",
78
+ "end_position",
79
+ "range_type"
80
+ ],
81
+ "properties": {
82
+ "start_position": {
83
+ "type": "integer"
84
+ },
85
+ "end_position": {
86
+ "type": "integer"
87
+ },
88
+ "range_type": {
89
+ "enum": [
90
+ "exclusive",
91
+ "inclusive"
92
+ ]
93
+ }
94
+ }
95
+ }
96
+ }
97
+ },
98
+ {
99
+ "type": "object",
100
+ "required": [
101
+ "insert"
102
+ ],
103
+ "properties": {
104
+ "insert": {
105
+ "type": "object",
106
+ "required": [
107
+ "position",
108
+ "value"
109
+ ],
110
+ "properties": {
111
+ "position": {
112
+ "type": "integer"
113
+ },
114
+ "value": {
115
+ "type": "string"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ },
121
+ {
122
+ "type": "object",
123
+ "required": [
124
+ "move_cursor"
125
+ ],
126
+ "properties": {
127
+ "move_cursor": {
128
+ "type": "object",
129
+ "required": [
130
+ "position"
131
+ ],
132
+ "properties": {
133
+ "position": {
134
+ "type": "integer"
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,198 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "description": "DESCRIBE EVIDENCE",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["evidence"],
7
+ "properties": {
8
+ "evidence": {
9
+ "type": "object",
10
+ "additionalProperties": false,
11
+ "required": ["bel_statement", "citation"],
12
+ "properties": {
13
+ "bel_statement": {
14
+ "type": "string",
15
+ "title": "BEL Statement",
16
+ "description": "A BEL Statement is an expression that represents knowledge of the existence of biological entities and relationships between them that are known to be observed within a particular context, based on some source of prior knowledge such as a scientific publication or newly generated experimental data."
17
+ },
18
+ "citation": {
19
+ "type": "object",
20
+ "title": "Citation",
21
+ "description": "The citation specifies the written source where the biological knowledge was referenced.",
22
+ "required": ["type", "id"],
23
+ "properties": {
24
+ "type": {
25
+ "type": "string",
26
+ "enum": ["PubMed", "Book", "Journal", "Online Resource", "Other"],
27
+ "title": "Citation Type",
28
+ "description": "The citation type of the reference."
29
+ },
30
+ "id": {
31
+ "type": ["string", "number"],
32
+ "title": "Citation ID",
33
+ "description": "The citation identifier (PubMed ID, ISBN, DOI, URL) of the reference."
34
+ },
35
+ "name": {
36
+ "type": ["string", "null"],
37
+ "title": "Citation Name",
38
+ "description": "The citation name of the reference."
39
+ },
40
+ "date": {
41
+ "type": ["string", "null"],
42
+ "title": "Citation Date",
43
+ "description": "The citation date of the reference."
44
+ },
45
+ "authors": {
46
+ "type": ["array", "null"],
47
+ "title": "Citation Authors",
48
+ "description": "The citation authors of the reference.",
49
+ "items": {
50
+ "type": "string",
51
+ "minItems": 0
52
+ }
53
+ },
54
+ "comment": {
55
+ "type": ["string", "null"],
56
+ "title": "Citation Comment",
57
+ "description": "The citation comment of the reference."
58
+ }
59
+ }
60
+ },
61
+ "experiment_context": {
62
+ "type": ["array", "null"],
63
+ "title": "Experiment Context",
64
+ "description": "An experiment context specifies the experiment's parameters where this interaction was observed.",
65
+ "items": {
66
+ "type": "object",
67
+ "required": ["name", "value"],
68
+ "properties": {
69
+ "name": {
70
+ "type": "string",
71
+ "title": "Annotation Type",
72
+ "description": "Annotation type listing - sourced from the BEL Annotation resource names"
73
+ },
74
+ "value": {
75
+ "type": ["string", "number", "boolean", "array"],
76
+ "title": "Annotations",
77
+ "description": "Annotations such as Homo sapiens, cancer, epithelial tissue sourced from the BEL Annotation resources",
78
+ "items": {
79
+ "type": ["string", "number", "boolean"]
80
+ }
81
+ },
82
+ "uri": {
83
+ "type": "string",
84
+ "title": "Annotation URI",
85
+ "description": "URI for Annotation",
86
+ "format": "uri",
87
+ "items": {
88
+ "type": "string",
89
+ "format": "uri"
90
+ }
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "summary_text": {
96
+ "type": ["string", "null"],
97
+ "title": "Summary Text",
98
+ "description": "Abstract from source text to provide support for this evidence"
99
+ },
100
+ "references": {
101
+ "type": ["object", "null"],
102
+ "title": "References",
103
+ "description": "The references section identifies annotation and namespace URIs.",
104
+ "properties": {
105
+ "annotations": {
106
+ "type": ["array", "null"],
107
+ "title": "Annotation references",
108
+ "description": "References to annotation resources.",
109
+ "item": {
110
+ "type": "object",
111
+ "properties": {
112
+ "keyword": {
113
+ "type": "string",
114
+ "title": "Keyword",
115
+ "description": "Keyword that identifies this annotation resource, but only in the context of this Evidence."
116
+ },
117
+ "uri": {
118
+ "type": "string",
119
+ "format": "uri",
120
+ "title": "URI",
121
+ "description": "URI that identifies this annotation resource."
122
+ }
123
+ },
124
+ "required": ["keyword", "uri"]
125
+ }
126
+ },
127
+ "namespaces": {
128
+ "type": ["array", "null"],
129
+ "title": "Namespace references",
130
+ "description": "References to namespace resources.",
131
+ "item": {
132
+ "type": "object",
133
+ "properties": {
134
+ "keyword": {
135
+ "type": "string",
136
+ "title": "Keyword",
137
+ "description": "Keyword that identifies this namespace resource, but only in the context of this Evidence."
138
+ },
139
+ "uri": {
140
+ "type": "string",
141
+ "format": "uri",
142
+ "title": "URI",
143
+ "description": "URI that identifies this namespace resource."
144
+ }
145
+ },
146
+ "required": ["keyword", "uri"]
147
+ }
148
+ }
149
+ }
150
+ },
151
+ "metadata": {
152
+ "type": ["array", "null"],
153
+ "title": "Evidence resource metadata",
154
+ "description": "Metadata that describes the evidence resource.",
155
+ "items": {
156
+ "oneOf": [
157
+ {
158
+ "type": "object",
159
+ "required": ["name", "value"],
160
+ "properties": {
161
+ "name": {
162
+ "type": "string",
163
+ "title": "Name",
164
+ "description": "The name of this metadata property."
165
+ },
166
+ "value": {
167
+ "type": ["array", "boolean", "number", "object", "string"],
168
+ "title": "Value",
169
+ "description": "The value of this metadata property.",
170
+ "items": {
171
+ "type": ["array", "boolean", "integer", "number", "null", "object", "string"]
172
+ }
173
+ }
174
+ }
175
+ },
176
+ {
177
+ "type": "object",
178
+ "required": ["uri"],
179
+ "title": "Annotation URI(s)",
180
+ "description": "URI(s) for Annotations",
181
+ "properties": {
182
+ "uri": {
183
+ "type": ["string", "array"],
184
+ "format": "uri",
185
+ "items": {
186
+ "type": "string",
187
+ "format": "uri"
188
+ }
189
+ }
190
+ }
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }