diff --git a/.gemspec b/.gemspec index fbc1e5a..a56f80f 100644 --- a/.gemspec +++ b/.gemspec @@ -34,27 +34,24 @@ Gem::Specification.new do |spec| # Dependencies ## bel.rb - spec.add_runtime_dependency 'bel', '0.6.0' + spec.add_runtime_dependency 'bel', '~> 1.0.0' ## bel.rb translator dependencies - spec.add_runtime_dependency 'json-ld', '1.99.0' - spec.add_runtime_dependency 'rdf-json', '1.99.0' - spec.add_runtime_dependency 'rdf-rdfa', '1.99.0' - spec.add_runtime_dependency 'rdf-rdfxml', '1.99.0' - spec.add_runtime_dependency 'rdf-trig', '1.99.0.1' - spec.add_runtime_dependency 'rdf-trix', '1.99.0' - spec.add_runtime_dependency 'rdf-turtle', '1.99.0' + spec.add_runtime_dependency 'json-ld', '2.0.0' + spec.add_runtime_dependency 'rdf-json', '2.0.0' + spec.add_runtime_dependency 'rdf-rdfa', '2.0.0' + spec.add_runtime_dependency 'rdf-rdfxml', '2.0.0' + spec.add_runtime_dependency 'rdf-trig', '2.0.0' + spec.add_runtime_dependency 'rdf-trix', '2.0.0' + spec.add_runtime_dependency 'rdf-turtle', '2.0.0' ## bel.rb plugin - annotation/namespace search - spec.add_runtime_dependency 'bel-search-sqlite', '0.4.2' + spec.add_runtime_dependency 'bel-search-sqlite', '~> 1.0.0' ## bel.rb plugin - RDF repository using Apache Jena - spec.add_runtime_dependency 'bel-rdf-jena', '0.4.2' + spec.add_runtime_dependency 'bel-rdf-jena', '~> 1.0.0' - ## RDF - RDF abstraction - spec.add_runtime_dependency 'rdf', '1.99.1' - - ## Mongo - Faceted search of evidence. + ## Mongo - Faceted search of nanopub. spec.add_runtime_dependency 'mongo', '1.12.5' spec.add_runtime_dependency 'bson', '1.12.5' diff --git a/.gitignore b/.gitignore index 48ae2a7..94a408a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ node_modules .netrwhist VimFlavor* /openbel-api-*gem +openbel-api-config.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 179c7e4..3aa70b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to openbel-api will be documented in this file. The curated This project adheres to [Semantic Versioning][Semantic Versioning]. +## [1.0.0][1.0.0] - TBD +### Added +- Support JWT authentication via *token* query parameter ([PR #108][108]). + ## [0.6.2][0.6.2] - 2016-03-23 ### Fixed - Missing authorization header reported when header is malformed ([Issue #105][105]). @@ -13,12 +17,12 @@ This project adheres to [Semantic Versioning][Semantic Versioning]. ## [0.6.0][0.6.0] - 2016-03-16 ### Added -- Retrieve evidence in a format supported by BEL translator plugins ([Issue 44][44]). -- Retrieve dataset evidence in a format supported by BEL translator plugins ([Issue 99][99]). +- Retrieve nanopub in a format supported by BEL translator plugins ([Issue 44][44]). +- Retrieve dataset nanopub in a format supported by BEL translator plugins ([Issue 99][99]). ### Fixed -- Dataset evidence collection is missing annotation/namespace URIs ([Issue 95][95]). -- Facets are not created for evidence uploaded through a dataset. +- Dataset nanopub collection is missing annotation/namespace URIs ([Issue 95][95]). +- Facets are not created for nanopub uploaded through a dataset. ### Changed - MongoDB version 3.2.0 is now required due to use of `$slice` operator in Aggregation queries. @@ -32,7 +36,7 @@ Datasets are stored with a URI computed from the scheme and host that is serving ## [0.5.1][0.5.1] - 2015-12-18 ### Fixed -- Authentication error for MongoDB user when faceting on `GET /api/evidence` ([Issue #93][93]). +- Authentication error for MongoDB user when faceting on `GET /api/nanopub` ([Issue #93][93]). ### Changed - MongoDB version 3.2.0 is now required due to use of `$slice` operator in Aggregation queries ([Issue ?][]). @@ -56,12 +60,12 @@ Datasets are stored with a URI computed from the scheme and host that is serving ## 0.4.0 - 2015-12-14 ### Added -- Evidence Store - - Storage of evidence including creation, retrieval, modification, and deletion actions. - - Flexible filtering of stored, evidence based on user's custom data requirements. - - Upload a document (e.g. BEL script, XBEL, or Evidence JSON), to the Evidence Store, as a dataset. These can later be retrieved or deleted from the Evidence Store. - - Flexible filtering of evidence contained within a dataset. - - Download a document (e.g. BEL script, XBEL, or Evidence JSON) from a dataset. +- Nanopub Store + - Storage of nanopub including creation, retrieval, modification, and deletion actions. + - Flexible filtering of stored, nanopub based on user's custom data requirements. + - Upload a document (e.g. BEL script, XBEL, or Nanopub JSON), to the Nanopub Store, as a dataset. These can later be retrieved or deleted from the Nanopub Store. + - Flexible filtering of nanopub contained within a dataset. + - Download a document (e.g. BEL script, XBEL, or Nanopub JSON) from a dataset. - BEL Expressions - Autocomplete a BEL term expression. - Retrieve the structural components of a BEL expression. @@ -70,13 +74,14 @@ Datasets are stored with a URI computed from the scheme and host that is serving - Retrieve equivalent namespace values from the individual. - Retrieve orthologous namespace values from the individual. +[1.0.0]: https://github.com/OpenBEL/openbel-api/compare/0.6.2...1.0.0 [0.6.2]: https://github.com/OpenBEL/openbel-api/compare/0.6.1...0.6.2 [0.6.1]: https://github.com/OpenBEL/openbel-api/compare/0.6.0...0.6.1 [0.6.0]: https://github.com/OpenBEL/openbel-api/compare/0.5.1...0.6.0 [0.5.1]: https://github.com/OpenBEL/openbel-api/compare/0.5.0...0.5.1 [0.5.0]: https://github.com/OpenBEL/openbel-api/compare/0.4.0...0.5.0 [Semantic Versioning]: http://semver.org -[MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#mongodb-user-authentication +[MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Nanopub-Store#mongodb-user-authentication [44]: https://github.com/OpenBEL/openbel-api/issues/44 [91]: https://github.com/OpenBEL/openbel-api/issues/91 [92]: https://github.com/OpenBEL/openbel-api/issues/92 @@ -85,3 +90,4 @@ Datasets are stored with a URI computed from the scheme and host that is serving [99]: https://github.com/OpenBEL/openbel-api/issues/99 [102]: https://github.com/OpenBEL/openbel-api/issues/102 [105]: https://github.com/OpenBEL/openbel-api/issues/105 +[108]: https://github.com/OpenBEL/openbel-api/issues/108 diff --git a/README.md b/README.md index d253438..9e74c24 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ The OpenBEL API provides RESTful API access to your BEL content. It is part of [ ## Features -- Evidence Store - - Storage of evidence including creation, retrieval, modification, and deletion actions. - - Flexible filtering of stored, evidence based on user's custom data requirements. - - Upload a document (e.g. BEL script, XBEL, or Evidence JSON), to the Evidence Store, as a dataset. These can later be retrieved or deleted from the Evidence Store. - - Flexible filtering of evidence contained within a dataset. - - Download a document (e.g. BEL script, XBEL, or Evidence JSON) from a dataset. +- Nanopub Store + - Storage of nanopub including creation, retrieval, modification, and deletion actions. + - Flexible filtering of stored, nanopub based on user's custom data requirements. + - Upload a document (e.g. BEL script, XBEL, or nanopub JSON), to the Nanopub Store, as a dataset. These can later be retrieved or deleted from the nanopub Store. + - Flexible filtering of nanopub contained within a dataset. + - Download a document (e.g. BEL script, XBEL, or Nanopub JSON) from a dataset. - BEL Expressions - Autocomplete a BEL term expression. - Retrieve the structural components of a BEL expression. @@ -21,28 +21,28 @@ The OpenBEL API provides RESTful API access to your BEL content. It is part of [ ## Vocabulary *Annotation* -A name/value property that describes an aspect of an *Evidence*. For example *Ncbi Taxonomy*:*Homo sapiens* is an annotation for the Human species. +A name/value property that describes an aspect of a *nanopub*. For example *Ncbi Taxonomy*:*Homo sapiens* is an annotation for the Human species. *Namespace* A biological identifier that is curated and maintained by an organization. For example the *Gene Ontology* (i.e. *GO*) or *HGNC* (i.e. *HUGO Gene Nomenclature Committee*) database. -*Evidence* +*nanopub* A biological interaction curated from scientific literature. It is comprised of five parts. - *Citation*: The identification for the scientific literature where the interaction was stated. - *BEL Statement*: The biological interaction curated from the *Citation*. -- *Summary text*: The text (i.e. *quotation*) within the *Citation* that supports the *BEL Statement*. +- *Support*: The text (i.e. *quotation*) within the *Citation* that supports the *BEL Statement*. - *Experiment Context*: The biological context within the experiment where the *BEL Statement* was observed. For example if the experiment sample was a biopsy on Human, Lung tissue then you might provide *Ncbi Taxonomy*: *Homo sapiens* and *Uberon*: *lung epithelium*. -- *Metadata*: Additional data about this *Evidence* that is not part of the experiment (i.e. in *Experiment Context*). For example the evidence's *Reviewer*, *Create Date*, or *Reviewed Date* would be considered metadata. +- *Metadata*: Additional data about this *nanopub* that is not part of the experiment (i.e. in *Experiment Context*). For example the nanopub's *Reviewer*, *Create Date*, or *Reviewed Date* would be considered metadata. - *References*: The annotation and namespace sources used in the *BEL Statement*, *Experiment Context*, and *Metadata*. For example *Ncbi Taxonomy* may refer to an annotation identified by the URI http://www.openbel.org/bel/namespace/ncbi-taxonomy. -*Document*: A file containing a collection of *Evidence* with document metadata like *Name*, *Description*, and *Version*. The supported document formats are BEL script, XBEL, and JSON Evidence. +*Document*: A file containing a collection of *nanopub* with document metadata like *Name*, *Description*, and *Version*. The supported document formats are BEL script, XBEL, and JSON Nanopub. -*Dataset*: The representation of a *BEL Document* within the OpenBEL API. This provides access to document metadata as well as the collection of *Evidence* stored in the OpenBEL API that originate from the *BEL Document*. +*Dataset*: The representation of a *BEL Document* within the OpenBEL API. This provides access to document metadata as well as the collection of *nanopub* stored in the OpenBEL API that originate from the *BEL Document*. *Expression*: A string encoded in BEL that may represent a parameter (e.g. *AKT1*, *GO:"apoptotic process"*), term (e.g. *bp(GO:"apoptotic process")*), or statement (e.g. *p(HGNC:AKT1) increases bp(GO:"apoptotic process")*). -*Evidence Store*: A database used for *Evidence*. It facilitates storage, filtering, and transformation of *Evidence*. +*Nanopub Store*: A database used for BEL *nanopubs*. It facilitates storage, filtering, and transformation of *nanopubs*. ## Technical requirements @@ -57,7 +57,7 @@ The OpenBEL API is built to run with [JRuby][JRuby] and [Java 8][Java 8]. - [MongoDB][MongoDB], version 3.2 or greater - Follow [MongoDB download][MongoDB download] page for download and installation instructions. - [SQLite][SQLite], version 3.8.0 or greater - - Follow [SQLite download][SQLite download] page for download and installation instructions. + - Follow [SQLite download][SQLite download] page for download and installation instructions. ## Getting up and Running @@ -103,20 +103,7 @@ The OpenBEL API requires a configuration file to set up a few things. You can cr openbel-config --file openbel-api-config.yml ``` -*Configure the Evidence Store* -The Evidence Store is backed by a [MongoDB][MongoDB] database. You will need to provide the *host*, *port*, and *database* option. - -The default configuration is: - -```yaml -evidence_store: - mongo: - host: 'localhost' - port: 27017 - database: 'openbel' -``` - -There are also settings for user authentication. See [MongoDB User Authentication][MongoDB User Authentication] on the wiki. +[Configuring the Nanopub Store][https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Nanopub-Store] *Resource RDF data* Annotations, namespaces, and dataset storage are represented as [RDF][RDF] data. The data is stored in an on-disk database using Apache Jena (Java library included with `openbel-api`). @@ -150,7 +137,7 @@ resource_search: You can obtain the latest Resource Search database (20150611) from the [OpenBEL build server][Resource Search 20150611]. *Token-based authentication* -The OpenBEL API is equipped to require authentication for specific API paths (e.g. Evidence, Datasets). The implementation uses [Auth0][Auth0] as a single sign-on service. +The OpenBEL API is equipped to require authentication for specific API paths (e.g. nanopub, Datasets). The implementation uses [Auth0][Auth0] as a single sign-on service. By default authentication is disabled. @@ -228,11 +215,13 @@ server { } ``` -## API Documentation +## Upgrading -The REST API is defined by a [RAML][RAML] specification. Th is published [here][OpenBEL API RAML specification]. +[Upgrading instructions][Upgrading] + +## API Documentation -API documentation with *Try it* functionality is available [here][OpenBEL API documentation]. +API documentation with *Try it* functionality is available here [OpenBEL API documentation][OpenBEL API documentation]. You can download the [RAML 0.8][RAML] or Swagger specification files, try it on the webpage or generate curl, httpie, and various language templates for using the API. ----- @@ -241,9 +230,8 @@ Built with collaboration and a lot of :heart: by the [OpenBEL][OpenBEL] communit [OpenBEL]: http://www.openbel.org [OpenBEL Platform]: https://github.com/OpenBEL/openbel-platform [RAML]: http://raml.org/ -[OpenBEL API RAML specification]: http://next.belframework.org/openbel-api.raml -[OpenBEL API documentation]: http://next.belframework.org/ -[Evidence API documentation]: http://next.belframework.org/#evidence +[OpenBEL API documentation]: http://openbelapi.api-docs.io/ +[Nanopub API documentation]: http://openbelapi.api-docs.io/0.0.2/models/enWQug5KYcBtXxmPN [JRuby]: http://jruby.org [JRuby Getting Started]: http://jruby.org/getting-started [Java 8]: http://www.oracle.com/technetwork/java/javase/overview/java8-2100321.html @@ -251,6 +239,7 @@ Built with collaboration and a lot of :heart: by the [OpenBEL][OpenBEL] communit [MongoDB download]: https://www.mongodb.org/downloads#production [SQLite]: https://www.sqlite.org [SQLite download]: https://www.sqlite.org/download.html +[Upgrading]: https://github.com/OpenBEL/openbel-api/blob/master/UPGRADING.md [RubyGems]: https://rubygems.org [RDF]: http://www.w3.org/RDF/ [Auth0]: https://auth0.com/ @@ -258,4 +247,4 @@ Built with collaboration and a lot of :heart: by the [OpenBEL][OpenBEL] communit [Resource RDF 20150611]: http://build.openbel.org/browse/OR-RRD2/latestSuccessful/artifact [Resource Search 20150611]: http://build.openbel.org/browse/OR-RSD2/latestSuccessful/artifact [Nginx]: http://nginx.org/ -[MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#mongodb-user-authentication +[MongoDB User Authentication]: https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Nanopub-Store#mongodb-user-authentication diff --git a/UPGRADING.md b/UPGRADING.md index 6f9ccd8..0aca266 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -30,7 +30,7 @@ Note: MongoDB 3.2 uses the *wiredTiger* storage engine by default. If you previo ### MongoDB Migration -The 0.6.0 version of OpenBEL API introduces a change to how evidence facets are stored in MongoDB. +The 0.6.0 version of OpenBEL API introduces a change to how nanopub facets are stored in MongoDB. #### Change Detail @@ -38,21 +38,21 @@ The 0.6.0 version of OpenBEL API introduces a change to how evidence facets are Collections: -- `evidence` - - Stores evidence.facets as strings. -- `evidence_facets` - - Stores evidence facet objects for all searches. +- `nanopub` + - Stores nanopub.facets as strings. +- `nanopub_facets` + - Stores nanopub facet objects for all searches. ##### 0.6.x Collections: -- `evidence` - - Stores evidence.facets as JSON objects for use in Mongo aggregation operations. -- `evidence_facet_cache` - - Stores the facet collection name for each unique evidence search. -- `evidence_facet_cache_{UUID}` - - Stores evidence facet objects for a specific evidence search. +- `nanopub` + - Stores nanopub.facets as JSON objects for use in Mongo aggregation operations. +- `nanopub_facet_cache` + - Stores the facet collection name for each unique nanopub search. +- `nanopub_facet_cache_{UUID}` + - Stores nanopub facet objects for a specific nanopub search. #### Migration Procedure @@ -66,9 +66,9 @@ It is recommended to stop OpenBEL API and MongoDB before migrating. - `git clone https://github.com/OpenBEL/openbel-api.git` 4. Change directory to the 0.6.x migrations directory. - `cd openbel-api/tools/migrations/0.6.x` -5. Run *migrate_evidence_facets.rb* to update evidence.facets to JSON objects. - - `./migrate_evidence_facets.rb YOUR_CONFIG.yml` or `jruby migrate_evidence_facets.rb YOUR_CONFIG.yml` -6. Run *drop_unused_collection.rb* to remove the old *evidence_facets* collection. +5. Run *migrate_nanopub_facets.rb* to update nanopub.facets to JSON objects. + - `./migrate_nanopub_facets.rb YOUR_CONFIG.yml` or `jruby migrate_nanopub_facets.rb YOUR_CONFIG.yml` +6. Run *drop_unused_collection.rb* to remove the old *nanopub_facets* collection. - `./drop_unused_collection.rb YOUR_CONFIG.yml` or `jruby drop_unused_collection.rb YOUR_CONFIG.yml` 7. Start MongoDB daemon. 8. Start OpenBEL API. diff --git a/VERSION b/VERSION index b616048..7dea76e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.2 +1.0.1 diff --git a/app/openbel/api/app.rb b/app/openbel/api/app.rb index a3b79bd..45b780f 100644 --- a/app/openbel/api/app.rb +++ b/app/openbel/api/app.rb @@ -2,12 +2,12 @@ # TODO This should probably be in app-config.rb. require 'jrjackson' +require 'bel_parser' require_relative 'util' require 'rack/cors' require 'sinatra/base' -require "sinatra/reloader" require "sinatra/cookies" require_relative 'version' @@ -15,12 +15,12 @@ require_relative 'routes/base' require_relative 'routes/root' require_relative 'routes/annotations' -require_relative 'routes/evidence' +require_relative 'routes/authenticate' require_relative 'routes/datasets' require_relative 'routes/expressions' -require_relative 'routes/functions' +require_relative 'routes/language' require_relative 'routes/namespaces' -require_relative 'routes/authenticate' +require_relative 'routes/nanopubs' require_relative 'routes/version' require_relative 'middleware/auth' @@ -28,13 +28,13 @@ module OpenBEL class Server < Sinatra::Application - configure :development do - register Sinatra::Reloader - end - configure do config = OpenBEL::Config::load! OpenBEL.const_set :Settings, config + + tdbdir = OpenBEL::Settings[:resource_rdf][:jena][:tdb_directory] + BELParser::Resource.default_uri_reader = + BELParser::Resource::JenaTDBReader.new(tdbdir) end if OpenBEL::Settings[:auth][:enabled] @@ -67,19 +67,20 @@ class Server < Sinatra::Application # routes not requiring authentication use OpenBEL::Routes::Root - use OpenBEL::Routes::Version + #use OpenBEL::Routes::Version use OpenBEL::Routes::Annotations + use OpenBEL::Routes::Authenticate use OpenBEL::Routes::Expressions - use OpenBEL::Routes::Functions + use OpenBEL::Routes::Language use OpenBEL::Routes::Namespaces - use OpenBEL::Routes::Authenticate + use OpenBEL::Routes::Version # routes requiring authentication if OpenBEL::Settings[:auth][:enabled] use OpenBEL::JWTMiddleware::Authentication end use OpenBEL::Routes::Datasets - use OpenBEL::Routes::Evidence + use OpenBEL::Routes::Nanopubs end end # vim: ts=2 sts=2 sw=2 diff --git a/app/openbel/api/config.rb b/app/openbel/api/config.rb index 8b7f006..4f5fc86 100644 --- a/app/openbel/api/config.rb +++ b/app/openbel/api/config.rb @@ -1,4 +1,5 @@ require 'dot_hash' +require 'bel_parser' module OpenBEL module Config @@ -35,28 +36,69 @@ def self.load! private def self.validate(cfg) - # validate evidence_store block - evidence_store = cfg[:evidence_store] - unless evidence_store + # validate BEL version + bel = cfg[:bel] + unless bel + return [ + true, <<-ERR.gsub(/ {12}/, '') + The "bel" section has not been configured. + You will need to supply a "bel.version" configuration block. + #{boilerplate_help} + ERR + ] + end + bel_failure = self.validate_bel(bel) + return bel_failure if bel_failure + + # validate nanopub_store block + nanopub_store = cfg[:nanopub_store] + unless nanopub_store + return [ + true, <<-ERR + An "nanopub_store" is not configured. + #{boilerplate_help} + ERR + ] + end + nanopub_failure = self.validate_nanopub_store(cfg[:nanopub_store]) + return nanopub_failure if nanopub_failure + + nil + end + + def self.validate_bel(bel) + unless bel[:version] + return [ + true, <<-ERR + The "bel.version" setting is not configured. This is required to + indicate which BEL version is supported by this OpenBEL API + instance. + #{boilerplate_help} + ERR + ] + end + + version = bel[:version] + unless BELParser::Language.defines_version?(version) + defined_versions = BELParser::Language.versions return [ true, <<-ERR - An "evidence_store" is not configured. + The "bel.version" setting of "#{version}" is not a defined BEL version. Allowed values: #{defined_versions} #{boilerplate_help} ERR ] + end - evidence_failure = self.validate_evidence_store(cfg[:evidence_store]) - return evidence_failure if evidence_failure nil end - def self.validate_evidence_store(evidence_store) - mongo = evidence_store[:mongo] + def self.validate_nanopub_store(nanopub_store) + mongo = nanopub_store[:mongo] unless mongo return [ true, <<-ERR - The "evidence_store.mongo" configuration block is not configured. + The "nanopub_store.mongo" configuration block is not configured. #{boilerplate_help} ERR ] @@ -68,7 +110,7 @@ def self.validate_evidence_store(evidence_store) unless mongo[setting] return [ true, <<-ERR - The "evidence_store.mongo.#{setting}" setting is not configured. + The "nanopub_store.mongo.#{setting}" setting is not configured. #{boilerplate_help} ERR ] @@ -131,7 +173,7 @@ def self.validate_evidence_store(evidence_store) def self.boilerplate_help <<-ERR.gsub(/^\s+/, '') Run the "openbel-config" command to see an example configuration. - See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store for details on how to configure an Evidence Store. + See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Nanopub-Store for details on how to configure a Nanopub Store. ERR end diff --git a/app/openbel/api/helpers/evidence.rb b/app/openbel/api/helpers/nanopub.rb similarity index 70% rename from app/openbel/api/helpers/evidence.rb rename to app/openbel/api/helpers/nanopub.rb index 324d4c2..d4212f9 100644 --- a/app/openbel/api/helpers/evidence.rb +++ b/app/openbel/api/helpers/nanopub.rb @@ -5,9 +5,9 @@ module OpenBEL module Helpers - def render_evidence_collection( + def render_nanopub_collection( name, page_results, start, size, filters, - filtered_total, collection_total, evidence_api + filtered_total, collection_total, nanopub_api ) # see if the user requested a BEL translator (Accept header or ?format) translator = Translators.requested_translator(request, params) @@ -20,7 +20,7 @@ def render_evidence_collection( if wants_default? || !translator facets = page_results[:facets] pager = Pager.new(start, size, filtered_total) - evidence = page_results[:cursor].map { |item| + nanopub = page_results[:cursor].map { |item| item.delete('facets') item }.to_a @@ -36,7 +36,7 @@ def render_evidence_collection( :total_filtered => pager.total_size, :total_pages => pager.total_pages, :current_page => pager.current_page, - :current_page_size => evidence.size, + :current_page_size => nanopub.size, } } } @@ -45,7 +45,7 @@ def render_evidence_collection( options[:previous_page] = pager.previous_page options[:next_page] = pager.next_page - render_collection(evidence, :evidence, options) + render_collection(nanopub, :nanopub, options) else extension = translator_plugin.file_extensions.first @@ -54,18 +54,17 @@ def render_evidence_collection( attachment "#{name}.#{extension}" stream :keep_open do |response| cursor = page_results[:cursor] - dataset_evidence = cursor.lazy.map { |evidence| - evidence.delete('facets') - evidence.delete('_id') - evidence = BEL::Model::Evidence.create(BEL.keys_to_symbols(evidence)) - evidence.bel_statement = BEL::Model::Evidence.parse_statement(evidence) - evidence + dataset_nanopub = cursor.lazy.map { |nanopub| + nanopub.delete('facets') + nanopub.delete('_id') + nanopub = BEL::Nanopub::Nanopub.create(BEL.keys_to_symbols(nanopub)) + nanopub } translator.write( - dataset_evidence, response, - :annotation_reference_map => evidence_api.find_all_annotation_references, - :namespace_reference_map => evidence_api.find_all_namespace_references + dataset_nanopub, response, + :annotation_reference_map => nanopub_api.find_all_annotation_references, + :namespace_reference_map => nanopub_api.find_all_namespace_references ) end end diff --git a/app/openbel/api/middleware/auth.rb b/app/openbel/api/middleware/auth.rb index 55d9fad..a8ffaf3 100644 --- a/app/openbel/api/middleware/auth.rb +++ b/app/openbel/api/middleware/auth.rb @@ -4,7 +4,6 @@ module OpenBEL module JWTMiddleware - def self.encode(payload, secret) ::JWT.encode(payload, secret, 'HS256') end @@ -16,32 +15,29 @@ def self.decode(token, secret, verify, options) def self.check_token(env) cookie_hdr = env['HTTP_COOKIE'] auth_hdr = env['HTTP_AUTHORIZATION'] - if cookie_hdr.nil? and auth_hdr.nil? - raise 'missing authorization cookie/header' + req = Rack::Request.new(env) + token_param = req.params['token'] + if cookie_hdr.nil? && auth_hdr.nil? && token_param.nil? + raise 'missing authorization cookie, header, or parameter' end - if not cookie_hdr.nil? + unless cookie_hdr.nil? cookies = cookie_hdr.split('; ') - selected = cookies.select {|x| x.start_with?('jwt=') } - if selected.size > 0 + selected = cookies.select { |x| x.start_with?('jwt=') } + unless selected.empty? tokens = selected[0].split('=') - if tokens.size > 1 - token = tokens[1] - end - end - if token.nil? - raise 'malformed authorization cookie' + token = tokens[1] if tokens.size > 1 end end - if not auth_hdr.nil? + unless auth_hdr.nil? tokens = auth_hdr.split('Bearer ') - if tokens.size != 2 - raise 'malformed authorization header' - end + raise 'malformed authorization header' if tokens.size != 2 token = tokens[1] end + token = token_param unless token_param.nil? + secret = OpenBEL::Settings[:auth][:secret] secret = Base64.decode64(secret) # whether we should verify the token @@ -52,6 +48,7 @@ def self.check_token(env) begin decoded_token = decode(token, secret, verify, options) rescue ::JWT::VerificationError => ve + puts ve.inspect raise 'invalid authorization token' rescue ::JWT::DecodeError => je puts je.inspect @@ -62,30 +59,26 @@ def self.check_token(env) exp = env['jwt.payload']['exp'] now = Time.now.to_i - if now > exp - raise 'token expired' - end + raise 'token expired' if now > exp env['email'] = env['jwt.payload']['email'] end class Authentication def initialize(app, opts = {}) - @app = app - @paths = opts.fetch(:paths, []) + @app = app + @paths = opts.fetch(:paths, []) end def call(env) check = false - if @paths.size == 0 + if @paths.empty? # w/out paths, always check for token check = true else path = env['PATH_INFO'] # w/ paths, only check for token iff matched - if @paths.any? {|x| path.start_with?(x)} - check = true - end + check = true if @paths.any? { |x| path.start_with?(x) } end if check @@ -101,8 +94,8 @@ def call(env) private def _401(message) - hdrs = {'Content-Type' => 'application/json'} - msg = {error: message } + hdrs = { 'Content-Type' => 'application/json' } + msg = { error: message } [401, hdrs, [msg.to_json]] end end diff --git a/app/openbel/api/resources/annotation.rb b/app/openbel/api/resources/annotation.rb index 7b527e4..b0c6a13 100644 --- a/app/openbel/api/resources/annotation.rb +++ b/app/openbel/api/resources/annotation.rb @@ -22,9 +22,9 @@ class AnnotationSerializer < BaseSerializer schema do type :annotation property :rdf_uri, item.uri.to_s - property :name, item.prefLabel - property :prefix, item.prefix - property :domain, item.domain + property :name, item.pref_label.first + property :prefix, item.prefix.first + property :domain, item.domain.first end end @@ -85,14 +85,14 @@ class AnnotationValueSerializer < BaseSerializer type :annotation_value property :rdf_uri, item.uri.to_s property :type, [item.type].flatten.map(&:to_s) - property :identifier, item.identifier - property :name, item.prefLabel + property :identifier, item.identifier.first + property :name, item.pref_label.first entity :annotation, item.annotation, AnnotationSerializer # Support inclusion of the matched text when annotation values are filtered by # a full-text search. - if item.match_text - property :match_text, item.match_text + if item.respond_to?(:match_text) && item.match_text + property :match_text, item.match_text end setup(item) diff --git a/app/openbel/api/resources/function.rb b/app/openbel/api/resources/function.rb index 61be424..0b5bc9d 100644 --- a/app/openbel/api/resources/function.rb +++ b/app/openbel/api/resources/function.rb @@ -11,11 +11,10 @@ class FunctionSerializer < BaseSerializer schema do type :function properties do |p| - p.short_form item[:short_form] - p.long_form item[:long_form] - p.description item[:description] - p.return_type item[:return_type] - p.signatures item[:signatures] + p.short_form item.short + p.long_form item.long + p.description item.description + p.return_type item.return_type.to_sym end end end @@ -26,12 +25,11 @@ class FunctionResourceSerializer < BaseSerializer schema do type :function properties do |p| - p.functions item + p.function item end - link :self, link_self(item.first[:short_form]) - link :next, link_next - link :collection, link_collection + link :self, link_self(item[:long_form]) + link :collection, link_collection end private @@ -45,53 +43,32 @@ def link_self(id) def link_collection { - :type => :'function_collection', + :type => :function_collection, :href => "#{base_url}/api/functions" } end - - def link_next - fx_values = FUNCTIONS.values.uniq.sort_by { |fx| - fx[:short_form] - } - next_fx = fx_values[fx_values.index(item) + 1] - { - :type => :function, - :href => next_fx ? - "#{base_url}/api/functions/#{next_fx[:short_form]}" : - nil - } - end end class FunctionCollectionSerializer < BaseSerializer adapter Oat::Adapters::HAL schema do - type :'function_collection' + type :function_collection properties do |p| - p.functions item + p.function_collection item end - link :self, link_self - link :start, link_start(item.first[:short_form]) + link :self, link_self end private def link_self { - :type => :'function_collection', + :type => :function_collection, :href => "#{base_url}/api/functions" } end - - def link_start(first_function) - { - :type => :function, - :href => "#{base_url}/api/functions/#{first_function}" - } - end end end end diff --git a/app/openbel/api/resources/namespace.rb b/app/openbel/api/resources/namespace.rb index 3aa2cd8..78df2f5 100644 --- a/app/openbel/api/resources/namespace.rb +++ b/app/openbel/api/resources/namespace.rb @@ -22,9 +22,9 @@ class NamespaceSerializer < BaseSerializer schema do type :namespace property :rdf_uri, item.uri.to_s - property :name, item.prefLabel - property :prefix, item.prefix - property :domain, item.domain + property :name, item.pref_label.first + property :prefix, item.prefix.first + property :domain, item.domain.first end end @@ -86,16 +86,16 @@ class NamespaceValueSerializer < BaseSerializer type :namespace_value property :rdf_uri, item.uri.to_s property :type, [item.type].flatten.map(&:to_s) - property :identifier, item.identifier - property :name, item.prefLabel - property :title, item.title - property :species, item.fromSpecies + property :identifier, item.identifier.first + property :name, item.pref_label.first + property :title, item.title.first + property :species, item.from_species.first entity :namespace, item.namespace, NamespaceSerializer # Support inclusion of the matched text when annotation values are filtered by # a full-text search. - if item.match_text - property :match_text, item.match_text + if item.respond_to?(:match_text) && item.match_text + property :match_text, item.match_text end end end @@ -160,10 +160,10 @@ class ValueEquivalenceSerializer < BaseSerializer type :value_equivalence property :value, item.value property :type, item.type ? item.type.sub(VOCABULARY_RDF, '') : nil - property :identifier, item.identifier - property :title, item.title - property :species, item.fromSpecies - property :namespace_uri, item.inScheme + property :identifier, item.identifier.first + property :title, item.title.first + property :species, item.from_species.first + property :namespace_uri, item.in_scheme.first property :value_equivalence_collection, item.equivalences, NamespaceValueSerializer end diff --git a/app/openbel/api/resources/evidence.rb b/app/openbel/api/resources/nanopub.rb similarity index 67% rename from app/openbel/api/resources/evidence.rb rename to app/openbel/api/resources/nanopub.rb index 1e36a96..8346960 100644 --- a/app/openbel/api/resources/evidence.rb +++ b/app/openbel/api/resources/nanopub.rb @@ -3,29 +3,29 @@ module OpenBEL module Resource - module Evidence + module Nanopub - class EvidenceSerializer < BaseSerializer + class NanopubSerializer < BaseSerializer adapter Oat::Adapters::HAL schema do - type :evidence + type :nanopub property :bel_statement, item['bel_statement'] property :citation, item['citation'] - property :summary_text, item['summary_text'] + property :support, item['support'] property :experiment_context, item['experiment_context'] property :metadata, item['metadata'] property :id, item['_id'] end end - class EvidenceResourceSerializer < BaseSerializer + class NanopubResourceSerializer < BaseSerializer adapter Oat::Adapters::HAL schema do - type :evidence + type :nanopub properties do |p| - p.evidence item + p.nanopub item end link :self, link_self @@ -38,25 +38,25 @@ def link_self id = item[:id] || context[:_id] item.delete(:id) { - :type => :evidence, - :href => "#{base_url}/api/evidence/#{id}" + :type => :nanopub, + :href => "#{base_url}/api/nanopubs/#{id}" } end def link_collection { - :type => :evidence_collection, - :href => "#{base_url}/api/evidence" + :type => :nanopub_collection, + :href => "#{base_url}/api/nanopubs" } end end - class EvidenceCollectionSerializer < BaseSerializer + class NanopubCollectionSerializer < BaseSerializer adapter Oat::Adapters::HAL schema do - type :evidence_collection - property :evidence_collection, item + type :nanopub_collection + property :nanopub_collection, item property :facets, context[:facets] property :metadata, context[:metadata] link :self, link_self @@ -71,16 +71,16 @@ def link_self start = context[:start] size = context[:size] { - :type => :evidence_collection, - :href => "#{base_url}/api/evidence?start=#{start}&size=#{size}&#{filter_query_params.join('&')}" + :type => :nanopub_collection, + :href => "#{base_url}/api/nanopubs?start=#{start}&size=#{size}&#{filter_query_params.join('&')}" } end def link_start size = context[:size] { - :type => :evidence_collection, - :href => "#{base_url}/api/evidence?start=0&size=#{size}&#{filter_query_params.join('&')}" + :type => :nanopub_collection, + :href => "#{base_url}/api/nanopubs?start=0&size=#{size}&#{filter_query_params.join('&')}" } end @@ -89,8 +89,8 @@ def link_previous return {} unless previous_page { - :type => :evidence_collection, - :href => "#{base_url}/api/evidence?start=#{previous_page.start_offset}&size=#{previous_page.page_size}&#{filter_query_params.join('&')}" + :type => :nanopub_collection, + :href => "#{base_url}/api/nanopubs?start=#{previous_page.start_offset}&size=#{previous_page.page_size}&#{filter_query_params.join('&')}" } end @@ -99,14 +99,14 @@ def link_next return {} unless next_page { - :type => :evidence_collection, - :href => "#{base_url}/api/evidence?start=#{next_page.start_offset}&size=#{next_page.page_size}&#{filter_query_params.join('&')}" + :type => :nanopub_collection, + :href => "#{base_url}/api/nanopubs?start=#{next_page.start_offset}&size=#{next_page.page_size}&#{filter_query_params.join('&')}" } end def filter_query_params context[:filters].map { |filter| - "filter=#{filter}" + "filter=#{MultiJson.dump(filter)}" } end end diff --git a/app/openbel/api/resources/evidence_transform.rb b/app/openbel/api/resources/nanopub_transform.rb similarity index 90% rename from app/openbel/api/resources/evidence_transform.rb rename to app/openbel/api/resources/nanopub_transform.rb index 3ff9eef..a8abb5e 100644 --- a/app/openbel/api/resources/evidence_transform.rb +++ b/app/openbel/api/resources/nanopub_transform.rb @@ -2,7 +2,7 @@ module OpenBEL module Resource - module Evidence + module Nanopub class AnnotationTransform @@ -18,9 +18,9 @@ def initialize(annotations) @annotations = annotations end - def transform_evidence!(evidence, base_url) - if evidence - experiment_context = evidence.experiment_context + def transform_nanopub!(nanopub, base_url) + if nanopub + experiment_context = nanopub.experiment_context if experiment_context != nil experiment_context.values.map! { |annotation| transform_annotation(annotation, base_url) @@ -103,12 +103,12 @@ def free_annotation(name, value) class AnnotationGroupingTransform - ExperimentContext = ::BEL::Model::ExperimentContext + ExperimentContext = ::BEL::Nanopub::ExperimentContext - def transform_evidence!(evidence) - experiment_context = evidence.experiment_context + def transform_nanopub!(nanopub) + experiment_context = nanopub.experiment_context if experiment_context != nil - evidence.experiment_context = ExperimentContext.new( + nanopub.experiment_context = ExperimentContext.new( experiment_context.group_by { |annotation| annotation[:name] }.values.map do |grouped_annotation| diff --git a/app/openbel/api/resources/relationship.rb b/app/openbel/api/resources/relationship.rb new file mode 100644 index 0000000..afb8178 --- /dev/null +++ b/app/openbel/api/resources/relationship.rb @@ -0,0 +1,74 @@ +require 'bel' +require_relative 'base' + +module OpenBEL + module Resource + module Relationships + + class RelationshipSerializer < BaseSerializer + adapter Oat::Adapters::HAL + + schema do + type :relationship + properties do |p| + p.short_form item.short + p.long_form item.long + p.description item.description + end + end + end + + class RelationshipResourceSerializer < BaseSerializer + adapter Oat::Adapters::HAL + + schema do + type :relationship + properties do |p| + p.relation item + end + + link :self, link_self(item[:long_form]) + link :collection, link_collection + end + + private + + def link_self(id) + { + :type => :relationship, + :href => "#{base_url}/api/relationships/#{id}" + } + end + + def link_collection + { + :type => :relationship_collection, + :href => "#{base_url}/api/relationships" + } + end + end + + class RelationshipCollectionSerializer < BaseSerializer + adapter Oat::Adapters::HAL + + schema do + type :relationship_collection + properties do |p| + p.relationship_collection item + end + + link :self, link_self + end + + private + + def link_self + { + :type => :relationship_collection, + :href => "#{base_url}/api/relationships" + } + end + end + end + end +end diff --git a/app/openbel/api/routes/annotations.rb b/app/openbel/api/routes/annotations.rb index 3a543c9..a098a9e 100644 --- a/app/openbel/api/routes/annotations.rb +++ b/app/openbel/api/routes/annotations.rb @@ -58,7 +58,7 @@ def initialize(app) render_collection( annotations.sort { |x,y| - x.prefLabel.to_s <=> y.prefLabel.to_s + x.pref_label.to_s <=> y.pref_label.to_s }, :annotation ) diff --git a/app/openbel/api/routes/base.rb b/app/openbel/api/routes/base.rb index 3b9d7c2..ffe1f6b 100644 --- a/app/openbel/api/routes/base.rb +++ b/app/openbel/api/routes/base.rb @@ -3,8 +3,9 @@ require 'multi_json' require_relative '../resources/annotation' require_relative '../resources/completion' -require_relative '../resources/evidence' +require_relative '../resources/nanopub' require_relative '../resources/function' +require_relative '../resources/relationship' require_relative '../resources/match_result' require_relative '../resources/namespace' require_relative '../schemas' @@ -14,9 +15,10 @@ module Routes class Base < Sinatra::Application include OpenBEL::Resource::Annotations - include OpenBEL::Resource::Evidence + include OpenBEL::Resource::Nanopub include OpenBEL::Resource::Expressions include OpenBEL::Resource::Functions + include OpenBEL::Resource::Relationships include OpenBEL::Resource::MatchResults include OpenBEL::Resource::Namespaces include OpenBEL::Schemas @@ -36,15 +38,17 @@ class Base < Sinatra::Application :completion_collection => CompletionCollectionSerializer, :function => FunctionResourceSerializer, :function_collection => FunctionCollectionSerializer, + :relationship => RelationshipResourceSerializer, + :relationship_collection => RelationshipCollectionSerializer, :match_result => MatchResultResourceSerializer, :match_result_collection => MatchResultCollectionSerializer, :namespace => NamespaceResourceSerializer, :namespace_collection => NamespaceCollectionSerializer, :namespace_value => NamespaceValueResourceSerializer, :namespace_value_collection => NamespaceValueCollectionSerializer, - :evidence => EvidenceSerializer, - :evidence_resource => EvidenceResourceSerializer, - :evidence_collection => EvidenceCollectionSerializer + :nanopub => NanopubSerializer, + :nanopub_resource => NanopubResourceSerializer, + :nanopub_collection => NanopubCollectionSerializer } disable :protection @@ -111,9 +115,9 @@ def validate_media_type!(content_type, options = {}) end end - def read_evidence + def read_nanopub halt 415 unless ::BEL.translator(request.media_type) - ::BEL.evidence(request.body, request.media_type, :symbolize_keys => true) + ::BEL.nanopub(request.body, request.media_type, :symbolize_keys => true) end def read_json diff --git a/app/openbel/api/routes/datasets.rb b/app/openbel/api/routes/datasets.rb index ee6e5ba..501e701 100644 --- a/app/openbel/api/routes/datasets.rb +++ b/app/openbel/api/routes/datasets.rb @@ -1,12 +1,14 @@ require 'bel' require 'bel/util' require 'rdf' +require 'rdf/vocab' require 'cgi' require 'multi_json' -require 'openbel/api/evidence/mongo' -require 'openbel/api/evidence/facet_filter' -require_relative '../resources/evidence_transform' -require_relative '../helpers/evidence' +require 'openbel/api/nanopub/mongo' +require 'openbel/api/nanopub/facet_filter' +require 'openbel/api/helpers/uuid_generator' +require_relative '../resources/nanopub_transform' +require_relative '../helpers/nanopub' require_relative '../helpers/filters' require_relative '../helpers/pager' @@ -14,9 +16,10 @@ module OpenBEL module Routes class Datasets < Base - include OpenBEL::Evidence::FacetFilter - include OpenBEL::Resource::Evidence + include OpenBEL::Nanopub::FacetFilter + include OpenBEL::Resource::Nanopub include OpenBEL::Helpers + include OpenBEL::Helpers::UUIDGenerator DEFAULT_TYPE = 'application/hal+json' ACCEPTED_TYPES = { @@ -28,15 +31,20 @@ class Datasets < Base MONGO_BATCH = 500 FACET_THRESHOLD = 10000 + DC = ::RDF::Vocab::DC + VOID = ::RDF::Vocab::VOID + FOAF = ::RDF::Vocab::FOAF def initialize(app) super BEL.translator(:rdf) - # Evidence API using Mongo. - mongo = OpenBEL::Settings[:evidence_store][:mongo] - @api = OpenBEL::Evidence::Evidence.new(mongo) + @bel_version = OpenBEL::Settings[:bel][:version] + + # nanopub API using Mongo. + mongo = OpenBEL::Settings[:nanopub_store][:mongo] + @api = OpenBEL::Nanopub::Nanopub.new(mongo) # RdfRepository using Jena. @rr = BEL::RdfRepository.plugins[:jena].create_repository( @@ -63,19 +71,19 @@ def initialize(app) def check_dataset(io, type) begin - evidence = BEL.evidence(io, type).each.first + nanopub = BEL.nanopub(io, type).each.first - unless evidence + unless nanopub halt( 400, { 'Content-Type' => 'application/json' }, - render_json({ :status => 400, :msg => 'No BEL evidence was provided. Evidence is required to infer dataset information.' }) + render_json({ :status => 400, :msg => 'No BEL nanopub was provided. nanopub is required to infer dataset information.' }) ) end - void_dataset_uri = RDF::URI("#{base_url}/api/datasets/#{self.generate_uuid}") + void_dataset_uri = RDF::URI("#{base_url}/api/datasets/#{generate_uuid}") - void_dataset = evidence.to_void_dataset(void_dataset_uri) + void_dataset = nanopub.to_void_dataset(void_dataset_uri) unless void_dataset halt( 400, @@ -85,7 +93,7 @@ def check_dataset(io, type) end identifier_statement = void_dataset.query( - RDF::Statement.new(void_dataset_uri, RDF::DC.identifier, nil) + RDF::Statement.new(void_dataset_uri, DC.identifier, nil) ).to_a.first unless identifier_statement halt( @@ -100,10 +108,10 @@ def check_dataset(io, type) ) end - datasets = @rr.query_pattern(RDF::Statement.new(nil, RDF.type, RDF::VOID.Dataset)) + datasets = @rr.query_pattern(RDF::Statement.new(nil, RDF.type, VOID.Dataset)) existing_dataset = datasets.find { |dataset_statement| @rr.has_statement?( - RDF::Statement.new(dataset_statement.subject, RDF::DC.identifier, identifier_statement.object) + RDF::Statement.new(dataset_statement.subject, DC.identifier, identifier_statement.object) ) } @@ -131,24 +139,24 @@ def check_dataset(io, type) def dataset_exists?(uri) @rr.has_statement?( - RDF::Statement.new(uri, RDF.type, RDF::VOID.Dataset) + RDF::Statement.new(uri, RDF.type, VOID.Dataset) ) end def retrieve_dataset(uri) dataset = {} identifier = @rr.query( - RDF::Statement.new(uri, RDF::DC.identifier, nil) + RDF::Statement.new(uri, DC.identifier, nil) ).first dataset[:identifier] = identifier.object.to_s if identifier title = @rr.query( - RDF::Statement.new(uri, RDF::DC.title, nil) + RDF::Statement.new(uri, DC.title, nil) ).first dataset[:title] = title.object.to_s if title description = @rr.query( - RDF::Statement.new(uri, RDF::DC.description, nil) + RDF::Statement.new(uri, DC.description, nil) ).first dataset[:description] = description.object.to_s if description @@ -158,22 +166,22 @@ def retrieve_dataset(uri) dataset[:waiver] = waiver.object.to_s if waiver creator = @rr.query( - RDF::Statement.new(uri, RDF::DC.creator, nil) + RDF::Statement.new(uri, DC.creator, nil) ).first dataset[:creator] = creator.object.to_s if creator license = @rr.query( - RDF::Statement.new(uri, RDF::DC.license, nil) + RDF::Statement.new(uri, DC.license, nil) ).first dataset[:license] = license.object.to_s if license publisher = @rr.query( - RDF::Statement.new(uri, RDF::DC.publisher, nil) + RDF::Statement.new(uri, DC.publisher, nil) ).first if publisher publisher.object contact_info = @rr.query( - RDF::Statement.new(publisher.object, RDF::FOAF.mbox, nil) + RDF::Statement.new(publisher.object, FOAF.mbox, nil) ).first dataset[:contact_info] = contact_info.object.to_s if contact_info end @@ -240,58 +248,58 @@ def retrieve_dataset(uri) dataset = retrieve_dataset(void_dataset_uri) dataset_id = dataset[:identifier] - # Add batches of read evidence objects; save to Mongo and RDF. + # Add batches of read nanopub objects; save to Mongo and RDF. # TODO Add JRuby note regarding Enumerator threading. - evidence_count = 0 - evidence_batch = [] + nanopub_count = 0 + nanopub_batch = [] # Clear out all facets before loading dataset. @api.delete_facets - BEL.evidence(io, type).each do |ev| + BEL.nanopub(io, type, :language => @bel_version).each do |nanopub| # Standardize annotations from experiment_context. - @annotation_transform.transform_evidence!(ev, base_url) - - ev.metadata[:dataset] = dataset_id - facets = map_evidence_facets(ev) - ev.bel_statement = ev.bel_statement.to_s - hash = BEL.object_convert(String, ev.to_h) { |str| - str.gsub(/\n/, "\\n").gsub(/\r/, "\\r") - } - hash[:facets] = facets + @annotation_transform.transform_nanopub!(nanopub, base_url) + + nanopub.metadata[:dataset] = dataset_id + facets = map_nanopub_facets(nanopub) + hash = BEL.object_convert(String, nanopub.to_h) { |str| + str.gsub(/\n/, "\\n").gsub(/\r/, "\\r") + } + hash[:facets] = facets # Create dataset field for efficient removal. - hash[:_dataset] = dataset_id + hash[:_dataset] = dataset_id + hash[:bel_statement] = hash[:bel_statement].to_s - evidence_batch << hash + nanopub_batch << hash - if evidence_batch.size == MONGO_BATCH - _ids = @api.create_evidence(evidence_batch) + if nanopub_batch.size == MONGO_BATCH + _ids = @api.create_nanopub(nanopub_batch) dataset_parts = _ids.map { |object_id| - RDF::Statement.new(void_dataset_uri, RDF::DC.hasPart, object_id.to_s) + RDF::Statement.new(void_dataset_uri, DC.hasPart, object_id.to_s) } @rr.insert_statements(dataset_parts) - evidence_batch.clear + nanopub_batch.clear # Clear out all facets after FACET_THRESHOLD nanopubs have been seen. - evidence_count += MONGO_BATCH - if evidence_count >= FACET_THRESHOLD + nanopub_count += MONGO_BATCH + if nanopub_count >= FACET_THRESHOLD @api.delete_facets - evidence_count = 0 + nanopub_count = 0 end end end - unless evidence_batch.empty? - _ids = @api.create_evidence(evidence_batch) + unless nanopub_batch.empty? + _ids = @api.create_nanopub(nanopub_batch) dataset_parts = _ids.map { |object_id| - RDF::Statement.new(void_dataset_uri, RDF::DC.hasPart, object_id.to_s) + RDF::Statement.new(void_dataset_uri, DC.hasPart, object_id.to_s) } @rr.insert_statements(dataset_parts) - evidence_batch.clear + nanopub_batch.clear end # Clear out all facets after the dataset is completely loaded. @@ -314,15 +322,15 @@ def retrieve_dataset(uri) :type => 'dataset', :href => void_dataset_uri.to_s }, - :evidence_collection => { - :type => 'evidence_collection', - :href => "#{base_url}/api/datasets/#{id}/evidence" + :nanopub_collection => { + :type => 'nanopub_collection', + :href => "#{base_url}/api/datasets/#{id}/nanopub" } } }) end - get '/api/datasets/:id/evidence' do + get '/api/datasets/:id/nanopub' do id = params[:id] void_dataset_uri = RDF::URI("#{base_url}/api/datasets/#{id}") halt 404 unless dataset_exists?(void_dataset_uri) @@ -336,12 +344,12 @@ def retrieve_dataset(uri) filters = validate_filters! - collection_total = @api.count_evidence - filtered_total = @api.count_evidence(filters) - page_results = @api.find_dataset_evidence(dataset, filters, start, size, faceted, max_values_per_facet) + collection_total = @api.count_nanopub + filtered_total = @api.count_nanopub(filters) + page_results = @api.find_dataset_nanopub(dataset, filters, start, size, faceted, max_values_per_facet) name = dataset[:identifier].gsub(/[^\w]/, '_') - render_evidence_collection( + render_nanopub_collection( name, page_results, start, size, filters, filtered_total, collection_total, @api ) @@ -349,7 +357,7 @@ def retrieve_dataset(uri) get '/api/datasets' do dataset_uris = @rr.query( - RDF::Statement.new(nil, RDF.type, RDF::VOID.Dataset) + RDF::Statement.new(nil, RDF.type, VOID.Dataset) ).map { |statement| statement.subject }.to_a @@ -363,9 +371,9 @@ def retrieve_dataset(uri) :type => 'dataset', :href => uri.to_s }, - :evidence_collection => { - :type => 'evidence_collection', - :href => "#{uri}/evidence" + :nanopub_collection => { + :type => 'nanopub_collection', + :href => "#{uri}/nanopub" } } } @@ -381,7 +389,7 @@ def retrieve_dataset(uri) halt 404 unless dataset_exists?(void_dataset_uri) dataset = retrieve_dataset(void_dataset_uri) - # XXX Removes all facets due to load of many evidence. + # XXX Removes all facets due to load of many nanopub. @api.delete_dataset(dataset[:identifier]) @rr.delete_statement(RDF::Statement.new(void_dataset_uri, nil, nil)) @@ -390,7 +398,7 @@ def retrieve_dataset(uri) delete '/api/datasets' do datasets = @rr.query( - RDF::Statement.new(nil, RDF.type, RDF::VOID.Dataset) + RDF::Statement.new(nil, RDF.type, VOID.Dataset) ).map { |stmt| stmt.subject }.to_a @@ -398,31 +406,13 @@ def retrieve_dataset(uri) datasets.each do |void_dataset_uri| dataset = retrieve_dataset(void_dataset_uri) - # XXX Removes all facets due to load of many evidence. + # XXX Removes all facets due to load of many nanopub. @api.delete_dataset(dataset[:identifier]) @rr.delete_statement(RDF::Statement.new(void_dataset_uri, nil, nil)) end status 202 end - - private - - unless self.methods.include?(:generate_uuid) - - # Dynamically defines an efficient UUID method for the current ruby. - if RUBY_ENGINE =~ /^jruby/i - java_import 'java.util.UUID' - define_method(:generate_uuid) do - Java::JavaUtil::UUID.random_uuid.to_s - end - else - require 'uuid' - define_method(:generate_uuid) do - UUID.generate - end - end - end end end end diff --git a/app/openbel/api/routes/expressions.rb b/app/openbel/api/routes/expressions.rb index 681489d..b8cd4c4 100644 --- a/app/openbel/api/routes/expressions.rb +++ b/app/openbel/api/routes/expressions.rb @@ -1,6 +1,11 @@ require 'cgi' require 'bel' require 'uri' +require 'bel_parser/expression/model' +require 'bel_parser/expression/parser' +require 'bel_parser/expression/validator' +require 'bel_parser/resources' +require 'bel_parser/resource/jena_tdb_reader' module OpenBEL module Routes @@ -10,6 +15,10 @@ class Expressions < Base def initialize(app) super + # Obtain configured BEL version. + bel_version = OpenBEL::Settings[:bel][:version] + @spec = BELParser::Language.specification(bel_version) + # RdfRepository using Jena. @rr = BEL::RdfRepository.plugins[:jena].create_repository( :tdb_directory => OpenBEL::Settings[:resource_rdf][:jena][:tdb_directory] @@ -25,7 +34,11 @@ def initialize(app) :database_file => OpenBEL::Settings[:resource_search][:sqlite][:database_file] ) - @sequence_variation = SequenceVariationFunctionHasLocationPredicate.new + @expression_validator = BELParser::Expression::Validator.new( + @spec, + BELParser::Resources::DEFAULT_NAMESPACES, + BELParser::Resource.default_uri_reader, + BELParser::Resource.default_url_reader) end options '/api/expressions/*/completions' do @@ -43,26 +56,11 @@ def initialize(app) status 200 end - options '/api/expressions/*/syntax-validations/?' do + options '/api/expressions/*/validation-result/?' do response.headers['Allow'] = 'OPTIONS,GET' status 200 end - options '/api/expressions/*/semantic-validations/?' do - response.headers['Allow'] = 'OPTIONS,GET' - status 200 - end - - # options '/api/expressions/*/ortholog' do - # response.headers['Allow'] = 'OPTIONS,GET' - # status 200 - # end - - # options '/api/expressions/*/ortholog/:species' do - # response.headers['Allow'] = 'OPTIONS,GET' - # status 200 - # end - helpers do def normalize_relationship(relationship) @@ -73,22 +71,28 @@ def normalize_relationship(relationship) def statement_components(bel_statement, flatten = false) obj = {} if flatten - obj[:subject] = bel_statement.subject ? bel_statement.subject.to_bel : nil - obj[:relationship] = normalize_relationship(bel_statement.relationship) - obj[:object] = bel_statement.object ? bel_statement.object.to_bel : nil + obj.merge!({ + :subject => bel_statement.subject ? bel_statement.subject.to_s : nil, + :relationship => bel_statement.relationship && bel_statement.relationship.long, + :object => bel_statement.object ? bel_statement.object.to_s : nil + }) else - obj[:subject] = term_components(bel_statement.subject) - obj[:relationship] = normalize_relationship(bel_statement.relationship) - obj[:object] = term_components(bel_statement.object) + obj.merge!({ + :subject => term_components(bel_statement.subject), + :relationship => bel_statement.relationship && bel_statement.relationship.to_h, + :object => term_components(bel_statement.object) + }) end + obj end def arg_components(bel_argument) - if bel_argument.respond_to? :fx - term_components(bel_argument) - elsif bel_argument.respond_to? :ns + case bel_argument + when BELParser::Expression::Model::Parameter parameter_components(bel_argument) + when BELParser::Expression::Model::Term + term_components(bel_argument) else nil end @@ -99,7 +103,7 @@ def term_components(bel_term) { :term => { - :fx => bel_term.fx, + :function => bel_term.function.to_h, :arguments => bel_term.arguments.map { |a| arg_components(a) } } } @@ -107,14 +111,39 @@ def term_components(bel_term) def parameter_components(bel_parameter) return nil unless bel_parameter + namespace = bel_parameter.namespace && bel_parameter.namespace.to_s { :parameter => { - :ns => bel_parameter.ns ? bel_parameter.ns.prefix : nil, + :namespace => namespace, :value => bel_parameter.value.to_s } } end + + def syntax_results(results) + results.select do |res| + res.is_a? BELParser::Language::Syntax::SyntaxResult + end + end + + def semantics_results(results) + results.select do |res| + res.is_a? BELParser::Language::Semantics::SemanticsResult + end + end + + def successfully_matched_signatures(results) + results.select do |res| + res.is_a?(BELParser::Language::Semantics::SignatureMappingSuccess) + end + end + + def signature_warnings(results) + results.select do |res| + res.is_a?(BELParser::Language::Semantics::SignatureMappingWarning) + end + end end get '/api/expressions/*/completions/?' do @@ -123,7 +152,7 @@ def parameter_components(bel_parameter) halt 400 unless bel and caret_position begin - completions = BEL::Completion.complete(bel, @search, @namespaces, caret_position) + completions = BEL::Completion.complete(bel, @spec, @search, @namespaces, caret_position) rescue IndexError => ex halt( 400, @@ -145,9 +174,10 @@ def parameter_components(bel_parameter) bel = params[:splat].first flatten = as_bool(params[:flatten]) - statement = BEL::Script.parse(bel).find { |obj| - obj.is_a? BEL::Model::Statement - } + statement = + BELParser::Expression.parse_statements( + bel, + @spec) halt 404 unless statement response.headers['Content-Type'] = 'application/json' @@ -163,23 +193,27 @@ def parameter_components(bel_parameter) flatten = as_bool(params[:flatten]) inner_terms = as_bool(params[:inner_terms]) - terms = BEL::Script.parse(bel).select { |obj| - obj.is_a? BEL::Model::Term - } + terms = + BELParser::Expression.parse_terms( + bel, + @spec) + halt 404 if terms.empty? if !functions.empty? functions = functions.map(&:to_sym) - terms = terms.select { |term| - functions.any? { |match| - term.fx.short_form == match || term.fx.long_form == match - } - } + terms = + terms.select do |term| + functions.any? { |match| term.function === match } + end end if inner_terms - terms = terms.flat_map { |term| - term.arguments.select { |arg| arg.is_a? BEL::Model::Term } - } + terms = + terms.flat_map do |term| + term.arguments.select do |arg| + arg.is_a?(BELParser::Expression::Model::Term) + end + end end terms = terms.to_a @@ -188,7 +222,7 @@ def parameter_components(bel_parameter) response.headers['Content-Type'] = 'application/json' if flatten MultiJson.dump({ - :terms => terms.map { |term| term.to_bel } + :terms => terms.map { |term| term.to_s } }) else MultiJson.dump({ @@ -197,360 +231,16 @@ def parameter_components(bel_parameter) end end - # TODO Relies on LibBEL.bel_parse_statement which is not currently supported. - # get '/api/expressions/*/ortholog/:species' do - # bel = params[:splat].first - # species = params[:species] - # taxon_annotation = @annotations.find('taxon').first - # - # unless taxon_annotation - # halt( - # 404, - # { 'Content-Type' => 'application/json' }, - # render_json({ - # :status => 404, - # :msg => 'Could not find NCBI Taxonomy annotation.' - # }) - # ) - # end - # - # species = taxon_annotation.find(species).first - # - # if species - # species = species.identifier.to_s - # else - # halt( - # 400, - # { 'Content-Type' => 'application/json' }, - # render_json({ - # :status => 400, - # :msg => %Q{Could not find species "#{params[:species]}"} - # }) - # ) - # end - # - # bel_ast = BEL::Parser.parse(bel) - # - # if bel_ast.any?([@sequence_variation]) - # msg = 'Could not orthologize sequence variation terms with location' - # halt( - # 404, - # { 'Content-Type' => 'application/json' }, - # render_json({ - # :status => 404, - # :msg => msg - # }) - # ) - # end - # - # param_transform = ParameterOrthologTransform.new( - # @namespaces, @annotations, species - # ) - # transformed_ast = bel_ast.transform_tree([param_transform]) - # - # if !param_transform.parameter_errors.empty? - # parameters = param_transform.parameter_errors.map { |p| - # p.join(':') - # }.join(', ') - # halt( - # 404, - # { 'Content-Type' => 'application/json' }, - # render_json({ - # :status => 404, - # :msg => "Could not orthologize #{parameters}" - # }) - # ) - # end - # - # # serialize AST to BEL - # bel_serialization = BELSerializationTransform.new - # transformed_ast.transform_tree([bel_serialization]) - # - # # write response - # response.headers['Content-Type'] = 'application/json' - # MultiJson.dump({ - # :original => bel, - # :species => params[:species], - # :orthologized => bel_serialization.bel_string - # }) - # end - - # BEL Syntax Validation - # TODO Move out to a separate route. - get '/api/expressions/*/syntax-validations/?' do - halt 501 - end - - # BEL Semantic Validations - # TODO Move out to a separate route. - get '/api/expressions/*/semantic-validations/?' do - halt 501 - end - - class SequenceVariationFunctionHasLocationPredicate - include BEL::LibBEL - - SEQUENCE_VARIATION_FX = [ - 'fus', 'fusion', - 'pmod', 'proteinModification', - 'sub', 'substitution', - 'trunc', 'truncation' - ] - - def call(ast_node) - # check if AST node is a TERM - if !ast_node.is_a?(BelAstNodeToken) || ast_node.token_type != :BEL_TOKEN_TERM - return false - end - - # check if AST node is a pmod TERM - if !SEQUENCE_VARIATION_FX.include?(ast_node.left.to_typed_node.value) - return false - end - - # walk arg AST nodes until terminal - arg_node = ast_node.right.to_typed_node - while !(arg_node.left.pointer.null? && arg_node.right.pointer.null?) - # check if NV token child - arg_token = arg_node.left.to_typed_node - - if arg_token.token_type == :BEL_TOKEN_NV - # true if namespace value is an integer - node_value = arg_token.right.to_typed_node.value - if integer?(node_value) - return true - end - end - - # advance to the next ARG - arg_node = arg_node.right.to_typed_node - end - - return false - end - - private - - def integer?(value) - begin - Integer(value) - return true - rescue ArgumentError - return false - end - end - end - - class ParameterOrthologTransform - include BEL::LibBEL - - NAMESPACE_PREFERENCE = [ - "hgnc", - "mgi", - "rgd", - "gocc", - "scomp", - "meshcs", - "sfam", - "gobp", - "meshpp", - "chebi", - "schem", - "do", - "meshd", - "sdis", - "sp", - "affx", - "egid", - ] - - def initialize(namespaces, annotations, species_tax_id) - @namespaces = namespaces - @orthology = OrthologAdapter.new( - namespaces, species_tax_id - ) - @species_tax_id = species_tax_id - @parameter_errors = [] - end - - def parameter_errors - @parameter_errors.uniq - end - - def call(ast_node) - if ast_node.is_a?(BelAstNodeToken) && - ast_node.token_type == :BEL_TOKEN_NV - - ns_value = [ - ast_node.left.to_typed_node.value, - ast_node.right.to_typed_node.value - ] - orthologs = @orthology[ns_value] - if !orthologs.empty? - orthologs.sort_by! { |ortholog| namespace_preference(ortholog) } - ortholog = orthologs.first - BEL::LibBEL::bel_free_ast_node(ast_node.left.pointer) - ast_node.left = BelAstNode.new( - bel_new_ast_node_value(:BEL_VALUE_PFX, ortholog[0].upcase) - ) - - BEL::LibBEL::bel_free_ast_node(ast_node.right.pointer) - ast_node.right = BelAstNode.new( - bel_new_ast_node_value(:BEL_VALUE_VAL, ortholog[1]) - ) - else - # flag as ortholog error if this parameter has a namespace and - # the namespace value is either not known or its species differs - # from our target - if ns_value[0] != nil - namespace, value = ns_value - namespace = @namespaces.find(namespace).first - if namespace - value = namespace.find(value).first - if !value || value.fromSpecies != @species_tax_id - @parameter_errors << value - end - end - end - end - end - end - - private - - def namespace_preference(ortholog) - NAMESPACE_PREFERENCE.index(ortholog[0]) - end - end - - class BELSerializationTransform - include BEL::LibBEL - - attr_reader :bel_string - - def initialize - @bel_string = "" - end - - def call(ast_node) - if ast_node.is_a?(BelAstNodeToken) - case ast_node.token_type - when :BEL_TOKEN_STATEMENT - when :BEL_TOKEN_SUBJECT - when :BEL_TOKEN_OBJECT - when :BEL_TOKEN_REL - when :BEL_TOKEN_TERM - when :BEL_TOKEN_ARG - when :BEL_TOKEN_NV - end - else - case ast_node.value_type - when :BEL_VALUE_FX - function(ast_node.value) - when :BEL_VALUE_REL - relationship(ast_node.value) - when :BEL_VALUE_PFX - namespace_prefix(ast_node.value) - when :BEL_VALUE_VAL - namespace_value(ast_node.value) - end - end - end - - def between(ast_node) - if ast_node.is_a?(BelAstNodeToken) - case ast_node.token_type - when :BEL_TOKEN_STATEMENT - when :BEL_TOKEN_SUBJECT - when :BEL_TOKEN_OBJECT - when :BEL_TOKEN_REL - when :BEL_TOKEN_TERM - when :BEL_TOKEN_ARG - token_arg(ast_node) - when :BEL_TOKEN_NV - end - end - end - - def after(ast_node) - if ast_node.is_a?(BelAstNodeToken) - case ast_node.token_type - when :BEL_TOKEN_STATEMENT - when :BEL_TOKEN_SUBJECT - when :BEL_TOKEN_OBJECT - when :BEL_TOKEN_REL - when :BEL_TOKEN_TERM - @bel_string.concat(')') - when :BEL_TOKEN_ARG - when :BEL_TOKEN_NV - end - end - end - - private - - def token_arg(ast_node) - chained_arg_node = ast_node.right - if !chained_arg_node.pointer.null? - chained_arg_node = chained_arg_node.to_typed_node - if !chained_arg_node.left.pointer.null? || - !chained_arg_node.right.pointer.null? - @bel_string.concat(', ') - end - end - end - - def function(fx) - @bel_string.concat(fx).concat('(') - end - - def relationship(rel) - @bel_string.concat(" #{rel} ") - end - - def namespace_prefix(prefix) - return unless prefix - @bel_string.concat(prefix).concat(':') - end - - def namespace_value(value) - @bel_string.concat(value) - end - end - - # Hash-like - class OrthologAdapter - - EMPTY = [].freeze - - def initialize(namespaces, species_tax_id) - @namespaces = namespaces - @species_tax_id = species_tax_id - end - - def [](key) - namespace, value = key + # Produce validation result for BEL expression using the current language. + get '/api/expressions/*/validation/?' do + bel = params[:splat].first + response.headers['Content-Type'] = 'text/plain' - if value.start_with?('"') && value.end_with?('"') - value = value[1...-1] - end + @expression_validator.each( + StringIO.new("#{bel}\n") + ) do |(num, line, ast, result)| - namespace = @namespaces.find(namespace).first - return EMPTY unless namespace - value = namespace.find(value).first - return EMPTY unless value - orthologs = value.orthologs.select { |orth| - orth.fromSpecies == @species_tax_id - }.to_a - return EMPTY if orthologs.empty? - - orthologs.map! { |ortholog_value| - [ - ortholog_value.namespace.prefix, - ortholog_value.prefLabel - ] - } - orthologs + return result.to_s end end end diff --git a/app/openbel/api/routes/functions.rb b/app/openbel/api/routes/functions.rb deleted file mode 100644 index 4888fbd..0000000 --- a/app/openbel/api/routes/functions.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'bel' - -module OpenBEL - module Routes - - class Functions < Base - include BEL::Language - - SORTED_FUNCTIONS = FUNCTIONS.values.uniq.sort_by { |fx| - fx[:short_form] - } - - options '/api/functions' do - response.headers['Allow'] = 'OPTIONS,GET' - status 200 - end - - options '/api/functions/:fx' do - response.headers['Allow'] = 'OPTIONS,GET' - status 200 - end - - get '/api/functions' do - render(SORTED_FUNCTIONS, :function_collection) - end - - # BEL Completion - get '/api/functions/:fx' do - fx_match = FUNCTIONS[params[:fx].to_sym] - halt 404 unless fx_match - - render( - [fx_match], - :function_collection - ) - end - end - end -end -# vim: ts=2 sw=2: -# encoding: utf-8 diff --git a/app/openbel/api/routes/language.rb b/app/openbel/api/routes/language.rb new file mode 100644 index 0000000..4076645 --- /dev/null +++ b/app/openbel/api/routes/language.rb @@ -0,0 +1,118 @@ +require 'bel' +require 'bel_parser' + +module OpenBEL + module Routes + # Language defines and implements the _/api/language_ routes to expose + # BEL functions, relationships, and version configured for the API. + class Language < Base + + JSON = Rack::Mime.mime_type('.json') + TEXT = Rack::Mime.mime_type('.txt') + ACCEPTED_TYPES = {'json' => JSON, 'text' => TEXT} + DEFAULT_TYPE = TEXT + + def initialize(app) + super + bel_version = OpenBEL::Settings[:bel][:version] + @spec = BELParser::Language.specification(bel_version) + end + + options '/api/language' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + options '/api/language/functions' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + options '/api/language/functions/:fx' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + options '/api/language/relationships' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + options '/api/language/relationships/:rel' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + options '/api/language/version' do + response.headers['Allow'] = 'OPTIONS,GET' + status 200 + end + + get '/api/language' do + response.headers['Content-Type'] = 'application/hal+json' + MultiJson.dump({ + :_links => { + :item => [ + { + :href => "#{base_url}/api/language/functions" + }, + { + :href => "#{base_url}/api/language/relationships" + }, + { + :href => "#{base_url}/api/language/version" + } + ] + } + }) + end + + get '/api/language/functions' do + render_collection( + @spec.functions.sort_by(&:long), + :function) + end + + get '/api/language/functions/:fx' do + function = @spec.function(params[:fx].to_sym) + halt 404 unless function + render_resource(function, :function) + end + + get '/api/language/relationships' do + render_collection( + @spec.relationships.sort_by(&:long), + :relationship) + end + + get '/api/language/relationships/:rel' do + relationship = @spec.relationship(params[:rel].to_sym) + halt 404 unless relationship + render_resource(relationship, :relationship) + end + + get '/api/language/version' do + accept_type = request.accept.find { |accept_entry| + ACCEPTED_TYPES.values.include?(accept_entry.to_s) + } + accept_type ||= DEFAULT_TYPE + + format = params[:format] + if format + accept_type = ACCEPTED_TYPES[format] + halt 406 unless accept_type + end + + render_json( + { + :bel_version => { + :string => OpenBEL::Settings[:bel][:version].to_s + } + } + ) + end + end + end +end +# vim: ts=2 sw=2: +# encoding: utf-8 diff --git a/app/openbel/api/routes/namespaces.rb b/app/openbel/api/routes/namespaces.rb index 3e267db..57fa281 100644 --- a/app/openbel/api/routes/namespaces.rb +++ b/app/openbel/api/routes/namespaces.rb @@ -18,7 +18,7 @@ class Namespaces < Base RESULT_TYPES = { :resource => :all, - :name => :prefLabel, + :name => :pref_label, :identifier => :identifier, :title => :title } @@ -92,7 +92,7 @@ def initialize(app) render_collection( namespaces.sort { |x,y| - x.prefLabel.to_s <=> y.prefLabel.to_s + x.pref_label.to_s <=> y.pref_label.to_s }, :namespace ) diff --git a/app/openbel/api/routes/evidence.rb b/app/openbel/api/routes/nanopubs.rb similarity index 56% rename from app/openbel/api/routes/evidence.rb rename to app/openbel/api/routes/nanopubs.rb index e7021b7..aabbe59 100644 --- a/app/openbel/api/routes/evidence.rb +++ b/app/openbel/api/routes/nanopubs.rb @@ -1,25 +1,25 @@ require 'bel' require 'cgi' -require 'openbel/api/evidence/mongo' -require 'openbel/api/evidence/facet_filter' -require_relative '../resources/evidence_transform' -require_relative '../helpers/evidence' +require 'openbel/api/nanopub/mongo' +require 'openbel/api/nanopub/facet_filter' +require_relative '../resources/nanopub_transform' +require_relative '../helpers/nanopub' require_relative '../helpers/filters' require_relative '../helpers/pager' module OpenBEL module Routes - class Evidence < Base - include OpenBEL::Evidence::FacetFilter - include OpenBEL::Resource::Evidence + class Nanopubs < Base + include OpenBEL::Nanopub::FacetFilter + include OpenBEL::Resource::Nanopub include OpenBEL::Helpers def initialize(app) super - mongo = OpenBEL::Settings[:evidence_store][:mongo] - @api = OpenBEL::Evidence::Evidence.new(mongo) + mongo = OpenBEL::Settings[:nanopub_store][:mongo] + @api = OpenBEL::Nanopub::Nanopub.new(mongo) # RdfRepository using Jena @rr = BEL::RdfRepository.plugins[:jena].create_repository( @@ -27,31 +27,30 @@ def initialize(app) ) # Annotations using RdfRepository - annotations = BEL::Resource::Annotations.new(@rr) - - @annotation_transform = AnnotationTransform.new(annotations) + annotations = BEL::Resource::Annotations.new(@rr) + @annotation_transform = AnnotationTransform.new(annotations) @annotation_grouping_transform = AnnotationGroupingTransform.new end helpers do - def stream_evidence_objects(cursor) + def stream_nanopub_objects(cursor) stream :keep_open do |response| - cursor.each do |evidence| - evidence.delete('facets') + cursor.each do |nanopub| + nanopub.delete('facets') response << render_resource( - evidence, - :evidence, + nanopub, + :nanopub, :as_array => false, - :_id => evidence['_id'].to_s + :_id => nanopub['_id'].to_s ) end end end - def stream_evidence_array(cursor) + def stream_nanopub_array(cursor) stream :keep_open do |response| current = 0 @@ -63,14 +62,14 @@ def stream_evidence_array(cursor) end response << '[' - cursor.each do |evidence| - evidence.delete('facets') + cursor.each do |nanopub| + nanopub.delete('facets') response << render_resource( - evidence, - :evidence, + nanopub, + :nanopub, :as_array => false, - :_id => evidence['_id'].to_s + :_id => nanopub['_id'].to_s ) current += 1 response << ',' if current < total @@ -98,22 +97,22 @@ def keys_to_s_deep(hash) end end - options '/api/evidence' do + options '/api/nanopubs' do response.headers['Allow'] = 'OPTIONS,POST,GET' status 200 end - options '/api/evidence/:id' do + options '/api/nanopubs/:id' do response.headers['Allow'] = 'OPTIONS,GET,PUT,DELETE' status 200 end - post '/api/evidence' do - # Validate JSON Evidence. + post '/api/nanopubs' do + # Validate BNJ. validate_media_type! "application/json" - evidence_obj = read_json + nanopub_obj = read_json - schema_validation = validate_schema(keys_to_s_deep(evidence_obj), :evidence) + schema_validation = validate_schema(keys_to_s_deep(nanopub_obj), :nanopub) unless schema_validation[0] halt( 400, @@ -122,39 +121,39 @@ def keys_to_s_deep(hash) ) end - evidence = ::BEL::Model::Evidence.create(evidence_obj[:evidence]) + nanopub = ::BEL::Nanopub::Nanopub.create(nanopub_obj[:nanopub]) # Standardize annotations. - @annotation_transform.transform_evidence!(evidence, base_url) + @annotation_transform.transform_nanopub!(nanopub, base_url) # Build facets. - facets = map_evidence_facets(evidence) - hash = evidence.to_h + facets = map_nanopub_facets(nanopub) + hash = nanopub.to_h hash[:bel_statement] = hash.fetch(:bel_statement, nil).to_s hash[:facets] = facets - _id = @api.create_evidence(hash) + _id = @api.create_nanopub(hash) # Return Location information (201). status 201 - headers "Location" => "#{base_url}/api/evidence/#{_id}" + headers "Location" => "#{base_url}/api/nanopubs/#{_id}" end - get '/api/evidence-stream', provides: 'application/json' do + get '/api/nanopubs-stream', provides: 'application/json' do start = (params[:start] || 0).to_i size = (params[:size] || 0).to_i group_as_array = as_bool(params[:group_as_array]) filters = validate_filters! - cursor = @api.find_evidence(filters, start, size, false)[:cursor] + cursor = @api.find_nanopub(filters, start, size, false)[:cursor] if group_as_array - stream_evidence_array(cursor) + stream_nanopub_array(cursor) else - stream_evidence_objects(cursor) + stream_nanopub_objects(cursor) end end - get '/api/evidence' do + get '/api/nanopubs' do start = (params[:start] || 0).to_i size = (params[:size] || 0).to_i faceted = as_bool(params[:faceted]) @@ -162,46 +161,46 @@ def keys_to_s_deep(hash) filters = validate_filters! - collection_total = @api.count_evidence() - filtered_total = @api.count_evidence(filters) - page_results = @api.find_evidence(filters, start, size, faceted, max_values_per_facet) + collection_total = @api.count_nanopub() + filtered_total = @api.count_nanopub(filters) + page_results = @api.find_nanopub(filters, start, size, faceted, max_values_per_facet) - render_evidence_collection( - 'evidence-export', page_results, start, size, filters, + render_nanopub_collection( + 'nanopub-export', page_results, start, size, filters, filtered_total, collection_total, @api ) end - get '/api/evidence/:id' do + get '/api/nanopubs/:id' do object_id = params[:id] halt 404 unless BSON::ObjectId.legal?(object_id) - evidence = @api.find_evidence_by_id(object_id) - halt 404 unless evidence + nanopub = @api.find_nanopub_by_id(object_id) + halt 404 unless nanopub - evidence.delete('facets') + nanopub.delete('facets') # XXX Hack to return single resource wrapped as json array - # XXX Need to better support evidence resource arrays in base.rb + # XXX Need to better support nanopub resource arrays in base.rb render_resource( - evidence, - :evidence, + nanopub, + :nanopub, :as_array => false, :_id => object_id ) end - put '/api/evidence/:id' do + put '/api/nanopubs/:id' do object_id = params[:id] halt 404 unless BSON::ObjectId.legal?(object_id) validate_media_type! "application/json" - ev = @api.find_evidence_by_id(object_id) + ev = @api.find_nanopub_by_id(object_id) halt 404 unless ev - evidence_obj = read_json - schema_validation = validate_schema(keys_to_s_deep(evidence_obj), :evidence) + nanopub_obj = read_json + schema_validation = validate_schema(keys_to_s_deep(nanopub_obj), :nanopub) unless schema_validation[0] halt( 400, @@ -211,30 +210,30 @@ def keys_to_s_deep(hash) end # transformation - evidence = evidence_obj[:evidence] - evidence_model = ::BEL::Model::Evidence.create(evidence) - @annotation_transform.transform_evidence!(evidence_model, base_url) - facets = map_evidence_facets(evidence_model) - evidence = evidence_model.to_h - evidence[:bel_statement] = evidence.fetch(:bel_statement, nil).to_s - evidence[:facets] = facets + nanopub = nanopub_obj[:nanopub] + nanopub = ::BEL::Nanopub::Nanopub.create(nanopub) + @annotation_transform.transform_nanopub!(nanopub, base_url) + + facets = map_nanopub_facets(nanopub) + nanopub = nanopub.to_h + nanopub[:bel_statement] = nanopub.fetch(:bel_statement, nil).to_s + nanopub[:facets] = facets - @api.update_evidence_by_id(object_id, evidence) + @api.update_nanopub_by_id(object_id, nanopub) status 202 end - delete '/api/evidence/:id' do + delete '/api/nanopubs/:id' do object_id = params[:id] halt 404 unless BSON::ObjectId.legal?(object_id) - ev = @api.find_evidence_by_id(object_id) + ev = @api.find_nanopub_by_id(object_id) halt 404 unless ev - @api.delete_evidence_by_id(object_id) + @api.delete_nanopub_by_id(object_id) status 202 end - end end end diff --git a/app/openbel/api/routes/root.rb b/app/openbel/api/routes/root.rb index 40f0bb6..c813022 100644 --- a/app/openbel/api/routes/root.rb +++ b/app/openbel/api/routes/root.rb @@ -17,13 +17,13 @@ class Root < Base :href => "#{base_url}/api/annotations" }, { - :href => "#{base_url}/api/evidence" + :href => "#{base_url}/api/nanopub" }, { :href => "#{base_url}/api/expressions" }, { - :href => "#{base_url}/api/functions" + :href => "#{base_url}/api/language" }, { :href => "#{base_url}/api/namespaces" diff --git a/app/openbel/api/routes/version.rb b/app/openbel/api/routes/version.rb index 65e3c52..03a90d2 100644 --- a/app/openbel/api/routes/version.rb +++ b/app/openbel/api/routes/version.rb @@ -1,45 +1,59 @@ -require_relative '../version' -require 'rack/mime' +require 'openbel/api/version' module OpenBEL module Routes - + # Version defines and implements the _/api/version_ route that exposes + # the semantic version of the OpenBEL API. class Version < Base JSON = Rack::Mime.mime_type('.json') + HAL = 'application/hal+json' TEXT = Rack::Mime.mime_type('.txt') - ACCEPTED_TYPES = {'json' => JSON, 'text' => TEXT} + ACCEPTED_TYPES = { + 'hal' => HAL, + 'json' => JSON, + 'text' => TEXT + } DEFAULT_TYPE = TEXT + helpers do + def requested_media_type + if params && params[:format] + ACCEPTED_TYPES[params[:format]] + else + request.accept.flat_map { |accept_entry| + ACCEPTED_TYPES.values.find { |type| type == accept_entry.entry } + }.compact.first + end + end + end + options '/api/version' do response.headers['Allow'] = 'OPTIONS,GET' status 200 end get '/api/version' do - accept_type = request.accept.find { |accept_entry| - ACCEPTED_TYPES.values.include?(accept_entry.to_s) - } - accept_type ||= DEFAULT_TYPE - - format = params[:format] - if format - accept_type = ACCEPTED_TYPES[format] - halt 406 unless accept_type - end + accept_type = requested_media_type || DEFAULT_TYPE - if accept_type == JSON - render_json( - { - :version => { - :string => OpenBEL::Version.to_s, - :semantic_version_numbers => OpenBEL::Version.to_a + case accept_type + when TEXT + response.headers['Content-Type'] = 'text/plain' + OpenBEL::Version.to_s + when HAL, JSON + response.headers['Content-Type'] = 'application/hal+json' + MultiJson.dump({ + :version => { + :string => OpenBEL::Version.to_s, + :semantic_version => { + :major => OpenBEL::Version::MAJOR, + :minor => OpenBEL::Version::MINOR, + :patch => OpenBEL::Version::PATCH } } - ) + }) else - response.headers['Content-Type'] = 'text/plain' - OpenBEL::Version.to_s + halt 406 end end end diff --git a/app/openbel/api/schemas/annotation_resource.schema.json b/app/openbel/api/schemas/annotation_resource.schema.json index 25d5e58..c5a22d2 100644 --- a/app/openbel/api/schemas/annotation_resource.schema.json +++ b/app/openbel/api/schemas/annotation_resource.schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema", "title": "Annotation", - "description": "A vocabulary of terms for describing evidence resources.", + "description": "A vocabulary of terms for describing nanopub resources.", "type": "object", "additionalProperties": false, "required": [ diff --git a/app/openbel/api/schemas/evidence_collection.schema.json b/app/openbel/api/schemas/evidence_collection.schema.json deleted file mode 100644 index 85e5989..0000000 --- a/app/openbel/api/schemas/evidence_collection.schema.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "description": "DESCRIBE EVIDENCE COLLECTION", - "type": "object", - "additionalProperties": false, - "required": [ - "evidence_collection", - "facets" - ], - "properties": { - "evidence_collection": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "$ref":"evidence_resource.schema.json" - } - }, - "facets": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "type": "object", - "additionalProperties": false, - "required": [ - "category", - "name", - "value", - "filter", - "count" - ], - "properties": { - "category": { - "type": "string" - }, - "name": { - "type": "string" - }, - "value": { - "type": "string" - }, - "filter": { - "type": "string" - }, - "count": { - "type": "integer" - } - } - } - }, - "metadata": { - "title": "Metadata", - "description": "Data about the evidence collection", - "type": "object", - "additionalProperties": true, - "properties": { - "collection_paging": { - "type": "object", - "properties": { - "total": { - "title": "Total", - "description": "The total number of resources in this collection.", - "type": "number", - "minimum": 0 - }, - "total_filtered": { - "title": "Total Filtered", - "description": "The total number of resources in the filtered collection.", - "type": "number", - "minimum": 0 - }, - "total_pages": { - "title": "Total Pages", - "description": "The total number of pages (i.e. sized partitions) in the filtered collection.", - "type": "number", - "minimum": 0 - }, - "current_page": { - "title": "Current Page", - "description": "The current page of the filtered collection that this resource represents.", - "type": "number", - "minimum": 0 - }, - "current_page_size": { - "title": "Current Page Size", - "description": "The number of resources in the current page of the filtered collection.", - "type": "number", - "minimum": 0 - } - } - } - } - } - } -} diff --git a/app/openbel/api/schemas/evidence_resource.schema.json b/app/openbel/api/schemas/evidence_resource.schema.json deleted file mode 100644 index 87c73d7..0000000 --- a/app/openbel/api/schemas/evidence_resource.schema.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Evidence Resource", - "description": "A single evidence resource.", - "type": "object", - "additionalProperties": false, - "required": [ - "evidence" - ], - "properties": { - "allOf": [ - { - "$ref":"evidence.schema.json" - }, - { - "type": "object", - "additionalProperties": false, - "required": [ - "links" - ], - "properties": { - "links": { - "type": "object" - } - } - } - ] - } -} diff --git a/app/openbel/api/schemas/evidence.schema.json b/app/openbel/api/schemas/nanopub.schema.json similarity index 94% rename from app/openbel/api/schemas/evidence.schema.json rename to app/openbel/api/schemas/nanopub.schema.json index 91e100e..e9c5585 100644 --- a/app/openbel/api/schemas/evidence.schema.json +++ b/app/openbel/api/schemas/nanopub.schema.json @@ -1,11 +1,11 @@ { "$schema": "http://json-schema.org/draft-04/schema", - "description": "DESCRIBE EVIDENCE", + "description": "DESCRIBE NANOPUB", "type": "object", "additionalProperties": false, - "required": ["evidence"], + "required": ["nanopub"], "properties": { - "evidence": { + "nanopub": { "type": "object", "additionalProperties": false, "required": ["bel_statement", "citation"], @@ -92,10 +92,10 @@ } } }, - "summary_text": { + "support": { "type": ["string", "null"], - "title": "Summary Text", - "description": "Abstract from source text to provide support for this evidence" + "title": "Support", + "description": "Abstract from source text to provide support for this nanopub" }, "references": { "type": ["object", "null"], @@ -112,7 +112,7 @@ "keyword": { "type": "string", "title": "Keyword", - "description": "Keyword that identifies this annotation resource, but only in the context of this Evidence." + "description": "Keyword that identifies this annotation resource, but only in the context of this Nanopub." }, "uri": { "type": "string", @@ -134,7 +134,7 @@ "keyword": { "type": "string", "title": "Keyword", - "description": "Keyword that identifies this namespace resource, but only in the context of this Evidence." + "description": "Keyword that identifies this namespace resource, but only in the context of this Nanopub." }, "uri": { "type": "string", @@ -150,8 +150,8 @@ }, "metadata": { "type": ["array", "null"], - "title": "Evidence resource metadata", - "description": "Metadata that describes the evidence resource.", + "title": "Nanopub resource metadata", + "description": "Metadata that describes the nanopub resource.", "items": { "oneOf": [ { diff --git a/docs/schemas/evidence_collection.schema.json b/app/openbel/api/schemas/nanopub_collection.schema.json similarity index 91% rename from docs/schemas/evidence_collection.schema.json rename to app/openbel/api/schemas/nanopub_collection.schema.json index 85e5989..93a33cc 100644 --- a/docs/schemas/evidence_collection.schema.json +++ b/app/openbel/api/schemas/nanopub_collection.schema.json @@ -1,20 +1,20 @@ { "$schema": "http://json-schema.org/draft-04/schema", - "description": "DESCRIBE EVIDENCE COLLECTION", + "description": "DESCRIBE NANOPUB COLLECTION", "type": "object", "additionalProperties": false, "required": [ - "evidence_collection", + "nanopub_collection", "facets" ], "properties": { - "evidence_collection": { + "nanopub_collection": { "type": "array", "minItems": 0, "title": "", "description": "", "items": { - "$ref":"evidence_resource.schema.json" + "$ref":"nanopub_resource.schema.json" } }, "facets": { @@ -53,7 +53,7 @@ }, "metadata": { "title": "Metadata", - "description": "Data about the evidence collection", + "description": "Data about the nanopub collection", "type": "object", "additionalProperties": true, "properties": { diff --git a/docs/schemas/evidence_resource.schema.json b/app/openbel/api/schemas/nanopub_resource.schema.json similarity index 75% rename from docs/schemas/evidence_resource.schema.json rename to app/openbel/api/schemas/nanopub_resource.schema.json index 87c73d7..873deef 100644 --- a/docs/schemas/evidence_resource.schema.json +++ b/app/openbel/api/schemas/nanopub_resource.schema.json @@ -1,16 +1,16 @@ { "$schema": "http://json-schema.org/draft-04/schema", - "title": "Evidence Resource", - "description": "A single evidence resource.", + "title": "Nanopub Resource", + "description": "A single nanopub resource.", "type": "object", "additionalProperties": false, "required": [ - "evidence" + "nanopub" ], "properties": { "allOf": [ { - "$ref":"evidence.schema.json" + "$ref":"nanopub.schema.json" }, { "type": "object", diff --git a/config/config.yml b/config/config.yml index 13c729b..9c24698 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,7 +1,17 @@ # Configuration template for OpenBEL API -# Storage of evidence through the Mongo database. -evidence_store: +# BEL configuration. +bel: + # The BEL version supported by this OpenBEL API instance. + # Allowed values: + # 1.0 + # (BEL version 1.0 specification) + # 2.0 + # (BEL version 2.0 specification) + version: 2.0 + +# Storage of nanopubs through the Mongo database. +nanopub_store: mongo: # The MongoDB host to connect to. For example if MongoDB's net.bindIp @@ -12,9 +22,9 @@ evidence_store: # The default MongoDB port. Configured under MongoDB's `net.port` setting. port: 27017 - # The name of your database. We think "openbel-evidence" should be fine, + # The name of your database. We think "openbel-nanopubs" should be fine, # but it's up to you. - database: 'openbel-evidence' + database: 'openbel-nanopubs' # MongoDB authentication and role assignment. These settings are necessary # if you would like to have a MongoDB user authenticated and authorized to @@ -23,7 +33,7 @@ evidence_store: #First, you will need to create a MongoDB user with the "readWrite" and #"dbAdmin" roles for the "database" value set above. This is to allow read, #write, and index creation in the OpenBEL API application. - #See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Evidence-Store#adding-the-openbel-user + #See https://github.com/OpenBEL/openbel-api/wiki/Configuring-the-Nanopub-Store#adding-the-openbel-user #username: 'openbel-user' #Second, you will need to set a password for the MongoDB user set above. diff --git a/docs/examples/annotation_collection.example.json b/docs/examples/annotation_collection.example.json deleted file mode 100644 index f6bfcf7..0000000 --- a/docs/examples/annotation_collection.example.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "annotation_collection": [ - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/cell-line-ontology", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Cell Line Ontology", - "domain": "cell-line", - "prefix": "clo" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/clo" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/cell-ontology", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Cell Ontology", - "domain": "cell", - "prefix": "cl" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/cl" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", - "prefLabel": "Disease Ontology", - "domain": "disease", - "prefix": "do" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/do" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/experimental-factor-ontology", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Experimental Factor Ontology", - "domain": "cell-line", - "prefix": "efo" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/efo" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/mesh-anatomy", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Mesh Anatomy", - "domain": "anatomy", - "prefix": "mesha" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/mesha" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/mesh-cellular-structures", - "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", - "prefLabel": "Mesh Cellular Structures", - "domain": "location", - "prefix": "meshcs" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/meshcs" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/mesh-diseases", - "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", - "prefLabel": "Mesh Diseases", - "domain": "disease", - "prefix": "meshd" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/meshd" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/ncbi-taxonomy", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Ncbi Taxonomy", - "domain": "species", - "prefix": "taxon" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/taxon" - } - } - }, - { - "annotation": { - "uri": "http://www.openbel.org/bel/namespace/uberon", - "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", - "prefLabel": "Uberon", - "domain": "anatomy", - "prefix": "uberon" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/uberon" - } - } - } - ], - "_links": { - "self": { - "type": "annotation_collection", - "href": "http://next.belframework.org/api/annotations" - }, - "start": { - "type": "start", - "href": "http://next.belframework.org/api/annotations/values" - } - } -} - diff --git a/docs/examples/annotation_resource.example.json b/docs/examples/annotation_resource.example.json deleted file mode 100644 index 4e3e7ba..0000000 --- a/docs/examples/annotation_resource.example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" - }, - "_links": { - "self": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/do" - } - } -} diff --git a/docs/examples/annotation_value_collection.example.json b/docs/examples/annotation_value_collection.example.json deleted file mode 100644 index 5dd19dc..0000000 --- a/docs/examples/annotation_value_collection.example.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "annotation_value_collection": [ - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "match_text": "<<sarcoma>>", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" - } - } - } - }, - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "3071", - "name": "gliosarcoma", - "match_text": "...3071 a ma oma coma rcoma arcoma <<sarcoma>> osarcoma iosarcoma liosarcoma gliosarcoma toma stoma astoma...", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/3071" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" - } - } - } - }, - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "3382", - "name": "liposarcoma", - "match_text": "2 82 382 3382 a ma oma coma rcoma arcoma <<sarcoma>> osarcoma posarcoma iposarcoma liposarcoma", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/3382" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" - } - } - } - } - ] -} diff --git a/docs/examples/annotation_value_resource.example.json b/docs/examples/annotation_value_resource.example.json deleted file mode 100644 index c3d2e51..0000000 --- a/docs/examples/annotation_value_resource.example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" - } - } - } -} diff --git a/docs/examples/annotation_values_filter.example.json b/docs/examples/annotation_values_filter.example.json deleted file mode 100644 index 9c64c29..0000000 --- a/docs/examples/annotation_values_filter.example.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "annotation_value_collection": [ - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "D012509", - "name": "Sarcoma", - "match_text": "...Sarcomas, Spindle Cell Soft Tissue <<Sarcoma>> Soft Tissue Sarcomas Spindle Cell <<Sarcoma>> Spindle Cell Sarcomas", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/mesh-diseases/values/D012509" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/mesh-diseases" - } - } - } - }, - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "match_text": "<<sarcoma>>", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" - } - } - } - }, - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "D008223", - "name": "Lymphoma", - "match_text": "Germinoblastic <<Sarcoma>> Germinoblastic Sarcomas Germinoblastoma Germinoblastomas Lymphoma, Malignant Lymphomas Lymphomas, Malignant Malignant Lymphoma Malignant Lymphomas...", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/mesh-diseases/values/D008223" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/mesh-diseases" - } - } - } - } - ] -} diff --git a/docs/examples/namespace_value_collection.example.json b/docs/examples/namespace_value_collection.example.json deleted file mode 100644 index b1262af..0000000 --- a/docs/examples/namespace_value_collection.example.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "namespace_value_collection": [ - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "3546", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "9606", - "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546" - }, - "collection": { - "type": "namespace", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546/orthologs" - } - ] - } - }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "6631", - "name": "LMAN1", - "title": "lectin, mannose-binding, 1", - "species": "9606", - "match_text": "F5F8D ERGIC53 MCFD1 MR60 gp58 ERGIC-53 FMFD1 coagulation <> V-factor <> combined deficiency" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/6631" - }, - "collection": { - "type": "namespace", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/6631/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/6631/orthologs" - } - ] - } - } - ] -} diff --git a/docs/examples/namespace_values_filter.example.json b/docs/examples/namespace_values_filter.example.json deleted file mode 100644 index 2283ee9..0000000 --- a/docs/examples/namespace_values_filter.example.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "namespace_value_collection": [ - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "88383", - "name": "F8", - "title": "coagulation factor VIII", - "species": "10090", - "match_text": "...or tor ctor actor <> I II III <> FVIII <> -8 f-8 Cf-8 f8..." - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://next.belframework.org/api/namespaces/mgi-mouse-genes/88383" - }, - "collection": { - "type": "namespace", - "href": "http://next.belframework.org/api/namespaces/mgi-mouse-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/mgi-mouse-genes/88383/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/mgi-mouse-genes/88383/orthologs" - } - ] - } - }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "727845", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "10116", - "match_text": "coagulation <> <>" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://next.belframework.org/api/namespaces/rgd-rat-genes/727845" - }, - "collection": { - "type": "namespace", - "href": "http://next.belframework.org/api/namespaces/rgd-rat-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/rgd-rat-genes/727845/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/rgd-rat-genes/727845/orthologs" - } - ] - } - }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "3546", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "9606", - "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546" - }, - "collection": { - "type": "namespace", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://next.belframework.org/api/namespaces/hgnc-human-genes/3546/orthologs" - } - ] - } - } - ] -} diff --git a/docs/examples/root.example.json b/docs/examples/root.example.json deleted file mode 100644 index d41aa7a..0000000 --- a/docs/examples/root.example.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "_links": { - "item": [ - { - "type": "annotation_collection", - "href": "http://next.belframework.org/api/annotations" - }, - { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence" - }, - { - "type": "expression_collection", - "href": "http://next.belframework.org/api/expressions" - }, - { - "type": "function_collection", - "href": "http://next.belframework.org/api/functions" - }, - { - "type": "namespace_collection", - "href": "http://next.belframework.org/api/namespaces" - } - ] - } -} diff --git a/docs/openbel-api.raml b/docs/openbel-api.raml index d728e61..480d822 100644 --- a/docs/openbel-api.raml +++ b/docs/openbel-api.raml @@ -1,56 +1,21 @@ #%RAML 0.8 -title: OpenBEL Platform +title: OpenBEL API version: 0.0.2 -baseUri: http://next.belframework.org/api -schemas: - - annotation_resource: !include http://next.belframework.org/schemas/annotation_resource.schema.json - - annotation_collection: !include http://next.belframework.org/schemas/annotation_collection.schema.json - - annotation_value_resource: !include http://next.belframework.org/schemas/annotation_value_resource.schema.json - - annotation_value_collection: !include http://next.belframework.org/schemas/annotation_value_collection.schema.json - - evidence: !include http://next.belframework.org/schemas/evidence.schema.json - - evidence_resource: !include http://next.belframework.org/schemas/evidence_resource.schema.json - - evidence_collection: !include http://next.belframework.org/schemas/evidence_collection.schema.json -traits: - - ro_options: - description: | - Returns allowable HTTP methods for this <>. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Allow: - description: Allowable HTTP methods. - type: string - enum: [ 'OPTIONS', 'GET' ] - - rw_options: - description: | - Returns allowable HTTP methods for this <>. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Allow: - description: Allowable HTTP methods. - type: string - enum: [ 'OPTIONS', 'GET', 'POST', 'PUT', 'DELETE' ] - - create_options: - description: | - Returns allowable HTTP methods for this <>. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Allow: - description: Allowable HTTP methods. - type: string - enum: [ 'OPTIONS', 'GET', 'POST' ] +baseUri: 'http://localhost/api' +mediaType: '' +protocols: + - HTTP documentation: - - title: Welcome + - title: OpenBEL API content: | - The OpenBEL Platform provides an Application Programming Interface (API) exposed over the Hypertext Transfer Protocol (HTTP). The primary goal of the API is to expose OpenBEL capabilities over the web to lower the technical barriers for users. + The primary goal of the OpenBEL API is to expose OpenBEL Platform capabilities over the web to lower the technical barriers for users. + - title: Planned Functionality + content: | + We are currently working on the following: + - Creating a group of BEL Nanopubs with returned resource "Location" + - Support for [BEL version 2.0](http://wiki.openbel.org/display/BLVD) + - Autocomplete with BEL expression semantics (e.g. namespace encoding, term signatures, etc.) + - Creation of BEL knowledge networks from the BEL Nanopubs collection - title: Functionality content: | The API provides the following: @@ -58,478 +23,1005 @@ documentation: - Equivalence and Orthologize BEL expressions - Autocomplete syntax of BEL expressions - Access BEL Functions and Relationships - - Store, query, and export BEL Evidence - - title: Planned Functionality - content: | - We are currently working on the following: - - Creating a group of BEL Evidence with returned resource "Location" - - Support for [BEL version 2.0](http://wiki.openbel.org/display/BLVD) - - Autocomplete with BEL expression semantics (e.g. namespace encoding, term signatures, etc.) - - Creation of BEL knowledge networks from the Evidence collection -/api: - description: | - Root resource of the API. Lists all subresources contained within the API. - options: - is: [ - ro_options: { name: "root resource" } - ] - get: - description: | - Returns a list of linked *item* resources. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - body: - application/hal+json: - example: !include examples/root.example.json -/annotations: - description: | - Annotation collection within the API. - - This provides access to BEL annotation vocabularies such as MeSH, Gene Ontology, and Disease Ontology. - - BEL Evidence can be annotated to express knowledge about the evidence itself. Some important uses of annotations are: - - Specify information about the biological system in which the facts represented by the statement hold or were demonstrated. - - Specify information about the experimental methods used to demonstrate the facts. - - Specify information about the knowledge source on which the statement is based, such as the citation and the specific text supporting the statement. - options: - is: [ - ro_options: { name: "annotation_collection" } - ] - get: - description: | - Returns the *annotation_collection* containing an array of all *annotation* resources. - - An *annotation* resource contains fields: - - prefLabel: human-readable name - - prefix: short prefix - - domain: biological domain + - Store, query, and export BEL + - title: Welcome + content: |- + The primary goal of the OpenBEL API is to expose OpenBEL Platform capabilities over the web to lower the technical barriers for users. - The collection contains zero or more *annotation* resource objects. If the *annotation_collection* is empty then the result is an empty array. + NOTE - this API documentation is managed/updated on stoplight.io (Public view at http://openbelapi.api-docs.io) +/api: + displayName: api + description: '' + /namespaces: + displayName: namespaces + description: '' + '/{namespace}': + displayName: '{namespace}' + description: '' + /values: + displayName: values + description: '' + '/{value}': + displayName: '{value}' + description: '' + /equivalents: + displayName: equivalents + description: '' + uriParameters: {} + options: + displayName: OPTIONS_namespaces-namespace-values-value-equivalents + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_namespaces-namespace-values-value-equivalents + headers: {} + responses: {} + queryParameters: {} + '/{target}': + displayName: '{target}' + description: '' + uriParameters: + target: + description: target + type: string + displayName: target + get: + displayName: GET_namespaces-namespace-values-value-equivalents-target + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_namespaces-namespace-values-value-equivalents-target + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + uriParameters: + value: + description: value + type: string + displayName: value + get: + displayName: GET_namespaces-namespace-values-value + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_namespaces-namespace-values-value + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + /orthologs: + displayName: orthologs + description: '' + '/{target}': + displayName: '{target}' + description: '' + uriParameters: + target: + description: target + type: string + displayName: target + options: + displayName: OPTIONS_namespaces-namespace-values-value-orthologs-target + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_namespaces-namespace-values-value-orthologs-target + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} + get: + displayName: GET_namespaces-namespace-values-value-orthologs + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_namespaces-namespace-values-value-orthologs + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} + options: + displayName: OPTIONS_namespaces-namespace-values + description: | + Returns allowable HTTP methods for this namespace_value_collection. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_namespaces-namespace-values + description: | + Returns the *namespace_value_collection* across the *namespace* resource identified by *{namespace}* URI parameter. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) +
+ **Limitations** - **JSON Schema** - - [annotation_collection](schemas/annotation_collection.schema.json) - - [annotation](schemas/annotation_resource.schema.json) - body: - application/json: - example: !include examples/annotation_collection.example.json - /values: - description: | - Annotation Value collection for all Annotation resources within the API. + This endpoint is limited to full-text searching including a *filter* like: + ```json + { + "category": "fts", + "name": "search", + "value": "factor VIII" + } + ``` - This provides a collection of all BEL annotation values that can be listed and filtered. - options: - is: [ - ro_options: { name: "annotation_value_collection" } - ] - get: - description: | - Returns the *annotation_value_collection* across all *annotation* resources. +
+ **Nested Namespace** -
- **Limitations** - - This endpoint is limited to full-text searching including a *filter* like: - ```json - { - "category": "fts", - "name": "search", - "value": "sarcoma" - } - ``` + All returned *namespace_value* in the *namespace_value_collection* will include the *namespace* it is found in. + For example if *factor VIII* is found in the *Hgnc Human Genes* namespace then the following will be included in the value: -
- **Nested Annotation** + ```json + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", + "name": "Hgnc Human Genes", + "prefix": "hgnc", + "domain": "gene and gene product" + }, + ``` - All returned *annotation_value* in the *annotation_value_collection* will include the *annotation* it is found in. - For example if *sarcoma* is found in the *Disease Ontology* annotation then the following will be included in the value: +
+ **Additional Property** - ```json - annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" - }, - ``` + A `match_text` property, included in each *namespace_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. -
- **Additional Property** +
+ **Complete Example** - A `match_text` property, included in each *annotation_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. + **GET http://localhost/api/namespaces/hgnc/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22factor%20VIII%22}&start=0&size=2** -
- **Complete Example** - - **GET http://next.belframework.org/api/annotations/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22sarcoma%22}&start=0&size=3** - - ```json - { - "annotation_value_collection": [ - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "D012509", - "name": "Sarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/mesh-diseases", - "name": "Mesh Diseases", - "prefix": "meshd", - "domain": "disease" - }, - "match_text": "...Sarcomas, Spindle Cell Soft Tissue <> Soft Tissue Sarcomas Spindle Cell <> Spindle Cell Sarcomas", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/mesh-diseases/values/D012509" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/mesh-diseases" - } - } - } - }, + ```json { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" - }, - "match_text": "<>", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" + "namespace_value_collection": [ + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "3546", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "9606", + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", + "name": "Hgnc Human Genes", + "prefix": "hgnc", + "domain": "gene and gene product" + }, + "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546" + }, + "collection": { + "type": "namespace", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/orthologs" + } + ] } - } - } - }, - { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "D008223", - "name": "Lymphoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/mesh-diseases", - "name": "Mesh Diseases", - "prefix": "meshd", - "domain": "disease" }, - "match_text": "Germinoblastic <> Germinoblastic Sarcomas Germinoblastoma Germinoblastomas Lymphoma, Malignant Lymphomas Lymphomas, Malignant Malignant Lymphoma Malignant Lymphomas...", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/mesh-diseases/values/D008223" + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "6631", + "name": "LMAN1", + "title": "lectin, mannose-binding, 1", + "species": "9606", + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", + "name": "Hgnc Human Genes", + "prefix": "hgnc", + "domain": "gene and gene product" + }, + "match_text": "F5F8D ERGIC53 MCFD1 MR60 gp58 ERGIC-53 FMFD1 coagulation <> V-factor <> combined deficiency" }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/mesh-diseases" + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631" + }, + "collection": { + "type": "namespace", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631/orthologs" + } + ] } } - } + ] } - ] - } - ``` + ``` + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "namespace_value_collection": [ + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "3546", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "9606", + "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546" + }, + "collection": { + "type": "namespace", + "href": "http://localhost/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546/orthologs" + } + ] + } + }, + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "6631", + "name": "LMAN1", + "title": "lectin, mannose-binding, 1", + "species": "9606", + "match_text": "F5F8D ERGIC53 MCFD1 MR60 gp58 ERGIC-53 FMFD1 coagulation <> V-factor <> combined deficiency" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost/api/namespaces/hgnc-human-genes/6631" + }, + "collection": { + "type": "namespace", + "href": "http://localhost/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/6631/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/6631/orthologs" + } + ] + } + } + ] + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - queryParameters: - start: - type: integer - description: | - The annotation value resource to start from for paging purposes. - example: "0" - required: false - size: - type: integer - description: | - The size of the annotation value resource collection to retrieve. This will return a slice of the annotation value resource collection relative to *start*. + **JSON Schema** + - [namespace_value_collection](schemas/namespace_value_collection.schema.json) + - [namespace_value](schemas/namespace_value_resource.schema.json) + queryParameters: + start: + type: integer + description: | + The namespace value resource to start from for paging purposes. + displayName: start + size: + type: integer + description: | + The size of the namespace value resource collection to retrieve. This will return a slice of the namespace value resource collection relative to *start*. - A size of zero or less will return all values. - example: 3 - required: false - filter: - type: string - description: | - A filter to apply to the annotation value resource collection to narrow the resources retrieved. - example: | - {"category":"fts","name":"search","value":"sarcoma"} - required: false - faceted: + A size of zero or less will return all values. + displayName: size + filter: + type: string + description: | + A filter to apply to the namespace value resource collection to narrow the resources retrieved. + displayName: filter + faceted: + type: string + description: | + The boolean indicator to provided faceted results for the namespace value resource collection. The default is to not facet. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: faceted + uriParameters: + namespace: + description: namespace type: string - description: | - The boolean indicator to provided faceted results for the annotation value resource collection. The default is to not facet. - enum: [ 'true', 'yes', '1', 'on' ] - example: no - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [annotation_value_collection](schemas/annotation_value_collection.schema.json) - - [annotation_value](schemas/annotation_value_resource.schema.json) - body: - application/json: - example: !include examples/annotation_values_filter.example.json - 400: - description: | - [400 Bad Request](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1) - - Returned if a filter is malformed. - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - Returned if no annotation values were found for the FTS search. - - Returned if a `{"category":"fts", "name": "search", ...}` filter was not provided. - 501: - description: | - [501 Not Implemented](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2) - - Returned if the client enabled the `faceted` query parameter. This is currently not implemented. - /{annotation}: - description: | - Annotation resource identified by *{annotation}* URI parameter. - uriParameters: - annotation: - type: string - description: | - An identifier string for an annotation. This is either the annotation prefix, name, or URI part. - - **Example Usage**: - - Identify the Disease Ontology, all of the following are equivalent identifiers: - - `do` (prefix) - - `Disease Ontology` (name) - - `disease-ontology` (URI part) - example: "Disease Ontology" - required: true - options: - is: [ - ro_options: { name: "annotation resource" } - ] - get: - description: | - Returns the *annotation* resource identified by *{annotation}* URI parameter. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [annotation](schemas/annotation_resource.schema.json) - body: - application/json: - example: !include examples/annotation_resource.example.json + displayName: namespace + get: + displayName: GET_namespaces-namespace + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_namespaces-namespace + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} /values: - description: | - Annotation Value collection within an Annotation resource identified by *{annotation}*. + displayName: values + description: '' + uriParameters: {} options: - is: [ - ro_options: { name: "annotation_value_collection" } - ] + displayName: OPTIONS_namespaces-values + description: | + Returns allowable HTTP methods for this namespace_value_collection. + headers: {} + responses: {} + queryParameters: {} get: + displayName: GET_namespaces-values description: | - Returns the *annotation_value_collection* across the *annotation* resource identified by *{annotation}* URI parameter. + Returns the *namespace_value_collection* across all *namespace* resources.
**Limitations** - + This endpoint is limited to full-text searching including a *filter* like: ```json { "category": "fts", "name": "search", - "value": "sarcoma" + "value": "factor VIII" } ```
- **Nested Annotation** + **Nested Namespace** - All returned *annotation_value* in the *annotation_value_collection* will include the *annotation* it is found in. - For example if *sarcoma* is found in the *Disease Ontology* annotation then the following will be included in the value: + All returned *namespace_value* in the *namespace_value_collection* will include the *namespace* it is found in. + For example if *factor VIII* is found in the *Hgnc Human Genes* namespace then the following will be included in the value: ```json - annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", + "name": "Hgnc Human Genes", + "prefix": "hgnc", + "domain": "gene and gene product" }, ```
**Additional Property** - A `match_text` property, included in each *annotation_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. + A `match_text` property, included in each *namespace_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`.
**Complete Example** - - **GET http://next.belframework.org/api/annotations/do/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22sarcoma%22}&start=0&size=3** - + + **GET http://localhost/api/namespaces/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22factor%20VIII%22}&start=0&size=3** + ```json { - "annotation_value_collection": [ + "namespace_value_collection": [ { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" + "namespace_value": { + "type": "ProteinConcept", + "identifier": "88383", + "name": "F8", + "title": "coagulation factor VIII", + "species": "10090", + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/mgi-mouse-genes", + "name": "Mgi Mouse Genes", + "prefix": "mgi", + "domain": "gene and gene product" }, - "match_text": "<>", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" + "match_text": "...or tor ctor actor <> I II III <> FVIII <> -8 f-8 Cf-8 f8..." + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383" + }, + "collection": { + "type": "namespace", + "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383/equivalents" }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383/orthologs" } - } + ] } }, { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "3071", - "name": "gliosarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" + "namespace_value": { + "type": "ProteinConcept", + "identifier": "727845", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "10116", + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/rgd-rat-genes", + "name": "Rgd Rat Genes", + "prefix": "rgd", + "domain": "gene and gene product" }, - "match_text": "...3071 a ma oma coma rcoma arcoma <> osarcoma iosarcoma liosarcoma gliosarcoma toma stoma astoma...", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/3071" + "match_text": "coagulation <> <>" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845" + }, + "collection": { + "type": "namespace", + "href": "http://localhost:9000/api/namespaces/rgd-rat-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845/equivalents" }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845/orthologs" } - } + ] } }, { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "3382", - "name": "liposarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" + "namespace_value": { + "type": "ProteinConcept", + "identifier": "3546", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "9606", + "namespace": { + "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", + "name": "Hgnc Human Genes", + "prefix": "hgnc", + "domain": "gene and gene product" }, - "match_text": "2 82 382 3382 a ma oma coma rcoma arcoma <> osarcoma posarcoma iposarcoma liposarcoma", - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/3382" + "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546" + }, + "collection": { + "type": "namespace", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/equivalents" }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" + { + "type": "namespace_value_collection", + "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/orthologs" } - } + ] } } ] } ``` + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "namespace_value_collection": [ + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "88383", + "name": "F8", + "title": "coagulation factor VIII", + "species": "10090", + "match_text": "...or tor ctor actor <> I II III <> FVIII <> -8 f-8 Cf-8 f8..." + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost/api/namespaces/mgi-mouse-genes/88383" + }, + "collection": { + "type": "namespace", + "href": "http://localhost/api/namespaces/mgi-mouse-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/mgi-mouse-genes/88383/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/mgi-mouse-genes/88383/orthologs" + } + ] + } + }, + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "727845", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "10116", + "match_text": "coagulation <> <>" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost/api/namespaces/rgd-rat-genes/727845" + }, + "collection": { + "type": "namespace", + "href": "http://localhost/api/namespaces/rgd-rat-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/rgd-rat-genes/727845/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/rgd-rat-genes/727845/orthologs" + } + ] + } + }, + { + "namespace_value": { + "type": "ProteinConcept", + "identifier": "3546", + "name": "F8", + "title": "coagulation factor VIII, procoagulant component", + "species": "9606", + "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" + }, + "_links": { + "self": { + "type": "namespace_value", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546" + }, + "collection": { + "type": "namespace", + "href": "http://localhost/api/namespaces/hgnc-human-genes" + }, + "item": [ + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546/equivalents" + }, + { + "type": "namespace_value_collection", + "href": "http://localhost/api/namespaces/hgnc-human-genes/3546/orthologs" + } + ] + } + } + ] + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + + **JSON Schema** + - [namespace_value_collection](schemas/namespace_value_collection.schema.json) + - [namespace_value](schemas/namespace_value_resource.schema.json) queryParameters: start: type: integer description: | - The annotation value resource to start from for paging purposes. - example: "0" - required: false + The namespace value resource to start from for paging purposes. + displayName: start size: type: integer description: | - The size of the annotation value resource collection to retrieve. This will return a slice of the annotation value resource collection relative to *start*. + The size of the namespace value resource collection to retrieve. This will return a slice of the namespace value resource collection relative to *start*. A size of zero or less will return all values. - example: 3 - required: false + displayName: size filter: type: string description: | - A filter to apply to the annotation value resource collection to narrow the resources retrieved. - example: | - {"category":"fts","name":"search","value":"sarcoma"} - required: false + A filter to apply to the namespace value resource collection to narrow the resources retrieved. + displayName: filter faceted: type: string description: | - The boolean indicator to provided faceted results for the annotation value resource collection. The default is to not facet. - enum: [ 'true', 'yes', '1', 'on' ] - example: no + The boolean indicator to provided faceted results for the namespace value resource collection. The default is to not facet. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: faceted + uriParameters: {} + get: + displayName: GET_namespaces + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_namespaces + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + /language: + displayName: language + description: '' + /functions: + displayName: functions + description: '' + '/{fx}': + displayName: '{fx}' + description: '' + uriParameters: + fx: + description: fx + type: string + displayName: fx + get: + displayName: GET_language-functions-fx + headers: + Accept: + type: string + displayName: Accept + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_language-functions-fx + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} + get: + displayName: GET_language-functions + headers: + Accept: + type: string + displayName: Accept + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_language-functions + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} + options: + displayName: OPTIONS_language + description: | + Returns allowable HTTP methods for this root resource. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_language + description: | + Returns a list of linked *item* resources. + headers: {} + responses: + '200': + body: + application/hal+json: + schema: '{}' + example: |- + { + "_links": { + "item": [ + { + "type": "function_collection", + "href": "http://localhost/api/language/functions" + }, + { + "type": "relation_collection", + "href": "http://localhost/api/language/relations" + }, + { + "type": "version_collection", + "href": "http://localhost/api/language/version" + } + ] + } + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + queryParameters: {} + /relations: + displayName: relations + description: '' + uriParameters: {} + options: + displayName: OPTIONS_language-relations + description: Returns allowable HTTP methods. + headers: {} responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [annotation_value_collection](schemas/annotation_value_collection.schema.json) - - [annotation_value](schemas/annotation_value_resource.schema.json) + '200': body: application/json: - example: !include examples/annotation_value_collection.example.json - 400: - description: | - [400 Bad Request](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1) - - Returned if a filter is malformed. - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - Returned if no annotation values were found for the FTS search. - - Returned if a `{"category":"fts", "name": "search", ...}` filter was not provided. - 501: - description: | - [501 Not Implemented](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2) - - Returned if the client enabled the `faceted` query parameter. This is currently not implemented. - /{value}: - description: | - Annotation value resource identified by *{annotation}* and *{value}* URI parameters. - options: - is: [ - ro_options: { name: "annotation_value resource" } - ] + schema: |- + { + "type": "object", + "properties": { + "relationship_collection": { + "type": "array", + "items": { + "type": "object", + "properties": { + "relation": { + "type": "object", + "properties": { + "short_form": { + "type": "string" + }, + "long_form": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + }, + "collection": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + } + } + } + } + } + }, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + } + } + } + } + } + example: |- + { + "relationship_collection": [ + { + "relation": { + "short_form": "actsIn", + "long_form": "actsIn", + "description": " +A actsIn f(A)+ - This relationship links an\n bundance term to the activity term for the same\n bundance. This relationship is direct because\n t is a _self_ relationship, the abundance acts\n n its own activity. For protein abundance p(A)\n nd its molecular activity kin(p(A), +p(A) actsIn\n in(p(A))+. This relationship is introduced by the\n EL Compiler and may not be used by statements in\n EL documents." + }, + "_links": { + "self": { + "type": "relationship", + "href": "http://openbel.dev/api/relationships/actsIn" + }, + "collection": { + "type": "relationship_collection", + "href": "http://openbel.dev/api/relationships" + } + } + } + ], + "_links": { + "self": { + "type": "relationship_collection", + "href": "http://openbel.dev/api/relationships" + } + } + } + queryParameters: {} + get: + displayName: GET_language-relations + headers: + Accept: + type: string + displayName: Accept + responses: + '200': + body: + application/json: + schema: |- + { + "type": "object", + "properties": { + "relationship_collection": { + "type": "array", + "items": { + "type": "object", + "properties": { + "relation": { + "type": "object", + "properties": { + "short_form": { + "type": "string" + }, + "long_form": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + }, + "collection": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + } + } + } + } + } + }, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "href": { + "type": "string" + } + } + } + } + } + } + } + example: |- + { + "relationship_collection": [ + { + "relation": { + "short_form": "actsIn", + "long_form": "actsIn", + "description": " +A actsIn f(A)+ - This relationship links an\n bundance term to the activity term for the same\n bundance. This relationship is direct because\n t is a _self_ relationship, the abundance acts\n n its own activity. For protein abundance p(A)\n nd its molecular activity kin(p(A), +p(A) actsIn\n in(p(A))+. This relationship is introduced by the\n EL Compiler and may not be used by statements in\n EL documents." + }, + "_links": { + "self": { + "type": "relationship", + "href": "http://openbel.dev/api/relationships/actsIn" + }, + "collection": { + "type": "relationship_collection", + "href": "http://openbel.dev/api/relationships" + } + } + } + ], + "_links": { + "self": { + "type": "relationship_collection", + "href": "http://openbel.dev/api/relationships" + } + } + } + queryParameters: {} + /annotations: + displayName: annotations + description: '' + '/{annotation}': + displayName: '{annotation}' + description: '' + /values: + displayName: values + description: '' + uriParameters: {} get: + displayName: GET_annotations-annotation-values description: | - Returns the *annotation_value* resource identified by *{annotation}* and *{value}* URI parameters. + Returns the *annotation_value_collection* across the *annotation* resource identified by *{annotation}* URI parameter. + +
+ **Limitations** + + This endpoint is limited to full-text searching including a *filter* like: + ```json + { + "category": "fts", + "name": "search", + "value": "sarcoma" + } + ```
**Nested Annotation** @@ -546,1621 +1038,2180 @@ documentation: }, ``` +
+ **Additional Property** + + A `match_text` property, included in each *annotation_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. + +
**Complete Example** - - **GET http://next.belframework.org/api/annotations/do/values/sarcoma** + + **GET http://localhost/api/annotations/do/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22sarcoma%22}&start=0&size=3** ```json { - "annotation_value": { - "type": "BiologicalProcessConcept", - "identifier": "1115", - "name": "sarcoma", - "annotation": { - "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", - "name": "Disease Ontology", - "prefix": "do", - "domain": "disease" + "annotation_value_collection": [ + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, + "match_text": "<>", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } }, - "_links": { - "self": { - "type": "annotation_value", - "href": "http://next.belframework.org/api/annotations/disease-ontology/values/1115" - }, - "collection": { - "type": "annotation", - "href": "http://next.belframework.org/api/annotations/disease-ontology" + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "3071", + "name": "gliosarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, + "match_text": "...3071 a ma oma coma rcoma arcoma <> osarcoma iosarcoma liosarcoma gliosarcoma toma stoma astoma...", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/3071" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "3382", + "name": "liposarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, + "match_text": "2 82 382 3382 a ma oma coma rcoma arcoma <> osarcoma posarcoma iposarcoma liposarcoma", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/3382" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } } } - } + ] } ``` + headers: {} responses: - 200: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "annotation_value_collection": [ + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "match_text": "<<sarcoma>>", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "3071", + "name": "gliosarcoma", + "match_text": "...3071 a ma oma coma rcoma arcoma <<sarcoma>> osarcoma iosarcoma liosarcoma gliosarcoma toma stoma astoma...", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/3071" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "3382", + "name": "liposarcoma", + "match_text": "2 82 382 3382 a ma oma coma rcoma arcoma <<sarcoma>> osarcoma posarcoma iposarcoma liposarcoma", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/3382" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + } + ] + } description: | [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) **JSON Schema** + - [annotation_value_collection](schemas/annotation_value_collection.schema.json) - [annotation_value](schemas/annotation_value_resource.schema.json) - body: - application/json: - example: !include examples/annotation_value_resource.example.json - 404: + queryParameters: + start: + type: integer description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - Returned if a resource was not found by *{annotation}* and *{value}*. -/evidence: - description: | - Evidence collection within the API. - - This provides storage and query of Evidence resources. - - BEL Evidence represents a biological finding extracted from scientific literature. It is comprised of 5 parts: - - Citation - - Identifies the reference (e.g. PubMed, Book, Journal, etc.) that contains supporting the *Summary Text*. - - - Summary Text - - The excerpt from the *Citation* that the *BEL Statement* is extracted from. + The annotation value resource to start from for paging purposes. + displayName: start + size: + type: integer + description: | + The size of the annotation value resource collection to retrieve. This will return a slice of the annotation value resource collection relative to *start*. - - BEL Statement + A size of zero or less will return all values. + displayName: size + filter: + type: string + description: | + A filter to apply to the annotation value resource collection to narrow the resources retrieved. + displayName: filter + faceted: + type: string + description: | + The boolean indicator to provided faceted results for the annotation value resource collection. The default is to not facet. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: faceted + '/{value}': + displayName: '{value}' + description: '' + uriParameters: + value: + description: value + type: string + displayName: value + get: + displayName: GET_annotations-annotation-values-value + description: | + Returns the *annotation_value* resource identified by *{annotation}* and *{value}* URI parameters. - An expression that represents knowledge of the existence of biological entities and relationships between them that are known to be observed within a particular *Experiment Context*. The structure of a BEL Statement is explained further on the [OpenBEL Wiki](http://wiki.openbel.org/display/BLVD/Statements). +
+ **Nested Annotation** - - Experiment Context + All returned *annotation_value* in the *annotation_value_collection* will include the *annotation* it is found in. + For example if *sarcoma* is found in the *Disease Ontology* annotation then the following will be included in the value: - Data (Key/Value) that describes parameters of the experiment. For example an evidence observed in the lung of a human could include Uberon's *lung* concept (i.e. [uberon/UBERON:0002048](http://identifiers.org/uberon/UBERON:0002048)) and NCBI Taxonomy's *homo sapiens* concept (i.e. [taxonomy/9606](http://identifiers.org/taxonomy/9606)) respectively. + ```json + annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, + ``` - - Metadata + **Complete Example** - Data (Key/Value) about this evidence resource useful for bookkeeping or system integration purposes. For example one might want to capture a *Reviewer* and *Review Status* to track who is reviewing and this evidence's status respectively. + **GET http://localhost/api/annotations/do/values/sarcoma** - - References - - States the vocabularies which the namespace and annotation values are drawn from. Each vocabulary should include a keyword and URI. - - options: - is: [ - create_options: { name: "evidence collection" } - ] - post: - description: | - Creates one or more Evidence resource within the API. - - The following formats are supported: - - Evidence JSON - - media type: `application/json` - - JSON schema: [evidence.schema.json](http://next.belframework.org/schemas/evidence.schema.json) - - BEL Script - - defined by [BEL Script V1.0 Format](http://wiki.openbel.org/display/BLDV20/BEL+Script+V1.0+Format) - - media type: `application/bel` - - XBEL (XML) - - media type: `application/xml` - - XML Schema: [xbel](http://resource.belframework.org/belframework/20150611/schema/xbel.xsd), [xbel-annotations](http://resource.belframework.org/belframework/20150611/schema/xbel-annotations.xsd) - - [BEL JSON Graph Format](http://jsongraphformat.info/) - - media type: `application/vnd.jgf+json` - - JSON schema: [bel-json-graph-2.0.schema.json](http://jsongraphformat.info/child-schemas/bel-json-graph-2.0.schema.json) - - BEL RDF - - defined within [bel.rb](https://github.com/OpenBEL/bel.rb) as a [format extension](https://github.com/OpenBEL/bel.rb/wiki/Format-Extensions). See [source](https://github.com/OpenBEL/bel.rb/tree/c1471942ce8326ad2399d66154c858d6a9fbcd6b/lib/bel/extensions/rdf) - - media type - - `application/n-quads` - - `application/n-triples` - - `application/rdf+xml` - - `application/turtle` - - `application/x-turtle` - - `text/turtle` - -
- If you send a single Evidence JSON object then the resource's *Location* will be returned. However if you send multiple Evidence resources using any of the supported formats above then a *Location* will not be returned. This will be addressed in a future version. - - responses: - 201: - description: | - [201 Created](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2) - - The Evidence resource was created. - - The link to the evidence resource is conveyed is the *Link* header. This will only be set when a single Evidence resource is created. - 415: - description: | - [415 Unsupported Media Type](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16) - - The evidence resource body was not a supported media type.. - body: - application/json: - example: | - { - "evidence": { - "bel_statement": "p(HGNC:MAPK1,pmod(P,T)) => kin(p(HGNC:MAPK1))", - "citation": { - "type": "PubMed", - "name": "J Biol Chem. 1997 Jul 4;272(27):16917-23.", - "id": "9202001" - }, - "summary_text": "These kinases are regulated by the reversible dual\nphosphorylation of conserved threonine and tyrosine residues.", - "experiment_context": [ - { - "name": "Species", - "value": "9606", - "uri": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno/9606", - "url": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" - }, - { - "name": "CellLine", - "value": "U-937", - "uri": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno/U-937", - "url": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" - } - ], - "references": { - "namespaces": { - "SFAM": "http://resource.belframework.org/belframework/20150611/namespace/selventa-protein-families.belns", - "SCOMP": "http://resource.belframework.org/belframework/20150611/namespace/selventa-named-complexes.belns", - "HGNC": "http://resource.belframework.org/belframework/20150611/namespace/hgnc-human-genes.belns", - "CHEBI": "http://resource.belframework.org/belframework/20150611/namespace/chebi.belns" - }, - "annotations": { - "CellLine": { - "type": "url", - "domain": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" + ```json + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" }, - "Species": { - "type": "url", - "domain": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" - } - } - }, - "metadata": [ - { - "name": "document_header", - "value": { - "Name": "BEL Framework Example 1 Document", - "Description": "Example of modeling a full abstract taken from the BEL V1.0 Language Overview. ", - "Version": "20150611", - "Copyright": "Copyright (c) 2011-2015, Selventa. All Rights Reserved.", - "ContactInfo": "support@belframework.org", - "Authors": "Selventa", - "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License" + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } } } - ] - } - } - - application/bel: - example: | - SET DOCUMENT Name = "BEL Framework Example 1 Document" - SET DOCUMENT Description = "Example of modeling a full abstract taken from the BEL V1.0 Language Overview. " - SET DOCUMENT Version = "20150611" - SET DOCUMENT Copyright = "Copyright (c) 2011-2015, Selventa. All Rights Reserved." - SET DOCUMENT ContactInfo = "support@belframework.org" - SET DOCUMENT Authors = "Selventa" - SET DOCUMENT Licenses = "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License" - - DEFINE NAMESPACE SFAM AS URL "http://resource.belframework.org/belframework/20150611/namespace/selventa-protein-families.belns" - DEFINE NAMESPACE SCOMP AS URL "http://resource.belframework.org/belframework/20150611/namespace/selventa-named-complexes.belns" - DEFINE NAMESPACE HGNC AS URL "http://resource.belframework.org/belframework/20150611/namespace/hgnc-human-genes.belns" - DEFINE NAMESPACE CHEBI AS URL "http://resource.belframework.org/belframework/20150611/namespace/chebi.belns" - - DEFINE ANNOTATION CellLine AS URL "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" - DEFINE ANNOTATION Species AS URL "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" - - SET Citation = {"PubMed","J Biol Chem. 1997 Jul 4;272(27):16917-23.","9202001"} - SET Evidence = "These kinases are regulated by the reversible dual - SET Species = "9606" - SET CellLine = "U-937" - p(HGNC:MAPK1,pmod(P,T)) => kin(p(HGNC:MAPK1)) - - application/xml: - example: | - <?xml version="1.0"?> - <bel:document xmlns:bel="http://belframework.org/schema/1.0/xbel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://belframework.org/schema/1.0/xbel http://resource.belframework.org/belframework/1.0/schema/xbel.xsd"> - <bel:header> - <bel:name>BEL Framework Example 1 Document</bel:name> - <bel:description>Example of modeling a full abstract taken from the BEL V1.0 Language Overview. </bel:description> - <bel:version>20150611</bel:version> - <bel:copyright>Copyright (c) 2011-2015, Selventa. All Rights Reserved.</bel:copyright> - <bel:contactInfo>support@belframework.org</bel:contactInfo> - <bel:authorGroup> - <bel:author>Selventa</bel:author> - </bel:authorGroup> - <bel:licenseGroup> - <bel:license>Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License</bel:license> - </bel:licenseGroup> - </bel:header> - <bel:namespaceGroup> - <bel:namespace bel:prefix="SFAM" bel:resourceLocation="http://resource.belframework.org/belframework/20150611/namespace/selventa-protein-families.belns"/> - <bel:namespace bel:prefix="SCOMP" bel:resourceLocation="http://resource.belframework.org/belframework/20150611/namespace/selventa-named-complexes.belns"/> - <bel:namespace bel:prefix="HGNC" bel:resourceLocation="http://resource.belframework.org/belframework/20150611/namespace/hgnc-human-genes.belns"/> - <bel:namespace bel:prefix="CHEBI" bel:resourceLocation="http://resource.belframework.org/belframework/20150611/namespace/chebi.belns"/> - </bel:namespaceGroup> - <bel:annotationDefinitionGroup> - <bel:externalAnnotationDefinition bel:id="CellLine" bel:url="http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno"/> - <bel:externalAnnotationDefinition bel:id="Species" bel:url="http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno"/> - </bel:annotationDefinitionGroup> - <bel:statementGroup> - <bel:statement bel:relationship="=>"> - <bel:annotationGroup> - <bel:citation bel:type="PubMed"> - <bel:reference>9202001</bel:reference> - <bel:name>J Biol Chem. 1997 Jul 4;272(27):16917-23.</bel:name> - </bel:citation> - <bel:evidence>These kinases are regulated by the reversible dual - phosphorylation of conserved threonine and tyrosine residues.</bel:evidence> - <bel:annotation bel:refID="Species">9606</bel:annotation> - <bel:annotation bel:refID="CellLine">U-937</bel:annotation> - </bel:annotationGroup> - <bel:subject> - <bel:term bel:function="proteinAbundance"> - <bel:parameter bel:ns="HGNC">MAPK1</bel:parameter> - <bel:term bel:function="proteinModification"> - <bel:parameter>P</bel:parameter> - <bel:parameter>T</bel:parameter> - </bel:term> - </bel:term> - </bel:subject> - <bel:object> - <bel:term bel:function="kinaseActivity"> - <bel:term bel:function="proteinAbundance"> - <bel:parameter bel:ns="HGNC">MAPK1</bel:parameter> - </bel:term> - </bel:term> - </bel:object> - </bel:statement> - </bel:statementGroup> - </bel:document> - - application/vnd.jgf+json: - example: | - { - "graph": { - "type": "BEL-V1.0", - "nodes": [ - { - "id": "p(HGNC:MAPK1,pmod(P,T))", - "label": "p(HGNC:MAPK1,pmod(P,T))" - }, - { - "id": "kin(p(HGNC:MAPK1))", - "label": "kin(p(HGNC:MAPK1))" - } - ], - "edges": [ - { - "source": "p(HGNC:MAPK1,pmod(P,T))", - "relation": "=>", - "target": "kin(p(HGNC:MAPK1))" - } - ] - } - } - - application/n-triples: - example: | - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Term> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/ModifiedProteinAbundance> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> <http://www.w3.org/2000/01/rdf-schema#label> "p(HGNC:MAPK1,pmod(P,T))" . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> <http://www.openbel.org/vocabulary/hasModificationType> <http://www.openbel.org/vocabulary/Phosphorylation> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> <http://www.openbel.org/vocabulary/hasChild> <http://www.openbel.org/bel/p_HGNC_MAPK1> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Term> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/ProteinAbundance> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/2000/01/rdf-schema#label> "p(HGNC:MAPK1)" . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasConcept> <http://www.openbel.org/bel/namespace/hgnc-human-genes/MAPK1> . - <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Term> . - <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/AbundanceActivity> . - <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasActivityType> <http://www.openbel.org/vocabulary/Kinase> . - <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> <http://www.w3.org/2000/01/rdf-schema#label> "kin(p(HGNC:MAPK1))" . - <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasChild> <http://www.openbel.org/bel/p_HGNC_MAPK1> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Term> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/ProteinAbundance> . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.w3.org/2000/01/rdf-schema#label> "p(HGNC:MAPK1)" . - <http://www.openbel.org/bel/p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasConcept> <http://www.openbel.org/bel/namespace/hgnc-human-genes/MAPK1> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasSubject> <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasObject> <http://www.openbel.org/bel/kin_p_HGNC_MAPK1> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasRelationship> <http://www.openbel.org/vocabulary/DirectlyIncreases> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Statement> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.w3.org/2000/01/rdf-schema#label> "p(HGNC:MAPK1,pmod(P,T)) => kin(p(HGNC:MAPK1))" . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.openbel.org/vocabulary/Evidence> . - <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> <http://www.openbel.org/vocabulary/hasEvidence> _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.openbel.org/vocabulary/hasStatement> <http://www.openbel.org/bel/p_HGNC_MAPK1_pmod_P_T_DirectlyIncreases_kin_p_HGNC_MAPK1> . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.openbel.org/vocabulary/hasCitation> <http://bio2rdf.org/pubmed:9202001> . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.openbel.org/vocabulary/hasEvidenceText> "These kinases are regulated by the reversible dual\nphosphorylation of conserved threonine and tyrosine residues." . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.openbel.org/vocabulary/hasAnnotation> <http://www.openbel.org/bel/annotation/species-taxonomy-id/9606> . - _:1ddf16d0-4a7b-0133-5cfc-082e5f8a66ae <http://www.openbel.org/vocabulary/hasAnnotation> <http://www.openbel.org/bel/annotation/cell-line/U-937> . - - get: - description: | - Retrieve the evidence resource collection. - - All evidence resources will be returned by default. - - The collection can be returned page by page by providing a *start* (defaults to `0`) index and *size* (defaults to no size limit) to return. - - This collection can be filtered by providing one or more *filter* options. A filter specifies the *category*, *name*, and *value* of the filter and is encoded as a JSON object. For example an evidence metadata filter might be encoded as: - - ```json - { - "category": "metadata", - "name": "status", - "value": "Approved" - } - ``` - - This collection can be filtered using by a full-text search filter such as: - - ```json - { - "category": "fts", - "name": "search", - "value": "lung liver pancreas" - } - ``` - - ```json - { - "category": "fts", - "name": "search", - "value": "\"subdural hematoma\"" - } - ``` - - This collection can specify the *faceted* boolean option. Facets will reflect all (possibly filtered) evidence resources irrespective of *start* and *size* paging. - - Facts are an array of facet objects that are composed of a *filter* and *count*. For example for the evidence metadata filter the facet object would be encoded as: - - ```json - { - "category": "metadata", - "name": "Status", - "values": [ - { - "value": "Approved", - "filter": "{\"category\":\"metadata\",\"name\":\"status\",\"value\":\"Approved\"}", - "count": 10200 - } - ] - }, - ``` - - The *filter* property value can be used as a *filter* option. This is intended to support filtering the evidence resource collection by selected facets. + } + ``` + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - The *max_values_per_facet* option can be specified to limit the number of returned facet values by category, name pairs. For example, setting *max_values_per_facet* to `2` would return up to 2 distinct facets values for `{ "category": "citation", "name": "id", ... }`. - headers: - Accept: - displayName: Accept - description: | - The Accept header informs the server which media types the client accepts. - queryParameters: - start: - type: integer + **JSON Schema** + - [annotation_value](schemas/annotation_value_resource.schema.json) + queryParameters: {} + options: + displayName: OPTIONS_annotations-annotation-values-value + description: | + Returns allowable HTTP methods for this annotation_value resource. + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_annotations-annotation-values + description: | + Returns allowable HTTP methods for this annotation_value_collection. + headers: {} + responses: {} + queryParameters: {} + uriParameters: + annotation: + description: annotation + type: string + displayName: annotation + options: + displayName: OPTIONS_annotations-annotation description: | - The evidence resource to start from for paging purposes. - - The default value is `0`. This value will return evidence resources starting from the beginning of collection. - example: 100 - required: false - size: - type: integer + Returns allowable HTTP methods for this annotation resource. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_annotations-annotation description: | - The size of the evidence resource collection to retrieve. This will return a slice of the evidence resource collection relative to *start*. + Returns the *annotation* resource identified by *{annotation}* URI parameter. + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/do" + } + } + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - The default is `0`. This value will return all evidence resources in the collection. - example: 100 - required: false - filter: - type: string + **JSON Schema** + - [annotation](schemas/annotation_resource.schema.json) + queryParameters: {} + /values: + displayName: values + description: '' + uriParameters: {} + get: + displayName: GET_annotations-values description: | - A filter to apply to the evidence resource collection to narrow the resources retrieved. - - The default is to not apply filters. If filters are not specified then all evidence resources, in the collection, will be returned. + Returns the *annotation_value_collection* across all *annotation* resources. - **Example Usage:** +
+ **Limitations** - Find evidence matching either `prostate` or `gland`. - ``` - {"category":"experiment_context","name":"Anatomy","value":"prostate gland"} + This endpoint is limited to full-text searching including a *filter* like: + ```json + { + "category": "fts", + "name": "search", + "value": "sarcoma" + } ``` - Find evidence matching the phrase `subdural hematoma` or `carcinoma`. - ``` - {"category":"fts","name":"search","value":"\"subdural hematoma\" carcinoma"} - ``` +
+ **Nested Annotation** - Find evidence matching `homatoma` but not `carcinoma`. - ``` - {"category":"fts","name":"search","value":"homatoma -carcinoma"} + All returned *annotation_value* in the *annotation_value_collection* will include the *annotation* it is found in. + For example if *sarcoma* is found in the *Disease Ontology* annotation then the following will be included in the value: + + ```json + annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" + }, ``` - example: | - {"category":"experiment_context","name":"Anatomy","value":"prostate gland"} - required: false - faceted: - type: string - description: | - The boolean indicator to provided faceted results for the evidence resource collection. - - The default is `false`. This value will not return facets in the response. - enum: [ 'true', 'yes', '1', 'on' ] - example: yes - max_values_per_facet: - type: integer - description: e| - The maximum about of facet values to display for every category, name pair. - - The default is `0`. This value will return all facet values (i.e. unbounded) for every category, name pair. - example: 20 - required: false - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - An example request for this resource might be: +
+ **Additional Property** - - Path: `/api/evidence` - - Query parameters: - - `start=0` - - `size=1` - - `faceted=yes` - - `max_values_per_facet=1` - - `filter` - ```json - { - "category":"experiment_context", - "name":"Anatomy", - "value":"prostate gland" - } - ``` + A `match_text` property, included in each *annotation_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. - Example URL: [http://next.belframework.org/api/evidence?start=0&size=1&faceted=yes&max_values_per_facet=1&filter={"category":"experiment_context","name":"Anatomy","value":"prostate gland"}](http://next.belframework.org/api/evidence?start=0&size=1&faceted=yes&max_values_per_facet=1&filter={%22category%22:%22experiment_context%22,%22name%22:%22Anatomy%22,%22value%22:%22prostate gland%22}) +
+ **Complete Example** - **JSON Schema** - - [evidence_collection](schemas/evidence_collection.schema.json) - - [evidence_resource](schemas/evidence_resource.schema.json) - - [evidence](schemas/evidence.schema.json) + **GET http://localhost/api/annotations/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22sarcoma%22}&start=0&size=3** - body: - application/json: - example: | + ```json + { + "annotation_value_collection": [ { - "evidence_collection": [ - { - "evidence": { - "bel_statement": "a(CHEBI:\"1-octadec-9-enoylglycero-3-phosphate\") increases kin(p(HGNC:EGFR))", - "citation": { - "type": "PubMed", - "name": "Exp Cell Res 2003 Mar 10 284(1) 99-110", - "id": "12648469", - "date": "", - "authors": [], - "comment": "" - }, - "summary_text": "Treatment of cells with GPCR agonists such as endothelin- 1 (ET-1), thrombin, bombesin, and lysophosphatidic acid (LPA) transactivates ErbB1 (reviewed by Zwick et al. [48]). Mechanistically, the process involves rapid stimulation of metalloproteinases followed by cleavage of an ErbB1 ligand precursor, e.g., pro-HB-EGF [49], whose binding activates ErbB1 and downstream signaling pathways", - "experiment_context": [ - { - "name": "Species", - "value": "9606" - }, - { - "name": "Anatomy", - "value": "prostate gland" - }, - { - "name": "Cell", - "value": "squamous epithelial cell" - } - ], - "metadata": [ - { - "name": "document_header", - "value": { - "Name": "BEL Framework Large Corpus Document", - "Description": "Approximately 61,000 statements.", - "Version": "20150611", - "Copyright": "Copyright (c) 2011-2015, Selventa. All rights reserved.", - "Authors": "Selventa", - "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License", - "ContactInfo": "support@belframework.org" - } - } - ] + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "D012509", + "name": "Sarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/mesh-diseases", + "name": "Mesh Diseases", + "prefix": "meshd", + "domain": "disease" + }, + "match_text": "...Sarcomas, Spindle Cell Soft Tissue <> Soft Tissue Sarcomas Spindle Cell <> Spindle Cell Sarcomas", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/mesh-diseases/values/D012509" }, - "_links": { - "self": { - "type": "evidence", - "href": "http://next.belframework.org/api/evidence/56015a638a4cca1317005637" - }, - "collection": { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence" - } + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/mesh-diseases" } } - ], - "facets": [ - { - "category": "metadata", - "name": "document_header", - "values": [ - { - "value": [ - "Authors", - "Selventa" - ], - "filter": "{\"category\":\"metadata\",\"name\":\"document_header\",\"value\":[\"Authors\",\"Selventa\"]}", - "count": 423 - } - ] - }, - { - "category": "experiment_context", - "name": "Anatomy", - "values": [ - { - "value": "prostate gland", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}", - "count": 423 - } - ] - }, - { - "category": "experiment_context", - "name": "Species", - "values": [ - { - "value": "9606", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Species\",\"value\":\"9606\"}", - "count": 263 - } - ] - }, - { - "category": "citation", - "name": "id", - "values": [ - { - "value": "12351634", - "filter": "{\"category\":\"citation\",\"name\":\"id\",\"value\":\"12351634\"}", - "count": 62 - } - ] - }, - { - "category": "experiment_context", - "name": "Cell", - "values": [ - { - "value": "fibroblast", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Cell\",\"value\":\"fibroblast\"}", - "count": 20 - } - ] - }, - { - "category": "experiment_context", - "name": "Cellline", - "values": [ - { - "value": "LNCAP cell", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Cellline\",\"value\":\"LNCAP cell\"}", - "count": 17 - } - ] - }, - { - "category": "experiment_context", - "name": "Disease", - "values": [ - { - "value": "prostate carcinoma in situ", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Disease\",\"value\":\"prostate carcinoma in situ\"}", - "count": 13 - } - ] - }, - { - "category": "experiment_context", - "name": "Cellstructure", - "values": [ - { - "value": "Cytoplasm", - "filter": "{\"category\":\"experiment_context\",\"name\":\"Cellstructure\",\"value\":\"Cytoplasm\"}", - "count": 4 - } - ] - } - ], - "metadata": { - "collection_paging": { - "total": 52399, - "total_filtered": 423, - "total_pages": 423, - "current_page": 1, - "current_page_size": 1 - } - }, - "_links": { - "self": { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence?start=0&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" - }, - "start": { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence?start=0&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" - }, - "next": { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence?start=1&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" - } } - } - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - The evidence collection could not be found given your request. This typically indicates an empty evidence collection for the provided query parameters. - 406: - description: | - [406 Not Acceptable](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7) - - The evidence collection identified cannot be returned in the client-specified Content Type. - /{identifier}: - description: - options: - is: [ - rw_options: { name: "evidence resource" } - ] - get: - description: | - Retrieve the Evidence resource identified by *{identifier}*. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - An example request for this resource might be: - - - Path: `/api/evidence/56015c7e8a4cca1317006aa7` - - Example URL: [http://next.belframework.org/api/evidence/56015c7e8a4cca1317006aa7](http://next.belframework.org/api/evidence/56015c7e8a4cca1317006aa7) - - **JSON Schema** - - [evidence_resource](schemas/evidence_resource.schema.json) - - [evidence](schemas/evidence.schema.json) - - body: - application/json: - example: | - { - "evidence": { - "bel_statement": "a(\"cyclic AMP\") increases r(HGNC:AR)", - "citation": { - "type": "PubMed", - "name": "J Clin Endocrinol Metab 2003 Sep 88(9) 4043-54", - "id": "12970260", - "date": "", - "authors": [], - "comment": "" - }, - "summary_text": "Treatment with the cAMP analog dibutyryl cAMP enhanced AR promoter activity about 4- to 6-fold in a reporter gene assay and increased AR mRNA expression in LNCaP cells", - "experiment_context": [ - { - "name": "Species", - "value": "9606" - } - ], - "metadata": [ - { - "name": "document_header", - "value": { - "Name": "BEL Framework Large Corpus Document", - "Description": "Approximately 61,000 statements.", - "Version": "20150611", - "Copyright": "Copyright (c) 2011-2015, Selventa. All rights reserved.", - "Authors": "Selventa", - "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License", - "ContactInfo": "support@belframework.org" - } - } - ] + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "name": "Disease Ontology", + "prefix": "do", + "domain": "disease" }, + "match_text": "<>", "_links": { "self": { - "type": "evidence", - "href": "http://next.belframework.org/api/evidence/56015c7e8a4cca1317006aa7" + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" }, "collection": { - "type": "evidence_collection", - "href": "http://next.belframework.org/api/evidence" + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" } } } - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - The evidence resource could not be found for the given *{identifier}*. - 406: - description: | - [406 Not Acceptable](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7) - - The evidence resource identified cannot be returned in the client-specified Content Type. - put: - description: | - Replaces an Evidence resource identified by *{identifier}*. - - **JSON Schema** - - [evidence_resource](schemas/evidence_resource.schema.json) - - [evidence](schemas/evidence.schema.json) - body: - application/json: - example: | - { - "evidence": { - "bel_statement": "p(HGNC:MAPK1,pmod(P,T)) => kin(p(HGNC:MAPK1))", - "citation": { - "type": "PubMed", - "name": "J Biol Chem. 1997 Jul 4;272(27):16917-23.", - "id": "9202001" - }, - "summary_text": "These kinases are regulated by the reversible dual\nphosphorylation of conserved threonine and tyrosine residues.", - "experiment_context": [ - { - "name": "Species", - "value": "9606", - "uri": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno/9606", - "url": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" - }, - { - "name": "CellLine", - "value": "U-937", - "uri": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno/U-937", - "url": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" - } - ], - "references": { - "namespaces": { - "SFAM": "http://resource.belframework.org/belframework/20150611/namespace/selventa-protein-families.belns", - "SCOMP": "http://resource.belframework.org/belframework/20150611/namespace/selventa-named-complexes.belns", - "HGNC": "http://resource.belframework.org/belframework/20150611/namespace/hgnc-human-genes.belns", - "CHEBI": "http://resource.belframework.org/belframework/20150611/namespace/chebi.belns" + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "D008223", + "name": "Lymphoma", + "annotation": { + "rdf_uri": "http://www.openbel.org/bel/namespace/mesh-diseases", + "name": "Mesh Diseases", + "prefix": "meshd", + "domain": "disease" }, - "annotations": { - "CellLine": { - "type": "url", - "domain": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" + "match_text": "Germinoblastic <> Germinoblastic Sarcomas Germinoblastoma Germinoblastomas Lymphoma, Malignant Lymphomas Lymphomas, Malignant Malignant Lymphoma Malignant Lymphomas...", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/mesh-diseases/values/D008223" }, - "Species": { - "type": "url", - "domain": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/mesh-diseases" } } - }, - "metadata": [ + } + } + ] + } + ``` + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- { - "name": "document_header", - "value": { - "Name": "BEL Framework Example 1 Document", - "Description": "Example of modeling a full abstract taken from the BEL V1.0 Language Overview. ", - "Version": "20150611", - "Copyright": "Copyright (c) 2011-2015, Selventa. All Rights Reserved.", - "ContactInfo": "support@belframework.org", - "Authors": "Selventa", - "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License" - } + "annotation_value_collection": [ + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "D012509", + "name": "Sarcoma", + "match_text": "...Sarcomas, Spindle Cell Soft Tissue <<Sarcoma>> Soft Tissue Sarcomas Spindle Cell <<Sarcoma>> Spindle Cell Sarcomas", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/mesh-diseases/values/D012509" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/mesh-diseases" + } + } + } + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "1115", + "name": "sarcoma", + "match_text": "<<sarcoma>>", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/disease-ontology/values/1115" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/disease-ontology" + } + } + } + }, + { + "annotation_value": { + "type": "BiologicalProcessConcept", + "identifier": "D008223", + "name": "Lymphoma", + "match_text": "Germinoblastic <<Sarcoma>> Germinoblastic Sarcomas Germinoblastoma Germinoblastomas Lymphoma, Malignant Lymphomas Lymphomas, Malignant Malignant Lymphoma Malignant Lymphomas...", + "_links": { + "self": { + "type": "annotation_value", + "href": "http://localhost/api/annotations/mesh-diseases/values/D008223" + }, + "collection": { + "type": "annotation", + "href": "http://localhost/api/annotations/mesh-diseases" + } + } + } + } + ] } - ] - } - } - responses: - 202: - description: | - [202 Accepted](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3) - - The action to replace the evidence resource, identified by *{identifier}*, was accepted by the API. The evidence resource is considered replaced if a subsequent `GET /api/evidence/{identifier}` request returns a representation that reflects the body sent in this `PUT` request. - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - The evidence resource, identified by *{identifier}*, does not exist. - 415: - description: | - [415 Unsupported Media Type](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16) - - The evidence resource body was not a supported media type. - delete: - description: | - Deletes an Evidence resource identified by *{identifier}*. - responses: - 202: - description: | - [202 Accepted](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3) - - The action to delete the evidence resource, identified by *{identifier}*, was accepted by the API. The evidence resource is considered removed if a subsequent `GET /api/evidence/{identifier}` request returns [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5). - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - The evidence resource, identified by *{identifier}*, does not exist. -/expressions: - /{bel}/completions: - description: | - Retrieve completions for the *BEL* expression fragment. The caret position to complete from defaults to the end of *BEL* expression fragment. - - Examples: - - - *aabund* yields functions *microRNAAbundance* and *rnaAbundance* - - *p(H* yields functions *chaperoneActivity*, *pathology*, *phosphataseActivity* and namespace prefixes *CHEBI*, *CHEBIID*, *HGNC*, *MESHCS*, *MESHD*, *MESHPP*, *SCHEM* - - *tscript(p(HGNC:* yields namespace values *AKT1*, *AKT2*, etc. - - Custom Caret Position: - - The caret position can be provided to indicate where to complete from. + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - Examples: + **JSON Schema** + - [annotation_value_collection](schemas/annotation_value_collection.schema.json) + - [annotation_value](schemas/annotation_value_resource.schema.json) + queryParameters: + start: + type: integer + description: | + The annotation value resource to start from for paging purposes. + displayName: start + size: + type: integer + description: | + The size of the annotation value resource collection to retrieve. This will return a slice of the annotation value resource collection relative to *start*. - - *pro(HGNC:*, *caret_position*: `2` yields functions *biologicalProcess*, *products*, *proteinAbundance*, and *proteinModification* - uriParameters: - bel: - type: string - description: BEL statement fragment; Completions will be provided for this input. - required: false - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string + A size of zero or less will return all values. + displayName: size + filter: + type: string + description: | + A filter to apply to the annotation value resource collection to narrow the resources retrieved. + displayName: filter + faceted: + type: string + description: | + The boolean indicator to provided faceted results for the annotation value resource collection. The default is to not facet. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: faceted + options: + displayName: OPTIONS_annotations-values + description: | + Returns allowable HTTP methods for this annotation_value_collection. + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} get: + displayName: GET_annotations description: | - Retrieve completions for the *BEL* expression fragment. The caret position to complete from defaults to the end of *BEL* expression fragment. - - Examples: - - - *aabund* yields functions *microRNAAbundance* and *rnaAbundance* - - *p(H* yields functions *chaperoneActivity*, *pathology*, *phosphataseActivity* and namespace prefixes *CHEBI*, *CHEBIID*, *HGNC*, *MESHCS*, *MESHD*, *MESHPP*, *SCHEM* - - *tscript(p(HGNC:* yields namespace values *AKT1*, *AKT2*, etc. - - Custom Caret Position: - - The caret position can be provided to indicate where to complete from. + Returns the *annotation_collection* containing an array of all *annotation* resources. - Examples: + An *annotation* resource contains fields: + - prefLabel: human-readable name + - prefix: short prefix + - domain: biological domain - - *pro(HGNC:*, *caret_position*: `2` yields functions *biologicalProcess*, *products*, *proteinAbundance*, and *proteinModification* - headers: - Accept: - displayName: Accept - queryParameters: - caret_position: - type: integer - description: The position of the caret within the *bel* input. Defaults to the right-most caret_position for *bel* (e.g. length of *bel* input). - example: 0 - required: false + The collection contains zero or more *annotation* resource objects. If the *annotation_collection* is empty then the result is an empty array. + headers: {} responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [completion_collection](schemas/completion_collection.schema.json) - - [completion_resource](schemas/completion_resource.schema.json) + '200': body: application/json: - example: | + schema: '{}' + example: |- { - "completion_collection": [ - { - "completion": { - "type": "namespace_prefix", - "label": "HGNC", - "value": "HGNC:", - "highlight": { - "start_position": 2, - "end_position": 3, - "range_type": "inclusive" + "annotation_collection": [ + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/cell-line-ontology", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Cell Line Ontology", + "domain": "cell-line", + "prefix": "clo" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/clo" + } + } }, - "actions": [ - { - "delete": { - "start_position": 2, - "end_position": 3, - "range_type": "inclusive" + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/cell-ontology", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Cell Ontology", + "domain": "cell", + "prefix": "cl" }, - "insert": { - "position": 2, - "value": "HGNC:" + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/cl" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/disease-ontology", + "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", + "prefLabel": "Disease Ontology", + "domain": "disease", + "prefix": "do" }, - "move_cursor": { - "position": 7 + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/do" + } } - } - ] - } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/experimental-factor-ontology", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Experimental Factor Ontology", + "domain": "cell-line", + "prefix": "efo" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/efo" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/mesh-anatomy", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Mesh Anatomy", + "domain": "anatomy", + "prefix": "mesha" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/mesha" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/mesh-cellular-structures", + "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", + "prefLabel": "Mesh Cellular Structures", + "domain": "location", + "prefix": "meshcs" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/meshcs" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/mesh-diseases", + "type": "http://www.openbel.org/vocabulary/NamespaceConceptScheme", + "prefLabel": "Mesh Diseases", + "domain": "disease", + "prefix": "meshd" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/meshd" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/ncbi-taxonomy", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Ncbi Taxonomy", + "domain": "species", + "prefix": "taxon" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/taxon" + } + } + }, + { + "annotation": { + "uri": "http://www.openbel.org/bel/namespace/uberon", + "type": "http://www.w3.org/2004/02/skos/core#ConceptScheme", + "prefLabel": "Uberon", + "domain": "anatomy", + "prefix": "uberon" + }, + "_links": { + "self": { + "type": "annotation", + "href": "http://localhost/api/annotations/uberon" + } + } + } + ], + "_links": { + "self": { + "type": "annotation_collection", + "href": "http://localhost/api/annotations" + }, + "start": { + "type": "start", + "href": "http://localhost/api/annotations/values" + } } - ] } - /{bel}/components: - description: | - Retrieve the components of a *BEL* expression fragment. Currently this will only return the *subject*, *relationship*, and *object* understood from BEL statement expression. - uriParameters: - bel: - type: string - description: BEL statement expression to recognize; Components will be returned for this input. - required: false - options: - description: Returns allowable HTTP methods. - responses: - 200: description: | [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + + **JSON Schema** + - [annotation_collection](schemas/annotation_collection.schema.json) + - [annotation](schemas/annotation_resource.schema.json) + queryParameters: {} + options: + displayName: OPTIONS_annotations + description: | + Returns allowable HTTP methods for this annotation_collection. + headers: {} + responses: {} + queryParameters: {} + /expressions: + displayName: expressions + description: '' + '/{bel}': + displayName: '{bel}' + description: '' + /completions: + displayName: completions + description: '' + uriParameters: {} + get: + displayName: GET_expressions-bel-completions + description: | + Retrieve completions for the *BEL* expression fragment. The caret position to complete from defaults to the end of *BEL* expression fragment. + + Examples: + + - *aabund* yields functions *microRNAAbundance* and *rnaAbundance* + - *p(H* yields functions *chaperoneActivity*, *pathology*, *phosphataseActivity* and namespace prefixes *CHEBI*, *CHEBIID*, *HGNC*, *MESHCS*, *MESHD*, *MESHPP*, *SCHEM* + - *tscript(p(HGNC:* yields namespace values *AKT1*, *AKT2*, etc. + + Custom Caret Position: + + The caret position can be provided to indicate where to complete from. + + Examples: + + - *pro(HGNC:*, *caret_position*: `2` yields functions *biologicalProcess*, *products*, *proteinAbundance*, and *proteinModification* headers: Accept: - description: Allowable HTTP methods. - type: string - get: - description: | - Retrieve the components of a *BEL* expression fragment. Currently this will only return the *subject*, *relationship*, and *object* understood from BEL statement expression. + type: string + displayName: Accept + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "completion_collection": [ + { + "completion": { + "type": "namespace_prefix", + "label": "HGNC", + "value": "HGNC:", + "highlight": { + "start_position": 2, + "end_position": 3, + "range_type": "inclusive" + }, + "actions": [ + { + "delete": { + "start_position": 2, + "end_position": 3, + "range_type": "inclusive" + }, + "insert": { + "position": 2, + "value": "HGNC:" + }, + "move_cursor": { + "position": 7 + } + } + ] + } + } + ] + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + + **JSON Schema** + - [completion_collection](schemas/completion_collection.schema.json) + - [completion_resource](schemas/completion_resource.schema.json) + queryParameters: + caret_position: + type: integer + description: | + The position of the caret within the *bel* input. Defaults to the right-most caret_position for *bel* (e.g. length of *bel* input). + displayName: caret_position + options: + displayName: OPTIONS_expressions-bel-completions + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + /components: + displayName: components + description: '' + uriParameters: {} + options: + displayName: OPTIONS_expressions-bel-components + description: Returns allowable HTTP methods. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_expressions-bel-components + description: | + Retrieve the components of a *BEL* expression fragment. Currently this will only return the *subject*, *relationship*, and *object* understood from BEL statement expression. - Examples: + Examples: - - *p(HGNC:AKT1)* yields: + - *p(HGNC:AKT1)* yields: - ```json - { - "expression_components": { - "subject": { - "term": { - "fx": "proteinAbundance", - "arguments": [ - { - "parameter": { - "ns": "HGNC", - "value": "AKT1" - } + ```json + { + "expression_components": { + "subject": { + "term": { + "fx": "proteinAbundance", + "arguments": [ + { + "parameter": { + "ns": "HGNC", + "value": "AKT1" + } + } + ] } - ] - } - }, - "relationship": null, - "object": null - }, - "statement_short_form": "p(HGNC:AKT1)" - } - ``` + }, + "relationship": null, + "object": null + }, + "statement_short_form": "p(HGNC:AKT1)" + } + ``` - - *p(HGNC:AKT1) -> bp(MESHPP:Apoptosis)* yields: + - *p(HGNC:AKT1) -> bp(MESHPP:Apoptosis)* yields: - ```json - { - "expression_components": { - "subject": { - "term": { - "fx": "proteinAbundance", - "arguments": [ - { - "parameter": { - "ns": "HGNC", - "value": "AKT1" - } + ```json + { + "expression_components": { + "subject": { + "term": { + "fx": "proteinAbundance", + "arguments": [ + { + "parameter": { + "ns": "HGNC", + "value": "AKT1" + } + } + ] } - ] - } - }, - "relationship": "increases", - "object": { - "term": { - "fx": "biologicalProcess", - "arguments": [ - { - "parameter": { - "ns": "MESHPP", - "value": "Apoptosis" - } + }, + "relationship": "increases", + "object": { + "term": { + "fx": "biologicalProcess", + "arguments": [ + { + "parameter": { + "ns": "MESHPP", + "value": "Apoptosis" + } + } + ] } - ] - } + } + }, + "statement_short_form": "p(HGNC:AKT1) -> bp(MESHPP:Apoptosis)" } - }, - "statement_short_form": "p(HGNC:AKT1) -> bp(MESHPP:Apoptosis)" - } - ``` + ``` - - *a(CHEBI:"phosphatidyl-L-serine") increases pep(p(HGNC:F3))* yields: + - *a(CHEBI:"phosphatidyl-L-serine") increases pep(p(HGNC:F3))* yields: - ```json - { - "expression_components": { - "subject": { - "term": { - "fx": "abundance", - "arguments": [ - { - "parameter": { - "ns": "CHEBI", - "value": "phosphatidyl-L-serine" - } + ```json + { + "expression_components": { + "subject": { + "term": { + "fx": "abundance", + "arguments": [ + { + "parameter": { + "ns": "CHEBI", + "value": "phosphatidyl-L-serine" + } + } + ] } - ] - } - }, - "relationship": "increases", - "object": { - "term": { - "fx": "peptidaseActivity", - "arguments": [ - { - "term": { - "fx": "proteinAbundance", - "arguments": [ - { - "parameter": { - "ns": "HGNC", - "value": "F3" - } + }, + "relationship": "increases", + "object": { + "term": { + "fx": "peptidaseActivity", + "arguments": [ + { + "term": { + "fx": "proteinAbundance", + "arguments": [ + { + "parameter": { + "ns": "HGNC", + "value": "F3" + } + } + ] } - ] - } + } + ] } - ] - } + } + }, + "statement_short_form": "a(CHEBI:\"phosphatidyl-L-serine\") increases pep(p(HGNC:F3))" } - }, - "statement_short_form": "a(CHEBI:\"phosphatidyl-L-serine\") increases pep(p(HGNC:F3))" - } - ``` - queryParameters: - flatten: + ``` + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "expression_components": { + "subject": "a(CHEBI:\"phosphatidyl-L-serine\")", + "relationship": "increases", + "object": "pep(p(HGNC:F3))" + }, + "statement_short_form": "a(CHEBI:\"phosphatidyl-L-serine\") increases pep(p(HGNC:F3))" + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + queryParameters: + flatten: + type: string + description: | + The boolean indicator to flatten subject and object to strings. The default is to expand down to the terms and parameters. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: flatten + /validation: + displayName: validation + description: '' + uriParameters: {} + get: + description: |- + Retrieve the validation result for the *BEL* expression fragment. The following provides expression types for *{bel}* and some validations that can return: + + - *Parameters* + - Undefined namespace `Error` + - Undefined namespace value `Warning` + - *Terms* + - Invalid function `Error` + - Term signature `Warning` + - *Statements* + - Invalid relationship `Error` + - Statement signature `Warning` + + Valid expressions: + + - `HGNC:AKT1` + - `p(HGNC:AKT1, frag(5_20)` + - `act(p(SFAM:"RAS Family"), ma(DEFAULT:gtp))` + + Invalid expressions: + - `HGNC:YFG` will return an undefined namespace value warning for `YFG`. + - `tloc(bp(HGNC:NFE2L2), fromLoc(MESHCS:Cytoplasm), toLoc(MESHCS:"Cell Nucleus"))` will return a signature mapping warning for `tloc(bp(HGNC:NFE2L2))`. + - `p(SFAM:"MAPK p38 Family") =| list(p(HGNC:MAPK8), p(HGNC:MAPK9))` will indicate a warning using a non-list relationship with the `list()` object. + headers: {} + responses: + '200': + body: + text/plain: + schema: |- + { + "type": "object", + "properties": {} + } + example: |+ + Syntax: Valid + Semantics: Valid + + Subject term - Valid signatures + activity(F:abundance, F:molecularActivity)activity + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + Info: Successful semantic validation of argument. + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + Info: Successful semantic validation of argument. + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + proteinAbundance(E:proteinAbundance)proteinAbundance + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + Info: Successful semantic validation of argument. + Info: Successful semantic validation of parameter. + Info: Successful semantic validation of prefix. + Info: Successful semantic validation of prefix. + Info: Successful semantic validation of value. + Info: Successful semantic validation of value. + molecularActivity(E:activity)molecularActivity + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + Info: Successful semantic validation of argument. + Info: Successful semantic validation of parameter. + Info: Successful semantic validation of prefix. + Info: Successful semantic validation of prefix. + Info: Successful semantic validation of value. + Info: Successful semantic validation of value. + + Subject term - Invalid signatures + activity(F:abundance)activity + Expected 1 arguments, but saw 2 arguments. + proteinAbundance(E:proteinAbundance,F:location)proteinAbundance + Expected 2 arguments, but saw 1 arguments. + proteinAbundance(E:proteinAbundance,F:fragment)proteinAbundance + Expected 2 arguments, but saw 1 arguments. + proteinAbundance(E:proteinAbundance,F:proteinModification...)proteinAbundance + Expected 2 arguments, but saw 1 arguments. + proteinAbundance(E:proteinAbundance,F:variant)proteinAbundance + Expected 2 arguments, but saw 1 arguments. + proteinAbundance(F:fusion)proteinAbundance + Info: Successful semantic validation of term. + Info: Successful semantic validation of function. + Info: Successful semantic validation of identifier. + Info: Successful semantic validation of argument. + Expected term type, but saw parameter type. + + queryParameters: {} + /nanopubs: + displayName: nanopubs + description: '' + '/{identifier}': + displayName: '{identifier}' + description: '' + uriParameters: + identifier: + description: identifier type: string - description: | - The boolean indicator to flatten subject and object to strings. The default is to expand down to the terms and parameters. - enum: [ 'true', 'yes', '1', 'on' ] - example: yes - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - body: - application/json: - example: | - { - "expression_components": { - "subject": "a(CHEBI:\"phosphatidyl-L-serine\")", - "relationship": "increases", - "object": "pep(p(HGNC:F3))" - }, - "statement_short_form": "a(CHEBI:\"phosphatidyl-L-serine\") increases pep(p(HGNC:F3))" - } -/functions: - description: Retrieve the BEL function resource collection. - options: - description: Returns allowable HTTP methods. - responses: - 200: + displayName: identifier + put: + displayName: PUT_nanopubs-identifier description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - headers: - Accept: - displayName: Accept - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) -/functions/{fx}: - description: Retrieve a BEL function resource. - options: - description: Returns allowable HTTP methods. - responses: - 200: + Replaces a BEL Nanopub resource identified by *{identifier}*. + + **JSON Schema** + - [nanopub_resource](schemas/nanopub_resource.schema.json) + - [nanopub](schemas/nanopub.schema.json) + body: + application/json: + example: |- + { + "nanopub": { + "bel_statement": "p(HGNC:MAPK1,pmod(P,T)) => kin(p(HGNC:MAPK1))", + "citation": { + "type": "PubMed", + "name": "J Biol Chem. 1997 Jul 4;272(27):16917-23.", + "id": "9202001" + }, + "summary_text": "These kinases are regulated by the reversible dual\nphosphorylation of conserved threonine and tyrosine residues.", + "experiment_context": [ + { + "name": "Species", + "value": "9606", + "uri": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno/9606", + "url": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" + }, + { + "name": "CellLine", + "value": "U-937", + "uri": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno/U-937", + "url": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" + } + ], + "references": { + "namespaces": { + "SFAM": "http://resource.belframework.org/belframework/20150611/namespace/selventa-protein-families.belns", + "SCOMP": "http://resource.belframework.org/belframework/20150611/namespace/selventa-named-complexes.belns", + "HGNC": "http://resource.belframework.org/belframework/20150611/namespace/hgnc-human-genes.belns", + "CHEBI": "http://resource.belframework.org/belframework/20150611/namespace/chebi.belns" + }, + "annotations": { + "CellLine": { + "type": "url", + "domain": "http://resource.belframework.org/belframework/20150611/annotation/cell-line.belanno" + }, + "Species": { + "type": "url", + "domain": "http://resource.belframework.org/belframework/20150611/annotation/species-taxonomy-id.belanno" + } + } + }, + "metadata": [ + { + "name": "document_header", + "value": { + "Name": "BEL Framework Example 1 Document", + "Description": "Example of modeling a full abstract taken from the BEL V1.0 Language Overview. ", + "Version": "20150611", + "Copyright": "Copyright (c) 2011-2015, Selventa. All Rights Reserved.", + "ContactInfo": "support@belframework.org", + "Authors": "Selventa", + "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License" + } + } + ] + } + } + schema: '{}' + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_nanopubs-identifier description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - headers: - Accept: - displayName: Accept - responses: - 200: + Retrieve the BEL Nanopub resource identified by *{identifier}*. + headers: {} + responses: + '200': + body: + application/json: + schema: '{}' + example: |- + { + "nanopub": { + "bel_statement": "a(\"cyclic AMP\") increases r(HGNC:AR)", + "citation": { + "type": "PubMed", + "name": "J Clin Endocrinol Metab 2003 Sep 88(9) 4043-54", + "id": "12970260", + "date": "", + "authors": [], + "comment": "" + }, + "summary_text": "Treatment with the cAMP analog dibutyryl cAMP enhanced AR promoter activity about 4- to 6-fold in a reporter gene assay and increased AR mRNA expression in LNCaP cells", + "experiment_context": [ + { + "name": "Species", + "value": "9606" + } + ], + "metadata": [ + { + "name": "document_header", + "value": { + "Name": "BEL Framework Large Corpus Document", + "Description": "Approximately 61,000 statements.", + "Version": "20150611", + "Copyright": "Copyright (c) 2011-2015, Selventa. All rights reserved.", + "Authors": "Selventa", + "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License", + "ContactInfo": "support@belframework.org" + } + } + ] + }, + "_links": { + "self": { + "type": "nanopub", + "href": "http://localhost/api/nanopubs/56015c7e8a4cca1317006aa7" + }, + "collection": { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs" + } + } + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + + An example request for this resource might be: + + - Path: `/api/nanopubs/56015c7e8a4cca1317006aa7` + + Example URL: [http://localhost/api/nanopubs/56015c7e8a4cca1317006aa7](http://localhost/api/nanopubs/56015c7e8a4cca1317006aa7) + + **JSON Schema** + - [nanopub_resource](schemas/nanopub_resource.schema.json) + - [nanopub](schemas/nanopub.schema.json) + queryParameters: {} + delete: + displayName: DELETE_nanopubs-identifier description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) -/namespaces: - options: - description: Returns allowable HTTP methods. - responses: - 200: + Deletes a BEL Nanopub resource identified by *{identifier}*. + headers: {} + responses: {} + queryParameters: {} + options: + displayName: OPTIONS_nanopubs-identifier description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /values: - description: | - Namespace Value collection for all Namespace resources within the API. - - This provides a collection of all BEL namespace values that can be listed and filtered. - options: - is: [ - ro_options: { name: "namespace_value_collection" } - ] + Returns allowable HTTP methods for this nanopub resource. + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} get: + displayName: GET_nanopubs description: | - Returns the *namespace_value_collection* across all *namespace* resources. + Retrieve the nanopub resource collection. + + All nanopub resources will be returned by default. -
- **Limitations** + The collection can be returned page by page by providing a *start* (defaults to `0`) index and *size* (defaults to no size limit) to return. + + This collection can be filtered by providing one or more *filter* options. A filter specifies the *category*, *name*, and *value* of the filter and is encoded as a JSON object. For example an nanopub metadata filter might be encoded as: - This endpoint is limited to full-text searching including a *filter* like: ```json - { - "category": "fts", - "name": "search", - "value": "factor VIII" - } + { + "category": "metadata", + "name": "status", + "value": "Approved" + } ``` -
- **Nested Namespace** - - All returned *namespace_value* in the *namespace_value_collection* will include the *namespace* it is found in. - For example if *factor VIII* is found in the *Hgnc Human Genes* namespace then the following will be included in the value: + This collection can be filtered using by a full-text search filter such as: ```json - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", - "name": "Hgnc Human Genes", - "prefix": "hgnc", - "domain": "gene and gene product" - }, + { + "category": "fts", + "name": "search", + "value": "lung liver pancreas" + } ``` -
- **Additional Property** - - A `match_text` property, included in each *namespace_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. + ```json + { + "category": "fts", + "name": "search", + "value": "\"subdural hematoma\"" + } + ``` -
- **Complete Example** + This collection can specify the *faceted* boolean option. Facets will reflect all (possibly filtered) nanopub resources irrespective of *start* and *size* paging. - **GET http://next.belframework.org/api/namespaces/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22factor%20VIII%22}&start=0&size=3** + Facts are an array of facet objects that are composed of a *filter* and *count*. For example for the nanopub metadata filter the facet object would be encoded as: ```json - { - "namespace_value_collection": [ - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "88383", - "name": "F8", - "title": "coagulation factor VIII", - "species": "10090", - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/mgi-mouse-genes", - "name": "Mgi Mouse Genes", - "prefix": "mgi", - "domain": "gene and gene product" - }, - "match_text": "...or tor ctor actor <> I II III <> FVIII <> -8 f-8 Cf-8 f8..." - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383" - }, - "collection": { - "type": "namespace", - "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/mgi-mouse-genes/88383/orthologs" - } - ] - } - }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "727845", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "10116", - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/rgd-rat-genes", - "name": "Rgd Rat Genes", - "prefix": "rgd", - "domain": "gene and gene product" - }, - "match_text": "coagulation <> <>" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845" - }, - "collection": { - "type": "namespace", - "href": "http://localhost:9000/api/namespaces/rgd-rat-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/rgd-rat-genes/727845/orthologs" - } - ] - } - }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "3546", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "9606", - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", - "name": "Hgnc Human Genes", - "prefix": "hgnc", - "domain": "gene and gene product" - }, - "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546" - }, - "collection": { - "type": "namespace", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/orthologs" - } - ] + { + "category": "metadata", + "name": "Status", + "values": [ + { + "value": "Approved", + "filter": "{\"category\":\"metadata\",\"name\":\"status\",\"value\":\"Approved\"}", + "count": 10200 } - } - ] - } + ] + }, ``` - queryParameters: - start: - type: integer - description: | - The namespace value resource to start from for paging purposes. - example: "0" - required: false - size: - type: integer - description: | - The size of the namespace value resource collection to retrieve. This will return a slice of the namespace value resource collection relative to *start*. + The *filter* property value can be used as a *filter* option. This is intended to support filtering the nanopub resource collection by selected facets. - A size of zero or less will return all values. - example: 3 - required: false - filter: - type: string - description: | - A filter to apply to the namespace value resource collection to narrow the resources retrieved. - example: | - {"category":"fts","name":"search","value":"sarcoma"} - required: false - faceted: + The *max_values_per_facet* option can be specified to limit the number of returned facet values by category, name pairs. For example, setting *max_values_per_facet* to `2` would return up to 2 distinct facets values for `{ "category": "citation", "name": "id", ... }`. + headers: + Accept: type: string description: | - The boolean indicator to provided faceted results for the namespace value resource collection. The default is to not facet. - enum: [ 'true', 'yes', '1', 'on' ] - example: no + The Accept header informs the server which media types the client accepts. + displayName: Accept responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [namespace_value_collection](schemas/namespace_value_collection.schema.json) - - [namespace_value](schemas/namespace_value_resource.schema.json) + '200': body: application/json: - example: !include examples/namespace_values_filter.example.json - 400: - description: | - [400 Bad Request](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1) - - Returned if a filter is malformed. - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - Returned if no namespace values were found for the FTS search. - - Returned if a `{"category":"fts", "name": "search", ...}` filter was not provided. - 501: - description: | - [501 Not Implemented](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2) - - Returned if the client enabled the `faceted` query parameter. This is currently not implemented. - /{namespace}: - options: - description: Returns allowable HTTP methods. - responses: - 200: + schema: '{}' + example: |- + { + "nanopub_collection": [ + { + "nanopub": { + "bel_statement": "a(CHEBI:\"1-octadec-9-enoylglycero-3-phosphate\") increases kin(p(HGNC:EGFR))", + "citation": { + "type": "PubMed", + "name": "Exp Cell Res 2003 Mar 10 284(1) 99-110", + "id": "12648469", + "date": "", + "authors": [], + "comment": "" + }, + "summary_text": "Treatment of cells with GPCR agonists such as endothelin- 1 (ET-1), thrombin, bombesin, and lysophosphatidic acid (LPA) transactivates ErbB1 (reviewed by Zwick et al. [48]). Mechanistically, the process involves rapid stimulation of metalloproteinases followed by cleavage of an ErbB1 ligand precursor, e.g., pro-HB-EGF [49], whose binding activates ErbB1 and downstream signaling pathways", + "experiment_context": [ + { + "name": "Species", + "value": "9606" + }, + { + "name": "Anatomy", + "value": "prostate gland" + }, + { + "name": "Cell", + "value": "squamous epithelial cell" + } + ], + "metadata": [ + { + "name": "document_header", + "value": { + "Name": "BEL Framework Large Corpus Document", + "Description": "Approximately 61,000 statements.", + "Version": "20150611", + "Copyright": "Copyright (c) 2011-2015, Selventa. All rights reserved.", + "Authors": "Selventa", + "Licenses": "Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License", + "ContactInfo": "support@belframework.org" + } + } + ] + }, + "_links": { + "self": { + "type": "nanopub", + "href": "http://localhost/api/nanopubs/56015a638a4cca1317005637" + }, + "collection": { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs" + } + } + } + ], + "facets": [ + { + "category": "metadata", + "name": "document_header", + "values": [ + { + "value": [ + "Authors", + "Selventa" + ], + "filter": "{\"category\":\"metadata\",\"name\":\"document_header\",\"value\":[\"Authors\",\"Selventa\"]}", + "count": 423 + } + ] + }, + { + "category": "experiment_context", + "name": "Anatomy", + "values": [ + { + "value": "prostate gland", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}", + "count": 423 + } + ] + }, + { + "category": "experiment_context", + "name": "Species", + "values": [ + { + "value": "9606", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Species\",\"value\":\"9606\"}", + "count": 263 + } + ] + }, + { + "category": "citation", + "name": "id", + "values": [ + { + "value": "12351634", + "filter": "{\"category\":\"citation\",\"name\":\"id\",\"value\":\"12351634\"}", + "count": 62 + } + ] + }, + { + "category": "experiment_context", + "name": "Cell", + "values": [ + { + "value": "fibroblast", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Cell\",\"value\":\"fibroblast\"}", + "count": 20 + } + ] + }, + { + "category": "experiment_context", + "name": "Cellline", + "values": [ + { + "value": "LNCAP cell", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Cellline\",\"value\":\"LNCAP cell\"}", + "count": 17 + } + ] + }, + { + "category": "experiment_context", + "name": "Disease", + "values": [ + { + "value": "prostate carcinoma in situ", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Disease\",\"value\":\"prostate carcinoma in situ\"}", + "count": 13 + } + ] + }, + { + "category": "experiment_context", + "name": "Cellstructure", + "values": [ + { + "value": "Cytoplasm", + "filter": "{\"category\":\"experiment_context\",\"name\":\"Cellstructure\",\"value\":\"Cytoplasm\"}", + "count": 4 + } + ] + } + ], + "metadata": { + "collection_paging": { + "total": 52399, + "total_filtered": 423, + "total_pages": 423, + "current_page": 1, + "current_page_size": 1 + } + }, + "_links": { + "self": { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs?start=0&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" + }, + "start": { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs?start=0&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" + }, + "next": { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs?start=1&size=1&filter={\"category\":\"experiment_context\",\"name\":\"Anatomy\",\"value\":\"prostate gland\"}" + } + } + } description: | [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /values: - description: | - Namespace Value collection within a Namespace resource identified by *{namespace}*. - options: - is: [ - ro_options: { name: "namespace_value_collection" } - ] - get: - description: | - Returns the *namespace_value_collection* across the *namespace* resource identified by *{namespace}* URI parameter. -
- **Limitations** + An example request for this resource might be: - This endpoint is limited to full-text searching including a *filter* like: - ```json - { - "category": "fts", - "name": "search", - "value": "factor VIII" - } - ``` + - Path: `/api/nanopubs` + - Query parameters: + - `start=0` + - `size=1` + - `faceted=yes` + - `max_values_per_facet=1` + - `filter` + ```json + { + "category":"experiment_context", + "name":"Anatomy", + "value":"prostate gland" + } + ``` -
- **Nested Namespace** + Example URL: [http://localhost/api/nanopubs?start=0&size=1&faceted=yes&max_values_per_facet=1&filter={"category":"experiment_context","name":"Anatomy","value":"prostate gland"}](http://localhost/api/nanopubs?start=0&size=1&faceted=yes&max_values_per_facet=1&filter={%22category%22:%22experiment_context%22,%22name%22:%22Anatomy%22,%22value%22:%22prostate gland%22}) - All returned *namespace_value* in the *namespace_value_collection* will include the *namespace* it is found in. - For example if *factor VIII* is found in the *Hgnc Human Genes* namespace then the following will be included in the value: + **JSON Schema** + - [nanopub_collection](schemas/nanopub_collection.schema.json) + - [nanopub_resource](schemas/nanopub_resource.schema.json) + - [nanopub](schemas/nanopub.schema.json) + queryParameters: + start: + type: integer + description: | + The nanopub resource to start from for paging purposes. - ```json - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", - "name": "Hgnc Human Genes", - "prefix": "hgnc", - "domain": "gene and gene product" - }, - ``` + The default value is `0`. This value will return nanopub resources starting from the beginning of collection. + displayName: start + size: + type: integer + description: | + The size of the nanopub resource collection to retrieve. This will return a slice of the nanopub resource collection relative to *start*. -
- **Additional Property** + The default is `0`. This value will return all nanopub resources in the collection. + displayName: size + filter: + type: string + description: | + A filter to apply to the nanopub resource collection to narrow the resources retrieved. - A `match_text` property, included in each *namespace_value*, provides the snippet of text that matched the search. The matched term will be prefixed with `<<` and suffixed with `>>`. + The default is to not apply filters. If filters are not specified then all nanopub resources, in the collection, will be returned. -
- **Complete Example** + **Example Usage:** - **GET http://next.belframework.org/api/namespaces/hgnc/values?filter={%22category%22:%22fts%22,%22name%22:%22search%22,%22value%22:%22factor%20VIII%22}&start=0&size=2** + Find nanopubs matching either `prostate` or `gland`. + ``` + {"category":"experiment_context","name":"Anatomy","value":"prostate gland"} + ``` - ```json - { - "namespace_value_collection": [ + Find nanopubs matching the phrase `subdural hematoma` or `carcinoma`. + ``` + {"category":"fts","name":"search","value":"\"subdural hematoma\" carcinoma"} + ``` + + Find nanopubs matching `homatoma` but not `carcinoma`. + ``` + {"category":"fts","name":"search","value":"homatoma -carcinoma"} + ``` + displayName: filter + faceted: + type: string + description: | + The boolean indicator to provided faceted results for the nanopub resource collection. + + The default is `false`. This value will not return facets in the response. + enum: + - 'true' + - 'yes' + - '1' + - 'on' + displayName: faceted + max_values_per_facet: + type: integer + description: | + e| The maximum about of facet values to display for every category, name pair. + The default is `0`. This value will return all facet values (i.e. unbounded) for every category, name pair. + displayName: max_values_per_facet + options: + displayName: OPTIONS_nanopubs + description: | + Returns allowable HTTP methods for this nanopub collection. + headers: {} + responses: {} + queryParameters: {} + post: + displayName: POST_nanopubs + description: | + Creates one or more BEL Nanopubs within the API. + + The following formats are supported: + - BEL Nanopub JSON + - media type: `application/json` + - JSON schema: [nanopub.schema.json](http://localhost/schemas/nanopub.schema.json) + - BEL Script + - defined by [BEL Script V1.0 Format](http://wiki.openbel.org/display/BLDV20/BEL+Script+V1.0+Format) + - media type: `application/bel` + - XBEL (XML) + - media type: `application/xml` + - XML Schema: [xbel](http://resource.belframework.org/belframework/20150611/schema/xbel.xsd), [xbel-annotations](http://resource.belframework.org/belframework/20150611/schema/xbel-annotations.xsd) + - [BEL JSON Graph Format](http://jsongraphformat.info/) + - media type: `application/vnd.jgf+json` + - JSON schema: [bel-json-graph-2.0.schema.json](http://jsongraphformat.info/child-schemas/bel-json-graph-2.0.schema.json) + - BEL RDF + - defined within [bel.rb](https://github.com/OpenBEL/bel.rb) as a [format extension](https://github.com/OpenBEL/bel.rb/wiki/Format-Extensions). See [source](https://github.com/OpenBEL/bel.rb/tree/c1471942ce8326ad2399d66154c858d6a9fbcd6b/lib/bel/extensions/rdf) + - media type + - `application/n-quads` + - `application/n-triples` + - `application/rdf+xml` + - `application/turtle` + - `application/x-turtle` + - `text/turtle` + +
+ If you send a single BEL Nanopub JSON object then the resource's *Location* will be returned. However if you send multiple BEL Nanopubs using any of the supported formats above then a *Location* will not be returned. This will be addressed in a future version. + body: {} + headers: {} + responses: {} + queryParameters: {} + uriParameters: {} + options: + displayName: OPTIONS_api + description: | + Returns allowable HTTP methods for this root resource. + headers: {} + responses: {} + queryParameters: {} + get: + displayName: GET_api + description: | + Returns a list of linked *item* resources. + headers: {} + responses: + '200': + body: + application/hal+json: + schema: '{}' + example: |- { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "3546", - "name": "F8", - "title": "coagulation factor VIII, procoagulant component", - "species": "9606", - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", - "name": "Hgnc Human Genes", - "prefix": "hgnc", - "domain": "gene and gene product" - }, - "match_text": "coagulation <> VIII, procoagulant component...C 8C F8C I II III <> FVIII" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546" - }, - "collection": { - "type": "namespace", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" + "_links": { + "item": [ + { + "type": "annotation_collection", + "href": "http://localhost/api/annotations" + }, + { + "type": "nanopub_collection", + "href": "http://localhost/api/nanopubs" + }, + { + "type": "expression_collection", + "href": "http://localhost/api/expressions" + }, + { + "type": "language_collection", + "href": "http://localhost/api/language" + }, + { + "type": "namespace_collection", + "href": "http://localhost/api/namespaces" + } + ] + } + } + description: | + [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) + queryParameters: {} +schemas: + - nanopub_resource: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "title": "BEL Nanopub Resource", + "description": "A single nanopub resource.", + "type": "object", + "additionalProperties": false, + "required": [ + "nanopub" + ], + "properties": { + "allOf": [ + { + "$ref": "nanopub.schema.json" }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/3546/orthologs" - } - ] - } + { + "type": "object", + "additionalProperties": false, + "required": [ + "links" + ], + "properties": { + "links": { + "type": "object" + } + } + } + ] + } + } + - annotation_collection: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "description": "DESCRIBE ANNOTATION COLLECTION", + "type": "object", + "additionalProperties": false, + "required": [ + "annotation_collection" + ], + "properties": { + "annotation_collection": { + "type": "array", + "minItems": 0, + "title": "", + "description": "", + "items": { + "$ref": "http://localhost/schemas/annotation_resource.schema.json" + } + } + } + } + - annotation_value_collection: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "title": "Annotation Value Collection", + "description": "A collection of annotation value resources.", + "type": "object", + "additionalProperties": false, + "required": [ + "annotation_value_collection" + ], + "properties": { + "annotation_value_collection": { + "type": "array", + "minItems": 0, + "title": "", + "description": "", + "items": { + "$ref": "http://localhost/schemas/annotation_value_resource.schema.json" + } + } + } + } + - annotation_value_resource: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "title": "Annotation Value Resource", + "description": "A single annotation value within a BEL Annotation.", + "type": "object", + "additionalProperties": false, + "required": [ + "annotation_value" + ], + "properties": { + "annotation_value": { + "type": "object", + "additionalProperties": false, + "required": [ + "type", + "identifier", + "name" + ], + "properties": { + "type": { + "type": "string" + }, + "identifier": { + "type": "string" + }, + "name": { + "type": "string" + }, + "match_text": { + "type": "string" + } + } + } + } + } + - nanopub: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "description": "DESCRIBE NANOPUB", + "type": "object", + "additionalProperties": false, + "required": [ + "nanopub" + ], + "properties": { + "nanopub": { + "type": "object", + "additionalProperties": false, + "required": [ + "bel_statement", + "citation" + ], + "properties": { + "bel_statement": { + "type": "string", + "title": "BEL Statement", + "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." + }, + "citation": { + "type": "object", + "title": "Citation", + "description": "The citation specifies the written source where the biological knowledge was referenced.", + "required": [ + "type", + "id" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "PubMed", + "Book", + "Journal", + "Online Resource", + "Other" + ], + "title": "Citation Type", + "description": "The citation type of the reference." + }, + "id": { + "type": [ + "string", + "number" + ], + "title": "Citation ID", + "description": "The citation identifier (PubMed ID, ISBN, DOI, URL) of the reference." + }, + "name": { + "type": "string", + "title": "Citation Name", + "description": "The citation name of the reference." + }, + "date": { + "type": "string", + "title": "Citation Date", + "description": "The citation date of the reference." + }, + "authors": { + "type": "array", + "title": "Citation Authors", + "description": "The citation authors of the reference.", + "items": { + "type": "string", + "minItems": 0 + } + }, + "comment": { + "type": "string", + "title": "Citation Comment", + "description": "The citation comment of the reference." + } + } + }, + "experiment_context": { + "type": [ + "array", + "null" + ], + "title": "Experiment Context", + "description": "An experiment context specifies the experiment's parameters where this interaction was observed.", + "items": { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "title": "Annotation Type", + "description": "Annotation type listing - sourced from the BEL Annotation resource names" + }, + "value": { + "type": [ + "string", + "number", + "boolean", + "array" + ], + "title": "Annotations", + "description": "Annotations such as Homo sapiens, cancer, epithelial tissue sourced from the BEL Annotation resources", + "items": { + "type": [ + "string", + "number", + "boolean" + ] + } + }, + "uri": { + "type": "string", + "title": "Annotation URI", + "description": "URI for Annotation", + "format": "uri", + "items": { + "type": "string", + "format": "uri" + } + } + } + } + }, + "support": { + "type": [ + "string", + "null" + ], + "title": "Summary Text", + "description": "Abstract from source text to provide support for this nanopub" + }, + "references": { + "type": [ + "object", + "null" + ], + "title": "References", + "description": "The references section identifies annotation and namespace URIs.", + "properties": { + "annotations": { + "type": [ + "array", + "null" + ], + "title": "Annotation references", + "description": "References to annotation resources.", + "item": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "title": "Keyword", + "description": "Keyword that identifies this annotation resource, but only in the context of this BEL Nanopub." + }, + "uri": { + "type": "string", + "format": "uri", + "title": "URI", + "description": "URI that identifies this annotation resource." + } + }, + "required": [ + "keyword", + "uri" + ] + } + }, + "namespaces": { + "type": [ + "array", + "null" + ], + "title": "Namespace references", + "description": "References to namespace resources.", + "item": { + "type": "object", + "properties": { + "keyword": { + "type": "string", + "title": "Keyword", + "description": "Keyword that identifies this namespace resource, but only in the context of this BEL Nanopub." + }, + "uri": { + "type": "string", + "format": "uri", + "title": "URI", + "description": "URI that identifies this namespace resource." + } + }, + "required": [ + "keyword", + "uri" + ] + } + } + } + }, + "metadata": { + "type": [ + "array", + "null" + ], + "title": "BEL Nanopub resource metadata", + "description": "Metadata that describes the nanopub resource.", + "items": { + "oneOf": [ + { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "title": "Name", + "description": "The name of this metadata property." + }, + "value": { + "type": [ + "array", + "boolean", + "number", + "object", + "string" + ], + "title": "Value", + "description": "The value of this metadata property.", + "items": { + "type": [ + "array", + "boolean", + "integer", + "number", + "null", + "object", + "string" + ] + } + } + } + }, + { + "type": "object", + "required": [ + "uri" + ], + "title": "Annotation URI(s)", + "description": "URI(s) for Annotations", + "properties": { + "uri": { + "type": [ + "string", + "array" + ], + "format": "uri", + "items": { + "type": "string", + "format": "uri" + } + } + } + } + ] + } + } + } + } + } + } + - annotation_resource: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "title": "Annotation", + "description": "A vocabulary of terms for describing nanopub resources.", + "type": "object", + "additionalProperties": false, + "required": [ + "annotation" + ], + "properties": { + "annotation": { + "type": "object", + "additionalProperties": false, + "required": [ + "rdf_uri", + "name", + "prefix", + "domain" + ], + "properties": { + "rdf_uri": { + "type": "string" + }, + "name": { + "type": "string" + }, + "prefix": { + "type": "string" + }, + "domain": { + "type": "string" + } + } + } + } + } + - nanopub_collection: |- + { + "$schema": "http://json-schema.org/draft-04/schema", + "description": "DESCRIBE NANOPUB COLLECTION", + "type": "object", + "additionalProperties": false, + "required": [ + "nanopub_collection", + "facets" + ], + "properties": { + "nanopub_collection": { + "type": "array", + "minItems": 0, + "title": "", + "description": "", + "items": { + "$ref": "nanopub_resource.schema.json" + } }, - { - "namespace_value": { - "type": "ProteinConcept", - "identifier": "6631", - "name": "LMAN1", - "title": "lectin, mannose-binding, 1", - "species": "9606", - "namespace": { - "rdf_uri": "http://www.openbel.org/bel/namespace/hgnc-human-genes", - "name": "Hgnc Human Genes", - "prefix": "hgnc", - "domain": "gene and gene product" - }, - "match_text": "F5F8D ERGIC53 MCFD1 MR60 gp58 ERGIC-53 FMFD1 coagulation <> V-factor <> combined deficiency" - }, - "_links": { - "self": { - "type": "namespace_value", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631" - }, - "collection": { - "type": "namespace", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes" - }, - "item": [ - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631/equivalents" - }, - { - "type": "namespace_value_collection", - "href": "http://localhost:9000/api/namespaces/hgnc-human-genes/6631/orthologs" - } - ] - } + "facets": { + "type": "array", + "minItems": 0, + "title": "", + "description": "", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "category", + "name", + "value", + "filter", + "count" + ], + "properties": { + "category": { + "type": "string" + }, + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "filter": { + "type": "string" + }, + "count": { + "type": "integer" + } + } + } + }, + "metadata": { + "title": "Metadata", + "description": "Data about the nanopub collection", + "type": "object", + "additionalProperties": true, + "properties": { + "collection_paging": { + "type": "object", + "properties": { + "total": { + "title": "Total", + "description": "The total number of resources in this collection.", + "type": "number", + "minimum": 0 + }, + "total_filtered": { + "title": "Total Filtered", + "description": "The total number of resources in the filtered collection.", + "type": "number", + "minimum": 0 + }, + "total_pages": { + "title": "Total Pages", + "description": "The total number of pages (i.e. sized partitions) in the filtered collection.", + "type": "number", + "minimum": 0 + }, + "current_page": { + "title": "Current Page", + "description": "The current page of the filtered collection that this resource represents.", + "type": "number", + "minimum": 0 + }, + "current_page_size": { + "title": "Current Page Size", + "description": "The number of resources in the current page of the filtered collection.", + "type": "number", + "minimum": 0 + } + } + } + } } - ] } - ``` - queryParameters: - start: - type: integer - description: | - The namespace value resource to start from for paging purposes. - example: "0" - required: false - size: - type: integer - description: | - The size of the namespace value resource collection to retrieve. This will return a slice of the namespace value resource collection relative to *start*. - - A size of zero or less will return all values. - example: 2 - required: false - filter: - type: string - description: | - A filter to apply to the namespace value resource collection to narrow the resources retrieved. - example: | - {"category":"fts","name":"search","value":"factor VIII"} - required: false - faceted: - type: string - description: | - The boolean indicator to provided faceted results for the namespace value resource collection. The default is to not facet. - enum: [ 'true', 'yes', '1', 'on' ] - example: no - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - - **JSON Schema** - - [namespace_value_collection](schemas/namespace_value_collection.schema.json) - - [namespace_value](schemas/namespace_value_resource.schema.json) - body: - application/json: - example: !include examples/namespace_value_collection.example.json - 400: - description: | - [400 Bad Request](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1) - - Returned if a filter is malformed. - 404: - description: | - [404 Not Found](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5) - - Returned if no namespace values were found for the FTS search. - - Returned if a `{"category":"fts", "name": "search", ...}` filter was not provided. - 501: - description: | - [501 Not Implemented](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2) - - Returned if the client enabled the `faceted` query parameter. This is currently not implemented. - /{value}: - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /equivalents: - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /{target}: - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /orthologs: - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - /{target}: - options: - description: Returns allowable HTTP methods. - responses: - 200: - description: | - [200 OK](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1) - headers: - Accept: - description: Allowable HTTP methods. - type: string - get: - # vim: ft=yaml sw=2 ts=2 sts=2 expandtab: + } +traits: [] diff --git a/docs/schemas/annotation_collection.schema.json b/docs/schemas/annotation_collection.schema.json deleted file mode 100644 index b5dacab..0000000 --- a/docs/schemas/annotation_collection.schema.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "description": "DESCRIBE ANNOTATION COLLECTION", - "type": "object", - "additionalProperties": false, - "required": [ - "annotation_collection" - ], - "properties": { - "annotation_collection": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "$ref":"http://next.belframework.org/schemas/annotation_resource.schema.json" - } - } - } -} diff --git a/docs/schemas/annotation_resource.schema.json b/docs/schemas/annotation_resource.schema.json deleted file mode 100644 index 25d5e58..0000000 --- a/docs/schemas/annotation_resource.schema.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Annotation", - "description": "A vocabulary of terms for describing evidence resources.", - "type": "object", - "additionalProperties": false, - "required": [ - "annotation" - ], - "properties": { - "annotation": { - "type": "object", - "additionalProperties": false, - "required": [ - "rdf_uri", - "name", - "prefix", - "domain" - ], - "properties": { - "rdf_uri": { - "type": "string" - }, - "name": { - "type": "string" - }, - "prefix": { - "type": "string" - }, - "domain": { - "type": "string" - } - } - } - } -} diff --git a/docs/schemas/annotation_value_collection.schema.json b/docs/schemas/annotation_value_collection.schema.json deleted file mode 100644 index ebd21ca..0000000 --- a/docs/schemas/annotation_value_collection.schema.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Annotation Value Collection", - "description": "A collection of annotation value resources.", - "type": "object", - "additionalProperties": false, - "required": [ - "annotation_value_collection" - ], - "properties": { - "annotation_value_collection": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "$ref":"http://next.belframework.org/schemas/annotation_value_resource.schema.json" - } - } - } -} diff --git a/docs/schemas/annotation_value_resource.schema.json b/docs/schemas/annotation_value_resource.schema.json deleted file mode 100644 index 2c7e3ec..0000000 --- a/docs/schemas/annotation_value_resource.schema.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Annotation Value Resource", - "description": "A single annotation value within a BEL Annotation.", - "type": "object", - "additionalProperties": false, - "required": [ - "annotation_value" - ], - "properties": { - "annotation_value": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "identifier", - "name" - ], - "properties": { - "type": { - "type": "string" - }, - "identifier": { - "type": "string" - }, - "name": { - "type": "string" - }, - "match_text": { - "type": "string" - } - } - } - } -} diff --git a/docs/schemas/completion_collection.schema.json b/docs/schemas/completion_collection.schema.json deleted file mode 100644 index a8bb388..0000000 --- a/docs/schemas/completion_collection.schema.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Completion Collection", - "description": "A collection of BEL expression completions.", - "type": "object", - "additionalProperties": false, - "required": [ - "completion_collection" - ], - "properties": { - "completion_collection": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "$ref":"http://next.belframework.org/schemas/completion_resource.schema.json#/properties/completion" - } - } - } -} diff --git a/docs/schemas/completion_resource.schema.json b/docs/schemas/completion_resource.schema.json deleted file mode 100644 index e7f49f4..0000000 --- a/docs/schemas/completion_resource.schema.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Completion Resource", - "description": "A completion of a BEL expression.", - "type": "object", - "additionalProperties": false, - "required": [ - "completion" - ], - "properties": { - "completion": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "label", - "value", - "highlight", - "actions" - ], - "properties": { - "type": { - "enum": [ - "function", - "namespace_prefix", - "namespace_value" - ] - }, - "label": { - "type": "string" - }, - "value": { - "type": "string" - }, - "highlight": { - "oneOf": [ - { - "type": "null" - }, - { - "type": "object", - "required": [ - "start_position", - "end_position", - "range_type" - ], - "properties": { - "start_position": { - "type": "integer" - }, - "end_position": { - "type": "integer" - }, - "range_type": { - "enum": [ - "exclusive", - "inclusive" - ] - } - } - } - ] - }, - "actions": { - "type": "array", - "items": { - "oneOf": [ - { - "type": "object", - "required": [ - "delete" - ], - "properties": { - "delete": { - "type": "object", - "required": [ - "start_position", - "end_position", - "range_type" - ], - "properties": { - "start_position": { - "type": "integer" - }, - "end_position": { - "type": "integer" - }, - "range_type": { - "enum": [ - "exclusive", - "inclusive" - ] - } - } - } - } - }, - { - "type": "object", - "required": [ - "insert" - ], - "properties": { - "insert": { - "type": "object", - "required": [ - "position", - "value" - ], - "properties": { - "position": { - "type": "integer" - }, - "value": { - "type": "string" - } - } - } - } - }, - { - "type": "object", - "required": [ - "move_cursor" - ], - "properties": { - "move_cursor": { - "type": "object", - "required": [ - "position" - ], - "properties": { - "position": { - "type": "integer" - } - } - } - } - } - ] - } - } - } - } - } -} diff --git a/docs/schemas/evidence.schema.json b/docs/schemas/evidence.schema.json deleted file mode 100644 index 3e091ba..0000000 --- a/docs/schemas/evidence.schema.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "description": "DESCRIBE EVIDENCE", - "type": "object", - "additionalProperties": false, - "required": ["evidence"], - "properties": { - "evidence": { - "type": "object", - "additionalProperties": false, - "required": ["bel_statement", "citation"], - "properties": { - "bel_statement": { - "type": "string", - "title": "BEL Statement", - "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." - }, - "citation": { - "type": "object", - "title": "Citation", - "description": "The citation specifies the written source where the biological knowledge was referenced.", - "required": ["type", "id"], - "properties": { - "type": { - "type": "string", - "enum": ["PubMed", "Book", "Journal", "Online Resource", "Other"], - "title": "Citation Type", - "description": "The citation type of the reference." - }, - "id": { - "type": ["string", "number"], - "title": "Citation ID", - "description": "The citation identifier (PubMed ID, ISBN, DOI, URL) of the reference." - }, - "name": { - "type": "string", - "title": "Citation Name", - "description": "The citation name of the reference." - }, - "date": { - "type": "string", - "title": "Citation Date", - "description": "The citation date of the reference." - }, - "authors": { - "type": "array", - "title": "Citation Authors", - "description": "The citation authors of the reference.", - "items": { - "type": "string", - "minItems": 0 - } - }, - "comment": { - "type": "string", - "title": "Citation Comment", - "description": "The citation comment of the reference." - } - } - }, - "experiment_context": { - "type": ["array", "null"], - "title": "Experiment Context", - "description": "An experiment context specifies the experiment's parameters where this interaction was observed.", - "items": { - "type": "object", - "required": ["name", "value"], - "properties": { - "name": { - "type": "string", - "title": "Annotation Type", - "description": "Annotation type listing - sourced from the BEL Annotation resource names" - }, - "value": { - "type": ["string", "number", "boolean", "array"], - "title": "Annotations", - "description": "Annotations such as Homo sapiens, cancer, epithelial tissue sourced from the BEL Annotation resources", - "items": { - "type": ["string", "number", "boolean"] - } - }, - "uri": { - "type": "string", - "title": "Annotation URI", - "description": "URI for Annotation", - "format": "uri", - "items": { - "type": "string", - "format": "uri" - } - } - } - } - }, - "summary_text": { - "type": ["string", "null"], - "title": "Summary Text", - "description": "Abstract from source text to provide support for this evidence" - }, - "references": { - "type": ["object", "null"], - "title": "References", - "description": "The references section identifies annotation and namespace URIs.", - "properties": { - "annotations": { - "type": ["array", "null"], - "title": "Annotation references", - "description": "References to annotation resources.", - "item": { - "type": "object", - "properties": { - "keyword": { - "type": "string", - "title": "Keyword", - "description": "Keyword that identifies this annotation resource, but only in the context of this Evidence." - }, - "uri": { - "type": "string", - "format": "uri", - "title": "URI", - "description": "URI that identifies this annotation resource." - } - }, - "required": ["keyword", "uri"] - } - }, - "namespaces": { - "type": ["array", "null"], - "title": "Namespace references", - "description": "References to namespace resources.", - "item": { - "type": "object", - "properties": { - "keyword": { - "type": "string", - "title": "Keyword", - "description": "Keyword that identifies this namespace resource, but only in the context of this Evidence." - }, - "uri": { - "type": "string", - "format": "uri", - "title": "URI", - "description": "URI that identifies this namespace resource." - } - }, - "required": ["keyword", "uri"] - } - } - } - }, - "metadata": { - "type": ["array", "null"], - "title": "Evidence resource metadata", - "description": "Metadata that describes the evidence resource.", - "items": { - "oneOf": [ - { - "type": "object", - "required": ["name", "value"], - "properties": { - "name": { - "type": "string", - "title": "Name", - "description": "The name of this metadata property." - }, - "value": { - "type": ["array", "boolean", "number", "object", "string"], - "title": "Value", - "description": "The value of this metadata property.", - "items": { - "type": ["array", "boolean", "integer", "number", "null", "object", "string"] - } - } - } - }, - { - "type": "object", - "required": ["uri"], - "title": "Annotation URI(s)", - "description": "URI(s) for Annotations", - "properties": { - "uri": { - "type": ["string", "array"], - "format": "uri", - "items": { - "type": "string", - "format": "uri" - } - } - } - } - ] - } - } - } - } - } -} diff --git a/docs/schemas/namespace_value_collection.schema.json b/docs/schemas/namespace_value_collection.schema.json deleted file mode 100644 index af669ee..0000000 --- a/docs/schemas/namespace_value_collection.schema.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Namespace Value Collection", - "description": "A collection of namespace value resources.", - "type": "object", - "additionalProperties": false, - "required": [ - "namespace_value_collection" - ], - "properties": { - "namespace_value_collection": { - "type": "array", - "minItems": 0, - "title": "", - "description": "", - "items": { - "$ref":"http://next.belframework.org/schemas/namespace_value_resource.schema.json" - } - } - } -} diff --git a/docs/schemas/namespace_value_resource.schema.json b/docs/schemas/namespace_value_resource.schema.json deleted file mode 100644 index 89b45cf..0000000 --- a/docs/schemas/namespace_value_resource.schema.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema", - "title": "Namespace Value Resource", - "description": "A single namespace value within a BEL Namespace.", - "type": "object", - "additionalProperties": false, - "required": [ - "namespace_value" - ], - "properties": { - "namespace_value": { - "type": "object", - "additionalProperties": false, - "required": [ - "type", - "identifier", - "name", - "title", - "species" - ], - "properties": { - "type": { - "type": "string" - }, - "identifier": { - "type": "string" - }, - "name": { - "type": "string" - }, - "title": { - "type": ["null", "string"] - }, - "species": { - "type": ["null", "string"] - }, - "match_text": { - "type": "string" - } - } - } - } -} diff --git a/lib/openbel/api/helpers/uuid_generator.rb b/lib/openbel/api/helpers/uuid_generator.rb new file mode 100644 index 0000000..7f215e2 --- /dev/null +++ b/lib/openbel/api/helpers/uuid_generator.rb @@ -0,0 +1,22 @@ +module OpenBEL + module Helpers + # Mixin to provide generation of String UUIDs. + # + # The {#generate_uuid} instance method is available with a + # platform-specific implementation. + module UUIDGenerator + # Define UUID implementation based on Ruby. + if RUBY_ENGINE =~ /^jruby/i + java_import 'java.util.UUID' + define_method(:generate_uuid) do + Java::JavaUtil::UUID.random_uuid.to_s + end + else + require 'uuid' + define_method(:generate_uuid) do + UUID.generate + end + end + end + end +end diff --git a/lib/openbel/api/evidence/api.rb b/lib/openbel/api/nanopub/api.rb similarity index 70% rename from lib/openbel/api/evidence/api.rb rename to lib/openbel/api/nanopub/api.rb index 9cfb80b..96f09df 100644 --- a/lib/openbel/api/evidence/api.rb +++ b/lib/openbel/api/nanopub/api.rb @@ -1,17 +1,17 @@ module OpenBEL - module Evidence + module Nanopub module API # single or array - def create_evidence(evidence) + def create_nanopub(nanopub) fail NotImplementedError, "#{__method__} is not implemented" end - def find_evidence_by_id(id) + def find_nanopub_by_id(id) fail NotImplementedError, "#{__method__} is not implemented" end - def find_evidence(filters = [], offset = 0, length = 0, facet = false) + def find_nanopub(filters = [], offset = 0, length = 0, facet = false) fail NotImplementedError, "#{__method__} is not implemented" end @@ -23,23 +23,23 @@ def find_all_annotation_references fail NotImplementedError, "#{__method__} is not implemented" end - def count_evidence(filters = []) + def count_nanopub(filters = []) fail NotImplementedError, "#{__method__} is not implemented" end - def update_evidence_by_id(id, evidence_update) + def update_nanopub_by_id(id, nanopub_update) fail NotImplementedError, "#{__method__} is not implemented" end - def update_evidence_by_query(query, evidence_update) + def update_nanopub_by_query(query, nanopub_update) fail NotImplementedError, "#{__method__} is not implemented" end - def delete_evidence_by_id(id) + def delete_nanopub_by_id(id) fail NotImplementedError, "#{__method__} is not implemented" end - def delete_evidence_by_query(query) + def delete_nanopub_by_query(query) fail NotImplementedError, "#{__method__} is not implemented" end end diff --git a/lib/openbel/api/evidence/facet_api.rb b/lib/openbel/api/nanopub/facet_api.rb similarity index 88% rename from lib/openbel/api/evidence/facet_api.rb rename to lib/openbel/api/nanopub/facet_api.rb index be504b1..ca9178a 100644 --- a/lib/openbel/api/evidence/facet_api.rb +++ b/lib/openbel/api/nanopub/facet_api.rb @@ -1,8 +1,8 @@ module OpenBEL - module Evidence + module Nanopub module FacetAPI - def create_facets(evidence) + def create_facets(nanopub) fail NotImplementedError, "#{__method__} is not implemented" end diff --git a/lib/openbel/api/evidence/facet_filter.rb b/lib/openbel/api/nanopub/facet_filter.rb similarity index 86% rename from lib/openbel/api/evidence/facet_filter.rb rename to lib/openbel/api/nanopub/facet_filter.rb index fd9c461..7975215 100644 --- a/lib/openbel/api/evidence/facet_filter.rb +++ b/lib/openbel/api/nanopub/facet_filter.rb @@ -1,16 +1,16 @@ require 'multi_json' module OpenBEL - module Evidence + module Nanopub module FacetFilter EMPTY = [] - EVIDENCE_PARTS = [:citation, :experiment_context, :metadata] + NANOPUB_PARTS = [:citation, :experiment_context, :metadata] - def map_evidence_facets(evidence) - EVIDENCE_PARTS.reduce([]) { |facets, evidence_part| - part = evidence.send(evidence_part) - new_facets = self.send(:"map_#{evidence_part}_facets", part) + def map_nanopub_facets(nanopub) + NANOPUB_PARTS.reduce([]) { |facets, nanopub_part| + part = nanopub.send(nanopub_part) + new_facets = self.send(:"map_#{nanopub_part}_facets", part) facets.concat(new_facets) } end diff --git a/lib/openbel/api/evidence/mongo.rb b/lib/openbel/api/nanopub/mongo.rb similarity index 79% rename from lib/openbel/api/evidence/mongo.rb rename to lib/openbel/api/nanopub/mongo.rb index 85a5cf9..df8c8cb 100644 --- a/lib/openbel/api/evidence/mongo.rb +++ b/lib/openbel/api/nanopub/mongo.rb @@ -1,13 +1,14 @@ require 'bel' -require 'bel/evidence_model/util' +require 'bel_parser/expression/model' +require 'bel/nanopub/util' require 'mongo' require_relative 'api' require_relative 'mongo_facet' module OpenBEL - module Evidence + module Nanopub - class Evidence + class Nanopub include API include Mongo @@ -30,42 +31,42 @@ def initialize(options = {}) @db.authenticate(username, password, nil, auth_db) end - @collection = @db[:evidence] - @evidence_facets = EvidenceFacets.new(options) + @collection = @db[:nanopub] + @nanopub_facets = NanopubFacets.new(options) # ensure all indexes are created and maintained ensure_all_indexes end - def create_evidence(evidence) - # insert evidence; acknowledge journal - if evidence.respond_to?(:each_pair) - _id = @collection.insert(evidence, :w => 1, :j => true) + def create_nanopub(nanopub) + # insert nanopub; acknowledge journal + if nanopub.respond_to?(:each_pair) + _id = @collection.insert(nanopub, :w => 1, :j => true) - # remove evidence_facets after insert to facets - remove_evidence_facets(_id) + # remove nanopub_facets after insert to facets + remove_nanopub_facets(_id) _id - elsif evidence.respond_to?(:each) - @collection.insert(evidence.to_a, :w => 1, :j => true) + elsif nanopub.respond_to?(:each) + @collection.insert(nanopub.to_a, :w => 1, :j => true) else - raise "Evidence type #{evidence.class} cannot be inserted into Mongo." + raise "nanopub type #{nanopub.class} cannot be inserted into Mongo." end end - def find_evidence_by_id(value) + def find_nanopub_by_id(value) @collection.find_one(to_id(value)) end - def find_evidence(filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) + def find_nanopub(filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) if includes_fts_search?(filters) text_search = get_fts_search(filters) - evidence_aggregate(text_search, filters, offset, length, facet, facet_value_limit) + nanopub_aggregate(text_search, filters, offset, length, facet, facet_value_limit) else - evidence_query(filters, offset, length, facet, facet_value_limit) + nanopub_query(filters, offset, length, facet, facet_value_limit) end end - def find_dataset_evidence(dataset, filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) + def find_dataset_nanopub(dataset, filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) query_hash = to_query(filters) query_hash[:$and] ||= [] query_hash[:$and].unshift({ @@ -85,7 +86,7 @@ def find_dataset_evidence(dataset, filters = [], offset = 0, length = 0, facet = :cursor => @collection.find(query_hash, query_opts) } if facet - facets_cursor = @evidence_facets.find_facets(query_hash, filters, facet_value_limit) + facets_cursor = @nanopub_facets.find_facets(query_hash, filters, facet_value_limit) results[:facets] = facets_cursor.to_a end @@ -103,7 +104,7 @@ def find_all_namespace_references { :$unwind => "$references.namespaces" }, - { + { :$project => { keyword: "$references.namespaces.keyword", uri: "$references.namespaces.uri" @@ -137,7 +138,7 @@ def find_all_namespace_references obj = obj.to_h obj[:keyword] = obj.delete("keyword") obj[:uri] = obj.delete("uri") - union, new_remap = BEL::Model.union_namespace_references(union, [obj], 'incr') + union, new_remap = BEL::Nanopub.union_namespace_references(union, [obj], 'incr') remap.merge!(new_remap) end @@ -153,7 +154,7 @@ def find_all_annotation_references { :$unwind => "$references.annotations" }, - { + { :$project => { keyword: "$references.annotations.keyword", type: "$references.annotations.type", @@ -192,38 +193,39 @@ def find_all_annotation_references union = [] remap = {} references.each do |obj| - obj = obj.to_h - obj[:keyword] = obj.delete("keyword") - obj[:type] = obj.delete("type") - obj[:domain] = obj.delete("domain") - union, new_remap = BEL::Model.union_annotation_references(union, [obj], 'incr') + annotation = + BELParser::Expression::Model::Annotation.new( + *obj.values_at('keyword', 'type', 'domain') + ) + union, new_remap = + BEL::Nanopub.union_annotation_references(union, [annotation], 'incr') remap.merge!(new_remap) end remap end - def count_evidence(filters = []) + def count_nanopub(filters = []) query_hash = to_query(filters) @collection.count(:query => query_hash) end - def update_evidence_by_id(value, evidence) + def update_nanopub_by_id(value, nanopub) # add ObjectId to update _id = BSON::ObjectId(value) - evidence_h = evidence.to_h - evidence_h[:_id] = _id + nanopub_h = nanopub.to_h + nanopub_h[:_id] = _id - # save evidence; acknowledge journal - @collection.save(evidence_h, :j => true) + # save nanopub; acknowledge journal + @collection.save(nanopub_h, :j => true) - # remove evidence_facets after update to facets - remove_evidence_facets(_id) + # remove nanopub_facets after update to facets + remove_nanopub_facets(_id) nil end def delete_facets - @evidence_facets.delete_all_facets + @nanopub_facets.delete_all_facets end def delete_dataset(identifier) @@ -231,27 +233,27 @@ def delete_dataset(identifier) { :"_dataset" => identifier }, :j => true ) - @evidence_facets.delete_all_facets + @nanopub_facets.delete_all_facets end - def delete_evidence(value) + def delete_nanopub(value) if value.respond_to?(:each) value.each do |v| - delete_evidence_by_id(v) + delete_nanopub_by_id(v) end else - delete_evidence_by_id(value) + delete_nanopub_by_id(value) end end - def delete_evidence_by_query(query) + def delete_nanopub_by_query(query) @collection.remove( query, :j => true ) end - def delete_evidence_by_id(value) + def delete_nanopub_by_id(value) # convert to ObjectId begin _id = to_id(value) @@ -260,10 +262,10 @@ def delete_evidence_by_id(value) false end - # remove evidence_facets before evidence removal - remove_evidence_facets(_id) + # remove nanopub_facets before nanopub removal + remove_nanopub_facets(_id) - # remove evidence; returns true + # remove nanopub; returns true @collection.remove( { :_id => _id @@ -297,7 +299,7 @@ def ensure_all_indexes private - def evidence_query(filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) + def nanopub_query(filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) query_hash = to_query(filters) query_opts = query_options( query_hash, @@ -312,14 +314,14 @@ def evidence_query(filters = [], offset = 0, length = 0, facet = false, facet_va :cursor => @collection.find(query_hash, query_opts) } if facet - facets_cursor = @evidence_facets.find_facets(query_hash, filters, facet_value_limit) + facets_cursor = @nanopub_facets.find_facets(query_hash, filters, facet_value_limit) results[:facets] = facets_cursor.to_a end results end - def evidence_aggregate(text_search, filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) + def nanopub_aggregate(text_search, filters = [], offset = 0, length = 0, facet = false, facet_value_limit = -1) match_filters = filters.select { |filter| filter['category'] != 'fts' } @@ -376,7 +378,7 @@ def evidence_aggregate(text_search, filters = [], offset = 0, length = 0, facet facets = if facet query_hash = to_query(filters) - facets_cursor = @evidence_facets.find_facets(query_hash, filters, facet_value_limit) + facets_cursor = @nanopub_facets.find_facets(query_hash, filters, facet_value_limit) facets_cursor.to_a else nil @@ -498,13 +500,13 @@ def to_id(value) BSON::ObjectId(value.to_s) end - def remove_evidence_facets(_id) + def remove_nanopub_facets(_id) doc = @collection.find_one(_id, { :fields => {:_id => 0, :facets => 1} }) if doc && doc.has_key?('facets') - @evidence_facets.delete_facets(doc['facets']) + @nanopub_facets.delete_facets(doc['facets']) end end end diff --git a/lib/openbel/api/evidence/mongo_facet.rb b/lib/openbel/api/nanopub/mongo_facet.rb similarity index 82% rename from lib/openbel/api/evidence/mongo_facet.rb rename to lib/openbel/api/nanopub/mongo_facet.rb index d1bfc7c..8d0c2f1 100644 --- a/lib/openbel/api/evidence/mongo_facet.rb +++ b/lib/openbel/api/nanopub/mongo_facet.rb @@ -2,14 +2,16 @@ require 'multi_json' require_relative 'facet_api' require_relative 'facet_filter' +require_relative '../helpers/uuid_generator' module OpenBEL - module Evidence + module Nanopub - class EvidenceFacets + class NanopubFacets include FacetAPI include Mongo include FacetFilter + include ::OpenBEL::Helpers::UUIDGenerator def initialize(options = {}) host = options[:host] @@ -30,8 +32,8 @@ def initialize(options = {}) @db.authenticate(username, password, nil, auth_db) end - @evidence = @db[:evidence] - @evidence_facet_cache = @db[:evidence_facet_cache] + @nanopub = @db[:nanopub] + @nanopub_facet_cache = @db[:nanopub_facet_cache] # ensure all indexes are created and maintained ensure_all_indexes @@ -42,10 +44,10 @@ def find_facets(query, filters, facet_value_limit = -1) cache_collection = facet_cache_collection(sorted_filters) if no_collection?(cache_collection) - cache_collection = "evidence_facet_cache_#{EvidenceFacets.generate_uuid}" + cache_collection = "nanopub_facet_cache_#{generate_uuid}" create_aggr = create_aggregation(cache_collection, query) - @evidence.aggregate(create_aggr[:pipeline], create_aggr[:options]) - @evidence_facet_cache.insert({ + @nanopub.aggregate(create_aggr[:pipeline], create_aggr[:options]) + @nanopub_facet_cache.insert({ :filters => sorted_filters, :cache_collection => cache_collection }) @@ -82,7 +84,7 @@ def delete_facets(facets) facets.unshift([]) # Drop facet cache collections - @evidence_facet_cache.find( + @nanopub_facet_cache.find( {:filters => {:$in => facets}}, :fields => {:_id => 0, :cache_collection => 1} ).each do |doc| @@ -90,12 +92,12 @@ def delete_facets(facets) @db[cache_collection].drop() end - # remove filter match entries in evidence_facet_cache - @evidence_facet_cache.remove({:filters => {:$in => facets}}) + # remove filter match entries in nanopub_facet_cache + @nanopub_facet_cache.remove({:filters => {:$in => facets}}) end def delete_all_facets - @evidence_facet_cache.find( + @nanopub_facet_cache.find( {}, :fields => {:_id => 0, :cache_collection => 1} ).each do |doc| @@ -103,12 +105,12 @@ def delete_all_facets @db[cache_collection].drop() end - # remove all entries in evidence_facet_cache - @evidence_facet_cache.remove({}) + # remove all entries in nanopub_facet_cache + @nanopub_facet_cache.remove({}) end def ensure_all_indexes - @evidence_facet_cache.ensure_index([ + @nanopub_facet_cache.ensure_index([ [:"filters.category", Mongo::ASCENDING], [:"filters.name", Mongo::ASCENDING] ], @@ -132,7 +134,7 @@ def sort_filters(filters) end def facet_cache_collection(filters) - result = @evidence_facet_cache.find_one( + result = @nanopub_facet_cache.find_one( {:filters => filters}, :fields => {:cache_collection => 1, :_id => 0} ) @@ -203,19 +205,6 @@ def create_aggregation(out_collection, match_query = {}, options = {}) :allowDiskUse => true } } - - # Define UUID implementation based on Ruby. - if RUBY_ENGINE =~ /^jruby/i - java_import 'java.util.UUID' - define_singleton_method(:generate_uuid) do - Java::JavaUtil::UUID.random_uuid.to_s - end - else - require 'uuid' - define_singleton_method(:generate_uuid) do - UUID.generate - end - end end end end diff --git a/lib/openbel/api/plugin/evidence/evidence.rb b/lib/openbel/api/plugin/nanopub/nanopub.rb similarity index 76% rename from lib/openbel/api/plugin/evidence/evidence.rb rename to lib/openbel/api/plugin/nanopub/nanopub.rb index 11505b4..711811c 100644 --- a/lib/openbel/api/plugin/evidence/evidence.rb +++ b/lib/openbel/api/plugin/nanopub/nanopub.rb @@ -3,12 +3,12 @@ module OpenBEL module Plugin - class Evidence + class Nanopub include OpenBEL::Plugin - ID = 'evidence' - NAME = 'OpenBEL Evidence API' - DESC = 'API for accesing OpenBEL Evidence.' + ID = 'nanopub' + NAME = 'OpenBEL Nanopub API' + DESC = 'API for accesing OpenBEL Nanopub.' def id ID @@ -23,7 +23,7 @@ def description end def type - :evidence + :nanopub end def required_extensions @@ -35,7 +35,7 @@ def optional_extensions end def on_load - require_relative '../../evidence/mongo' + require_relative '../../nanopub/mongo' end def validate(extensions = {}, options = {}) @@ -51,7 +51,7 @@ def configure(extensions = {}, options = {}) end def create_instance - OpenBEL::Evidence::Evidence.new(@options) + OpenBEL::Nanopub::Nanopub.new(@options) end end end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index dcaf288..2e6d45d 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -23,11 +23,11 @@ expect(api._links.to_h.keys).to eql(['item']) end - it 'can navigate to "evidence" resource' do - evidence_link = api._links.item.find { |item| - item._url =~ %r{/evidence$} + it 'can navigate to "nanopub" resource' do + nanopub_link = api._links.item.find { |item| + item._url =~ %r{/nanopub$} } - expect(evidence_link._options._response.status).to eq(HTTP_OK) - expect(evidence_link._options._response[:allow]).to eq('OPTIONS,POST,GET') + expect(nanopub_link._options._response.status).to eq(HTTP_OK) + expect(nanopub_link._options._response[:allow]).to eq('OPTIONS,POST,GET') end end diff --git a/spec/auth_spec.rb b/spec/auth_spec.rb new file mode 100644 index 0000000..0929535 --- /dev/null +++ b/spec/auth_spec.rb @@ -0,0 +1,12 @@ +require_relative 'spec_helper' + +describe 'Authentication capabilities' do + it 'indicates whether authentication is enabled' do + response = api_conn.get '/api/authentication-enabled' + expect(response.status).to eql(HTTP_OK) + expect(response[:content_type]).to eql('application/json') + enabled = JSON.parse(response.body) + expect([true, false].include? enabled['enabled']).to eql(true) + end +end + diff --git a/spec/evidence/annotation_spec.rb b/spec/nanopub/annotation_spec.rb similarity index 51% rename from spec/evidence/annotation_spec.rb rename to spec/nanopub/annotation_spec.rb index 74f9e77..0714dd8 100644 --- a/spec/evidence/annotation_spec.rb +++ b/spec/nanopub/annotation_spec.rb @@ -1,26 +1,26 @@ require_relative '../spec_helper' require 'json' -describe 'API Evidence - Annotations' do +describe 'API Nanopub - Annotations' do - subject(:evidence_api) { - root_resource(:evidence) + subject(:nanopub_api) { + root_resource(:nanopub) } it 'stores name/value annotation as-is (free annotation)' do example = JSON.load(test_file('annotation.json')) - example['evidence']['experiment_context'] << { + example['nanopub']['experiment_context'] << { 'name' => 'Species', 'value' => '9606' } - post_and_get(example, '/api/evidence') do |response| + post_and_get(example, '/api/nanopubs') do |response| resource = response.body - expect(resource).to include('evidence') - expect(resource['evidence']).to be_a(Hash) - expect(resource['evidence']).to include('experiment_context') + expect(resource).to include('nanopub') + expect(resource['nanopub']).to be_a(Hash) + expect(resource['nanopub']).to include('experiment_context') - expect(resource['evidence']['experiment_context']).to include( + expect(resource['nanopub']['experiment_context']).to include( { 'name' => 'Species', 'value' => '9606' @@ -31,7 +31,7 @@ it 'normalizes name/value annotation names (free annotation)' do example = JSON.load(test_file('annotation.json')) - example['evidence']['experiment_context'] = [ + example['nanopub']['experiment_context'] = [ { 'name' => 'status_value', 'value' => '1' @@ -42,13 +42,13 @@ } ] - post_and_get(example, '/api/evidence') do |response| + post_and_get(example, '/api/nanopubs') do |response| resource = response.body - expect(resource).to include('evidence') - expect(resource['evidence']).to be_a(Hash) - expect(resource['evidence']).to include('experiment_context') + expect(resource).to include('nanopub') + expect(resource['nanopub']).to be_a(Hash) + expect(resource['nanopub']).to include('experiment_context') - expect(resource['evidence']['experiment_context']).to include( + expect(resource['nanopub']['experiment_context']).to include( {'name' => 'StatusValue', 'value' => '1'}, {'name' => 'StatusValue', 'value' => '3'} ) @@ -57,20 +57,20 @@ it 'normalizes name/value annotation to URI (structured annotation)' do example = JSON.load(test_file('annotation.json')) - example['evidence']['experiment_context'] = [ + example['nanopub']['experiment_context'] = [ { 'name' => 'Taxon', 'value' => '9606' } ] - post_and_get(example, '/api/evidence') do |response| + post_and_get(example, '/api/nanopubs') do |response| resource = response.body - expect(resource).to include('evidence') - expect(resource['evidence']).to be_a(Hash) - expect(resource['evidence']).to include('experiment_context') + expect(resource).to include('nanopub') + expect(resource['nanopub']).to be_a(Hash) + expect(resource['nanopub']).to include('experiment_context') - expect(resource['evidence']['experiment_context']).to include( + expect(resource['nanopub']['experiment_context']).to include( { 'name' => 'Ncbi Taxonomy', 'value' => 'Homo sapiens', @@ -82,19 +82,19 @@ it 'normalizes resource URI to equivalent URI (structured annotation)' do example = JSON.load(test_file('annotation.json')) - example['evidence']['experiment_context'] = [ + example['nanopub']['experiment_context'] = [ { 'uri' => "#{api_root}/annotations/taxon/values/9606" } ] - post_and_get(example, '/api/evidence') do |response| + post_and_get(example, '/api/nanopubs') do |response| resource = response.body - expect(resource).to include('evidence') - expect(resource['evidence']).to be_a(Hash) - expect(resource['evidence']).to include('experiment_context') + expect(resource).to include('nanopub') + expect(resource['nanopub']).to be_a(Hash) + expect(resource['nanopub']).to include('experiment_context') - expect(resource['evidence']['experiment_context']).to include( + expect(resource['nanopub']['experiment_context']).to include( { 'name' => 'Ncbi Taxonomy', 'value' => 'Homo sapiens', @@ -106,19 +106,19 @@ it "maps an annotation's RDF URI to an API URI" do example = JSON.load(test_file('annotation.json')) - example['evidence']['experiment_context'] = [ + example['nanopub']['experiment_context'] = [ { 'uri' => 'http://www.openbel.org/bel/namespace/ncbi-taxonomy/9606' } ] - post_and_get(example, '/api/evidence') do |response| + post_and_get(example, '/api/nanopubs') do |response| resource = response.body - expect(resource).to include('evidence') - expect(resource['evidence']).to be_a(Hash) - expect(resource['evidence']).to include('experiment_context') + expect(resource).to include('nanopub') + expect(resource['nanopub']).to be_a(Hash) + expect(resource['nanopub']).to include('experiment_context') - expect(resource['evidence']['experiment_context']).to include( + expect(resource['nanopub']['experiment_context']).to include( { 'name' => 'Ncbi Taxonomy', 'value' => 'Homo sapiens', diff --git a/spec/evidence/api_evidence_spec.rb b/spec/nanopub/api_nanopub_spec.rb similarity index 54% rename from spec/evidence/api_evidence_spec.rb rename to spec/nanopub/api_nanopub_spec.rb index d5f170c..4ebd98e 100644 --- a/spec/evidence/api_evidence_spec.rb +++ b/spec/nanopub/api_nanopub_spec.rb @@ -1,30 +1,30 @@ require_relative '../spec_helper' require 'json' -describe 'API Evidence' do +describe 'API Nanopub' do - subject(:evidence_api) { - root_resource(:evidence) + subject(:nanopub_api) { + root_resource(:nanopub) } it 'returns 404 when the resource collection is empty' do - response = api_conn.get '/api/evidence' + response = api_conn.get '/api/nanopubs' expect(response.status).to eql(404) end it 'returns an object when the resource collection is non-empty' do # create - response = api_conn.post('/api/evidence') { |req| + response = api_conn.post('/api/nanopubs') { |req| req.headers['Content-Type'] = 'application/json; charset=utf-8' - req.body = test_file('example_evidence.json').read + req.body = test_file('example_nanopub.json').read } expect(response.status).to eql(201) expect(response['Location']).not_to be_empty location = response['Location'] - expect(evidence_api._resource._response.body).to be_a(Hash) - expect(evidence_api._resource._response.body).to include('evidence_collection') - expect(evidence_api._resource['evidence_collection']).to be_an(Array) + expect(nanopub_api._resource._response.body).to be_a(Hash) + expect(nanopub_api._resource._response.body).to include('nanopub_collection') + expect(nanopub_api._resource['nanopub_collection']).to be_an(Array) # clean up api_conn.delete location @@ -32,9 +32,9 @@ it 'instances can be retrieved by id' do # create - response = api_conn.post('/api/evidence') { |req| + response = api_conn.post('/api/nanopubs') { |req| req.headers['Content-Type'] = 'application/json; charset=utf-8' - req.body = test_file('example_evidence.json').read + req.body = test_file('example_nanopub.json').read } expect(response.status).to eql(201) expect(response['Location']).not_to be_empty @@ -52,25 +52,25 @@ context 'entire collection (10 resources)' do it 'reports collection paging' do - # create evidence resources - evidence_uris = 10.times.map do |_| - response = api_conn.post('/api/evidence') { |req| + # create nanopub resources + nanopub_uris = 10.times.map do |_| + response = api_conn.post('/api/nanopubs') { |req| req.headers['Content-Type'] = 'application/json; charset=utf-8' - req.body = test_file('example_evidence.json').read + req.body = test_file('example_nanopub.json').read } expect(response.status).to eql(201) expect(response['Location']).not_to be_empty response['Location'] end - evidence_resource = api_conn.get { |req| - req.url '/api/evidence' + nanopub_resource = api_conn.get { |req| + req.url '/api/nanopubs' }.body - expect(evidence_resource['evidence_collection']).not_to be_nil - expect(evidence_resource['evidence_collection'].size).to eql(10) - expect(evidence_resource['metadata']).not_to be_nil - expect(evidence_resource['metadata']['collection_paging']).not_to be_nil - paging = evidence_resource['metadata']['collection_paging'] + expect(nanopub_resource['nanopub_collection']).not_to be_nil + expect(nanopub_resource['nanopub_collection'].size).to eql(10) + expect(nanopub_resource['metadata']).not_to be_nil + expect(nanopub_resource['metadata']['collection_paging']).not_to be_nil + paging = nanopub_resource['metadata']['collection_paging'] expect(paging['total']).to eql(10) expect(paging['total_filtered']).to eql(10) expect(paging['total_pages']).to eql(1) @@ -78,7 +78,7 @@ expect(paging['current_page_size']).to eql(10) # clean up - evidence_uris.each { |uri| + nanopub_uris.each { |uri| api_conn.delete uri } end @@ -87,30 +87,30 @@ context 'filtered collection' do it 'reports collection paging' do - # create evidence resources - human_evidence = test_file('human_evidence.json').read - evidence_uris = 10.times.map do |_| - response = api_conn.post('/api/evidence') { |req| + # create nanopub resources + human_nanopub = test_file('human_nanopub.json').read + nanopub_uris = 10.times.map do |_| + response = api_conn.post('/api/nanopubs') { |req| req.headers['Content-Type'] = 'application/json; charset=utf-8' - req.body = human_evidence + req.body = human_nanopub } expect(response.status).to eql(201) expect(response['Location']).not_to be_empty response['Location'] end - mouse_evidence = test_file('mouse_evidence.json').read - evidence_uris += 5.times.map do |_| - response = api_conn.post('/api/evidence') { |req| + mouse_nanopub = test_file('mouse_nanopub.json').read + nanopub_uris += 5.times.map do |_| + response = api_conn.post('/api/nanopubs') { |req| req.headers['Content-Type'] = 'application/json; charset=utf-8' - req.body = mouse_evidence + req.body = mouse_nanopub } expect(response.status).to eql(201) expect(response['Location']).not_to be_empty response['Location'] end - evidence_resource = api_conn.get { |req| - req.url '/api/evidence', + nanopub_resource = api_conn.get { |req| + req.url '/api/nanopubs', :start => 0, :size => 5, :filter => JSON.dump( @@ -121,11 +121,11 @@ } ) }.body - expect(evidence_resource['evidence_collection']).not_to be_nil - expect(evidence_resource['evidence_collection'].size).to eql(5) - expect(evidence_resource['metadata']).not_to be_nil - expect(evidence_resource['metadata']['collection_paging']).not_to be_nil - paging = evidence_resource['metadata']['collection_paging'] + expect(nanopub_resource['nanopub_collection']).not_to be_nil + expect(nanopub_resource['nanopub_collection'].size).to eql(5) + expect(nanopub_resource['metadata']).not_to be_nil + expect(nanopub_resource['metadata']['collection_paging']).not_to be_nil + paging = nanopub_resource['metadata']['collection_paging'] expect(paging['total']).to eql(15) expect(paging['total_filtered']).to eql(10) expect(paging['total_pages']).to eql(2) @@ -133,7 +133,7 @@ expect(paging['current_page_size']).to eql(5) # clean up - evidence_uris.each { |uri| + nanopub_uris.each { |uri| api_conn.delete uri } end diff --git a/spec/test_data/annotation.json b/spec/test_data/annotation.json index 668fa8a..a777af0 100644 --- a/spec/test_data/annotation.json +++ b/spec/test_data/annotation.json @@ -1,5 +1,5 @@ { - "evidence": { + "nanopub": { "bel_statement": "biologicalProcess(GOBP:aging) increases biologicalProcess(GOBP:\"apoptotic process\")", "citation": { "type": "PubMed", @@ -9,7 +9,7 @@ "authors": "de Nigris F|Lerman A|Ignarro LJ|Williams-Ignarro S|Sica V|Baker AH|Lerman LO|Geng YJ|Napoli C", "comment": "Primary literature from (Trends in Molecular Medicine)." }, - "summary_text": "Aging, one of the major predictors for atherosclerotic lesion formation, increases\nthe sensitivity of endothelial cells to apoptosis induced by in vitro and in vivo\nstimuli [35–37].", + "support": "Aging, one of the major predictors for atherosclerotic lesion formation, increases\nthe sensitivity of endothelial cells to apoptosis induced by in vitro and in vivo\nstimuli [35–37].", "experiment_context": [ ], "metadata": { diff --git a/spec/test_data/example_evidence.json b/spec/test_data/example_nanopub.json similarity index 87% rename from spec/test_data/example_evidence.json rename to spec/test_data/example_nanopub.json index 3b622a0..53e41fe 100644 --- a/spec/test_data/example_evidence.json +++ b/spec/test_data/example_nanopub.json @@ -1,5 +1,5 @@ { - "evidence": { + "nanopub": { "bel_statement": "biologicalProcess(GOBP:aging) increases biologicalProcess(GOBP:\"apoptotic process\")", "citation": { "type": "PubMed", @@ -9,7 +9,7 @@ "authors": ["de Nigris F", "Lerman A"], "comment": "Primary literature from (Trends in Molecular Medicine)." }, - "summary_text": "Aging, one of the major predictors for atherosclerotic lesion formation, increases\nthe sensitivity of endothelial cells to apoptosis induced by in vitro and in vivo\nstimuli [35–37].", + "support": "Aging, one of the major predictors for atherosclerotic lesion formation, increases\nthe sensitivity of endothelial cells to apoptosis induced by in vitro and in vivo\nstimuli [35–37].", "experiment_context": [ { "name": "Disease", diff --git a/spec/test_data/human_evidence.json b/spec/test_data/human_nanopub.json similarity index 88% rename from spec/test_data/human_evidence.json rename to spec/test_data/human_nanopub.json index 5f8a92b..50ff366 100644 --- a/spec/test_data/human_evidence.json +++ b/spec/test_data/human_nanopub.json @@ -1,5 +1,5 @@ { - "evidence": { + "nanopub": { "bel_statement": "p(HGNC:TIMP3) decreases bp(GOBP:angiogenesis)", "citation": { "type": "PubMed", @@ -9,7 +9,7 @@ "authors": ["de Nigris F", "Lerman A"], "comment": "Primary literature from (Trends in Molecular Medicine)." }, - "summary_text": "TIMP-3 can be anti-angiogenic by direct binding to vascular endothelial growth factor (VEGF) receptor 2 in a matrix-metalloproteinase- independent manner [94].", + "support": "TIMP-3 can be anti-angiogenic by direct binding to vascular endothelial growth factor (VEGF) receptor 2 in a matrix-metalloproteinase- independent manner [94].", "experiment_context": [ { "name": "Ncbi Taxonomy", diff --git a/spec/test_data/mouse_evidence.json b/spec/test_data/mouse_nanopub.json similarity index 82% rename from spec/test_data/mouse_evidence.json rename to spec/test_data/mouse_nanopub.json index af7d438..8982659 100644 --- a/spec/test_data/mouse_evidence.json +++ b/spec/test_data/mouse_nanopub.json @@ -1,5 +1,5 @@ { - "evidence": { + "nanopub": { "bel_statement": "p(MGI:Mapkap1) increases p(MGI:Akt1,pmod(P,S,473))", "citation": { "type": "PubMed", @@ -9,7 +9,7 @@ "authors": ["de Nigris F", "Lerman A"], "comment": "" }, - "summary_text": "We next examined the Akt T-loop Thr308 phosphorylation in wild-type and SIN1−/− cells. We found that although Ser473 phosphorylation was completely abolished in the SIN1−/− cells, Thr308 phosphorylation of Akt was not blocked (Figure 3A).", + "support": "We next examined the Akt T-loop Thr308 phosphorylation in wild-type and SIN1−/− cells. We found that although Ser473 phosphorylation was completely abolished in the SIN1−/− cells, Thr308 phosphorylation of Akt was not blocked (Figure 3A).", "experiment_context": [ { "name": "Ncbi Taxonomy", diff --git a/tools/migrations/0.6.x/README.md b/tools/migrations/0.6.x/README.md index 43a9168..4246c4e 100644 --- a/tools/migrations/0.6.x/README.md +++ b/tools/migrations/0.6.x/README.md @@ -1,6 +1,6 @@ ## MongoDB Migrations for 0.6.x -The 0.6.x version of OpenBEL API introduces a change to how evidence facets are stored in MongoDB. +The 0.6.x version of OpenBEL API introduces a change to how nanopub facets are stored in MongoDB. ### Change Detail @@ -8,21 +8,21 @@ The 0.6.x version of OpenBEL API introduces a change to how evidence facets are Collections: -- `evidence` - - Stores evidence.facets as strings. -- `evidence_facets` - - Stores evidence facet objects for all searches. +- `nanopub` + - Stores nanopub.facets as strings. +- `nanopub_facets` + - Stores nanopub facet objects for all searches. #### 0.6.x Collections: -- `evidence` - - Stores evidence.facets as JSON objects for use in Mongo aggregation operations. -- `evidence_facet_cache` - - Stores the facet collection name for each unique evidence search. -- `evidence_facet_cache_{UUID}` - - Stores evidence facet objects for a specific evidence search. +- `nanopub` + - Stores nanopub.facets as JSON objects for use in Mongo aggregation operations. +- `nanopub_facet_cache` + - Stores the facet collection name for each unique nanopub search. +- `nanopub_facet_cache_{UUID}` + - Stores nanopub facet objects for a specific nanopub search. ### Migration Procedure @@ -36,9 +36,9 @@ It is recommended to stop OpenBEL API and MongoDB before migrating. - `git clone https://github.com/OpenBEL/openbel-api.git` 4. Change directory to the 0.6.x migrations directory. - `cd openbel-api/tools/migrations/0.6.x` -5. Run *migrate_evidence_facets.rb* to update evidence.facets to JSON objects. - - `./migrate_evidence_facets.rb YOUR_CONFIG.yml` or `jruby migrate_evidence_facets.rb YOUR_CONFIG.yml` -6. Run *drop_unused_collection.rb* to remove the old *evidence_facets* collection. +5. Run *migrate_nanopub_facets.rb* to update nanopub.facets to JSON objects. + - `./migrate_nanopub_facets.rb YOUR_CONFIG.yml` or `jruby migrate_nanopub_facets.rb YOUR_CONFIG.yml` +6. Run *drop_unused_collection.rb* to remove the old *nanopub_facets* collection. - `./drop_unused_collection.rb YOUR_CONFIG.yml` or `jruby drop_unused_collection.rb YOUR_CONFIG.yml` 7. Start MongoDB daemon. 8. Start OpenBEL API. diff --git a/tools/migrations/0.6.x/clear_evidence_facets_cache.rb b/tools/migrations/0.6.x/clear_nanopub_facets_cache.rb similarity index 70% rename from tools/migrations/0.6.x/clear_evidence_facets_cache.rb rename to tools/migrations/0.6.x/clear_nanopub_facets_cache.rb index b0d8494..e2de642 100755 --- a/tools/migrations/0.6.x/clear_evidence_facets_cache.rb +++ b/tools/migrations/0.6.x/clear_nanopub_facets_cache.rb @@ -1,11 +1,11 @@ #!/usr/bin/env jruby -# Clears out evidence facet caches that may have been built before evidence +# Clears out nanopub facet caches that may have been built before nanopub # documents were migrated for 0.6.0. # # Mongo migration: -# - Drops all evidence_facet_cache_* collections. -# - Removes all documents from evidence_facet_caches that referenced the +# - Drops all nanopub_facet_cache_* collections. +# - Removes all documents from nanopub_facet_caches that referenced the # dropped collections. # @@ -18,7 +18,7 @@ ENV['OPENBEL_API_CONFIG_FILE'] ||= (ARGV.first || ENV['OPENBEL_API_CONFIG_FILE']) unless ENV['OPENBEL_API_CONFIG_FILE'] - $stderr.puts "usage: clear_evidence_facets_cache.rb [CONFIG FILE]\n" + $stderr.puts "usage: clear_nanopub_facets_cache.rb [CONFIG FILE]\n" $stderr.puts "Alternatively set the environment variable OPENBEL_API_CONFIG_FILE" exit 1 end @@ -44,13 +44,13 @@ def setup_mongo(cfg) end def migrate(mongo) - if mongo.collection_names.include?('evidence_facet_cache') - mongo['evidence_facet_cache'].remove({}) - puts %Q{Removing documents from "evidence_facet_cache" (success).} + if mongo.collection_names.include?('nanopub_facet_cache') + mongo['nanopub_facet_cache'].remove({}) + puts %Q{Removing documents from "nanopub_facet_cache" (success).} end mongo.collection_names.select { |name| - name =~ /^evidence_facet_cache_[0-9a-f\-]+$/ + name =~ /^nanopub_facet_cache_[0-9a-f\-]+$/ }.each do |name| mongo.drop_collection(name) puts %Q{Dropped "#{name}" collection (success).} @@ -62,7 +62,7 @@ def migrate(mongo) if ACTIVE_VERSION =~ VERSION_REQUIREMENT cfg = OpenBEL::Config.load! migrate( - setup_mongo(cfg[:evidence_store][:mongo]) + setup_mongo(cfg[:nanopub_store][:mongo]) ) exit 0 else diff --git a/tools/migrations/0.6.x/drop_unused_collection.rb b/tools/migrations/0.6.x/drop_unused_collection.rb index 8b583aa..a317351 100755 --- a/tools/migrations/0.6.x/drop_unused_collection.rb +++ b/tools/migrations/0.6.x/drop_unused_collection.rb @@ -1,8 +1,8 @@ #!/usr/bin/env jruby # Mongo migration: -# - Drops the now unused "evidence_facets" collection. -# - Replaced by the "evidence_facet_cache" collection plus individual UUID cache collections. +# - Drops the now unused "nanopub_facets" collection. +# - Replaced by the "nanopub_facet_cache" collection plus individual UUID cache collections. # - Idempotent (i.e. Safe to run multiple times.) # @@ -41,11 +41,11 @@ def setup_mongo(cfg) end def migrate(mongo) - if mongo.collection_names.include?('evidence_facets') - mongo.drop_collection('evidence_facets') - puts %Q{Dropped "evidence_facets" collection (success).} + if mongo.collection_names.include?('nanopub_facets') + mongo.drop_collection('nanopub_facets') + puts %Q{Dropped "nanopub_facets" collection (success).} else - puts %Q{The "evidence_facets" collection does not exist. Nothing to migrate (success).} + puts %Q{The "nanopub_facets" collection does not exist. Nothing to migrate (success).} end true @@ -54,7 +54,7 @@ def migrate(mongo) if ACTIVE_VERSION =~ VERSION_REQUIREMENT cfg = OpenBEL::Config.load! migrate( - setup_mongo(cfg[:evidence_store][:mongo]) + setup_mongo(cfg[:nanopub_store][:mongo]) ) exit 0 else diff --git a/tools/migrations/0.6.x/migrate_evidence_facets.rb b/tools/migrations/0.6.x/migrate_nanopub_facets.rb similarity index 78% rename from tools/migrations/0.6.x/migrate_evidence_facets.rb rename to tools/migrations/0.6.x/migrate_nanopub_facets.rb index 92beb30..ea17130 100755 --- a/tools/migrations/0.6.x/migrate_evidence_facets.rb +++ b/tools/migrations/0.6.x/migrate_nanopub_facets.rb @@ -1,7 +1,7 @@ #!/usr/bin/env jruby # Mongo migration: -# - Converts "evidence.facets" from JSON strings to objects in the document: +# - Converts "nanopub.facets" from JSON strings to objects in the document: # - Each facet will be expanded from a JSON string to: # { # category: "...", @@ -20,7 +20,7 @@ ENV['OPENBEL_API_CONFIG_FILE'] ||= (ARGV.first || ENV['OPENBEL_API_CONFIG_FILE']) unless ENV['OPENBEL_API_CONFIG_FILE'] - $stderr.puts "usage: migrate_evidence_facets.rb [CONFIG FILE]\n" + $stderr.puts "usage: migrate_nanopub_facets.rb [CONFIG FILE]\n" $stderr.puts "Alternatively set the environment variable OPENBEL_API_CONFIG_FILE" exit 1 end @@ -50,8 +50,8 @@ def migrate(mongo) count = 0 skipped = 0 - evidence_collection = mongo[:evidence] - evidence_collection.find do |cursor| + nanopub_collection = mongo[:nanopub] + nanopub_collection.find do |cursor| cursor.each do |doc| facets = doc['facets'] unless facets.empty? @@ -68,7 +68,7 @@ def migrate(mongo) if skip skipped += 1 else - evidence_collection.update( + nanopub_collection.update( {:_id => doc['_id']}, { :$set => { @@ -78,21 +78,21 @@ def migrate(mongo) ) count += 1 end - puts "...#{count} evidence migrated" if count > 0 && (count % 100).zero? + puts "...#{count} nanopub migrated" if count > 0 && (count % 100).zero? end end end - puts "Total of #{count} evidence migrated. Skipped #{skipped} evidence (success)." + puts "Total of #{count} nanopub migrated. Skipped #{skipped} nanopub (success)." true end if ACTIVE_VERSION =~ VERSION_REQUIREMENT cfg = OpenBEL::Config.load! migrate( - setup_mongo(cfg[:evidence_store][:mongo]) + setup_mongo(cfg[:nanopub_store][:mongo]) ) - $stdout.puts %Q{Successfully migrated "facets" field of documents in "evidence" collection from strings to full objects.} + $stdout.puts %Q{Successfully migrated "facets" field of documents in "nanopub" collection from strings to full objects.} exit 0 else $stderr.puts %Q{Migration is intended for version "#{VERSION_REQUIREMENT}".}