Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying ids in Service.enrichment call #55

Merged
merged 4 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
**/
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down
17 changes: 12 additions & 5 deletions js/im.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -5071,7 +5078,7 @@

},{"./promise":8}],17:[function(_dereq_,module,exports){
(function() {
exports.VERSION = '3.16.0';
exports.VERSION = '3.17.0';

}).call(this);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/service.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class Service
# of the items in this list.
# @param [Object<String, String>] opts The parameters to pass to the calculation.
# @option opts [String] list The name of the list to analyse.
# @option opts [Array<Number>] 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).
Expand All @@ -306,7 +307,13 @@ class Service
# @param [->] cb A function to call with the results when they have been received (optional).
# @return [Promise<Array<Object>>] 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.
Expand Down
12 changes: 12 additions & 0 deletions test/mocha/enrichment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down