From 1cb1e9115b8dbba53b29d6d86c07e07c5ac6b244 Mon Sep 17 00:00:00 2001 From: uosl Date: Wed, 21 Aug 2019 13:52:53 +0100 Subject: [PATCH 1/3] Support specifying ids in Service.enrichment call --- src/service.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/service.coffee b/src/service.coffee index 79ffce4f..4bfb1f8d 100644 --- a/src/service.coffee +++ b/src/service.coffee @@ -297,6 +297,7 @@ class Service # of the items in this list. # @param [Object] opts The parameters to pass to the calculation. # @option opts [String] list The name of the list to analyse. + # @option opts [Array] ids Array of InterMine object ID numbers to analyse. # @option opts [String] widget The name of the enrichment calculation to use. # @option opts [Number] maxp The maximum permissible p-value (optional, default = 0.05). # @option opts [String] correction The correction algorithm to use (default = Holm-Bonferroni). @@ -306,7 +307,13 @@ class Service # @param [->] cb A function to call with the results when they have been received (optional). # @return [Promise>] A promise to get results. enrichment: (opts, cb) => REQUIRES_VERSION @, 8, => - req = merge {maxp: 0.05, correction: 'Holm-Bonferroni'}, opts + defaults = {maxp: 0.05, correction: 'Holm-Bonferroni'} + + if utils.isArray opts.ids + req = merge defaults, opts, {ids: opts.ids.join(",")} + else + req = merge defaults, opts + withCB cb, @get(ENRICHMENT_PATH, req).then(get 'results') # Search for items in the database by any term or facet. From 6bc48bd4f9d3bc8ce7f78ca52e2b019a570decb7 Mon Sep 17 00:00:00 2001 From: uosl Date: Mon, 9 Dec 2019 14:35:48 +0000 Subject: [PATCH 2/3] Test for using enrichment service with ids --- test/mocha/enrichment.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/mocha/enrichment.coffee b/test/mocha/enrichment.coffee index 6b3306f0..297ecb6f 100644 --- a/test/mocha/enrichment.coffee +++ b/test/mocha/enrichment.coffee @@ -55,6 +55,18 @@ integrationTests() && describe 'Service', -> it 'performs an enrichment calculation', eventually there_are_seven + + integrationTests() && describe '#enrichment, using ids', -> + + @beforeAll prepare -> service.enrichment + # ID contents of 'My-Favourite-Employees' list. + ids: [2000010, 2000019, 2000064, 2000067] + widget: 'contractor_enrichment' + maxp: 1 + correction: 'Bonferroni' + + it 'performs an enrichment calculation using ids', eventually there_are_seven + integrationTests() && describe '#enrichment with callback', -> it 'performs an enrichment calculation with a callback', (done) -> From e30c0cdd7d6f07f9372edab717366666162f8c6f Mon Sep 17 00:00:00 2001 From: uosl Date: Mon, 9 Dec 2019 14:44:29 +0000 Subject: [PATCH 3/3] Update CHANGES, version number and im.js bundle --- CHANGES | 1 + bower.json | 2 +- js/im.js | 17 ++++++++++++----- package.json | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 86f41288..07fda5f5 100644 --- a/CHANGES +++ b/CHANGES @@ -67,4 +67,5 @@ 3.12.0 Query#orderBy and Query#select accept an options object to silence events. 3.13.0 findById now accepts a list of fields to find. 3.16.0 update params for paginating query and setting number of results returned. Thanks Aman! +3.17.0 support specifying ids instead of list in service.enrichment options **/ diff --git a/bower.json b/bower.json index 33c9dfc8..c70d0543 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "imjs", - "version": "3.15.1", + "version": "3.17.0", "description": "Client library for communication with InterMine web-services", "main": "js/im.js", "dependencies": {}, diff --git a/js/im.js b/js/im.js index b6165ab0..87a40741 100644 --- a/js/im.js +++ b/js/im.js @@ -1,4 +1,4 @@ -/*! imjs - v3.16.0 - 2019-08-22 */ +/*! imjs - v3.17.0 - 2019-12-09 */ // This library is open source software according to the definition of the // GNU Lesser General Public Licence, Version 3, (LGPLv3) a copy of which is @@ -3541,11 +3541,18 @@ Service.prototype.enrichment = function(opts, cb) { return REQUIRES_VERSION(this, 8, (function(_this) { return function() { - var req; - req = merge({ + var defaults, req; + defaults = { maxp: 0.05, correction: 'Holm-Bonferroni' - }, opts); + }; + if (utils.isArray(opts.ids)) { + req = merge(defaults, opts, { + ids: opts.ids.join(",") + }); + } else { + req = merge(defaults, opts); + } return withCB(cb, _this.get(ENRICHMENT_PATH, req).then(get('results'))); }; })(this)); @@ -5071,7 +5078,7 @@ },{"./promise":8}],17:[function(_dereq_,module,exports){ (function() { - exports.VERSION = '3.16.0'; + exports.VERSION = '3.17.0'; }).call(this); diff --git a/package.json b/package.json index 43b6030d..58b0b5a6 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "imjs", - "version": "3.16.0", + "version": "3.17.0", "description": "Client library for communication with InterMine web-services", "main": "build/service", "browser": { "xmldom": "./build/shims/xmldom.js", - "build/service": "./dist/im.js" + "build/service": "./dist/im.js" }, "keywords": [ "javascript",