Skip to content

Commit

Permalink
Merge ec4c997 into 1b4dd1f
Browse files Browse the repository at this point in the history
  • Loading branch information
eapearson committed Apr 16, 2018
2 parents 1b4dd1f + ec4c997 commit ac4b069
Show file tree
Hide file tree
Showing 14 changed files with 1,115 additions and 1,240 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 5
rules:
strict:
- error
- function
indent:
- error
- 4
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"handlebars": "^4.0.5",
"jquery-nearest": "~1.3.1",
"jquery.tipsy": "*",
"kbase-common-js": "2.15.1",
"kbase-common-js": "2.16.0",
"kbase-service-clients-js": "3.3.4",
"kbase-sdk-clients-js": "0.5.1",
"numeral": "~1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@
*/

define([
'kbwidget',
'bootstrap',
'jquery',
'narrativeConfig',
'kbwidget',
'kbaseAuthenticatedWidget',
'kbaseTabs',
'kb_common/jsonRpc/dynamicServiceClient',
// For effect
'bootstrap',
'jquery-dataTables',
'kbase-generic-client-api',
// NON Amd
'kbaseFeatureValues-client-api'
], function (
KBWidget,
bootstrap,
$,
Config,
KBWidget,
kbaseAuthenticatedWidget,
kbaseTabs,
GenericClient
) {
DynamicServiceClient
) {
'use strict';

return KBWidget({
name: 'kbaseExpressionConditionsetBaseWidget',
parent: kbaseAuthenticatedWidget,
Expand All @@ -40,15 +43,7 @@ define([
expressionMatrixID: null,
conditionIds: null,

// input_featureset: null,

// Service URL: should be in window.kbconfig.urls.
// featureValueURL: 'http://localhost:8889',
useDynamicService: true,
featureValueSrvVersion: 'dev',
featureValueURL: 'https://ci.kbase.us/services/feature_values/jsonrpc',
wsURL: window.kbconfig.urls.workspace,
loadingImage: "static/kbase/images/ajax-loader.gif"
loadingImage: 'static/kbase/images/ajax-loader.gif'
},

// Prefix for all div ids
Expand All @@ -64,54 +59,44 @@ define([
this._super(options);
this.pref = this.uuid();

if (window.kbconfig && window.kbconfig.urls) {
this.options.featureValueURL = window.kbconfig.urls.feature_values;
this.options.wsURL = window.kbconfig.urls.workspace;
}

// Create a message pane
this.$messagePane = $("<div/>").addClass("kbwidget-message-pane kbwidget-hide-message");
this.$messagePane = $('<div/>').addClass('kbwidget-message-pane kbwidget-hide-message');
this.$elem.append(this.$messagePane);

return this;
},

loggedInCallback: function(event, auth) {

// Build a client
if (this.options.useDynamicService) {
var serviceWizardURL = this.options.featureValueURL.replace("feature_values/jsonrpc",
"service_wizard");
this.genericClient = new GenericClient(serviceWizardURL, auth);
} else {
this.featureValueClient = new KBaseFeatureValues(this.options.featureValueURL, auth);
}
this.ws = new Workspace(this.options.wsURL, auth);
this.featureValues = new DynamicServiceClient({
module: 'KBaseFeatureValues',
url: Config.url('service_wizard'),
token: auth.token
});

// Let's go...
this.loadAndRender();
return this;
},

loggedOutCallback: function(event, auth) {
loggedOutCallback: function() {
this.isLoggedIn = false;
return this;
},

setTestParameters: function(){
this.options.workspaceID = '645';
this.options.expressionMatrixID = '9';
this.options.conditionIds = "ni__0500um_vs_NRC-1c,ni__1500um_vs_NRC-1c,ura3_Mn_1500um_b_vs_NRC-1d.sig";
this.options.conditionIds = 'ni__0500um_vs_NRC-1c,ni__1500um_vs_NRC-1c,ura3_Mn_1500um_b_vs_NRC-1d.sig';
},

// To be overriden to specify additional parameters
getSubmtrixParams: function(){
var self = this;
self.setTestParameters();
var conditions = [];
if(self.options.conditionIds) { conditions = $.map(self.options.conditionIds.split(","), $.trim); }
if(self.options.conditionIds) { conditions = $.map(self.options.conditionIds.split(','), $.trim); }
return{
input_data: self.options.workspaceID + "/" + self.options.expressionMatrixID,
input_data: self.options.workspaceID + '/' + self.options.expressionMatrixID,
column_ids: conditions,
fl_column_set_stat: 1,
// specify your additional parameters
Expand All @@ -127,74 +112,34 @@ define([

// some parameter checking
if(!smParams.column_ids || smParams.column_ids.length===0) {
self.clientError("No Conditions selected. Please include at least one Condition from the data.");
self.clientError('No Conditions selected. Please include at least one Condition from the data.');
return;
}

if (self.options.useDynamicService) {
self.genericClient.sync_call("KBaseFeatureValues.get_submatrix_stat",
[smParams],
function (data) {
self.submatrixStat = data[0];
self.render();
self.loading(false);
},
function (error) {
self.clientError(error);
}, self.options.featureValueSrvVersion);
} else {
self.featureValueClient.get_submatrix_stat(
smParams,
function(data){
self.submatrixStat = data;
self.render();
self.loading(false);
},
function(error){
self.clientError(error);
});
}
self.featureValues.callFunc('get_submatrix_stat', [
smParams
])
.spread(function (data) {
self.submatrixStat = data;
self.render();
self.loading(false);
})
.error(function (err) {
self.clientError(err);
});
};
getSubmatrixStatsAndRender();

// if a feature set is defined, use it.
// if(self.options.featureset) {
// self.ws.get_objects([{ref:self.options.workspaceID+"/"+self.options.featureset}],
// function(fdata) {
// var fs = fdata[0].data;
// if(!self.options.geneIds) { self.options.geneIds=''; }

// for (var fid in fs.elements) {
// if (fs.elements.hasOwnProperty(fid)) {
// if(self.options.geneIds) {
// self.options.geneIds += ",";
// }
// self.options.geneIds += fid;
// // for now we ignore which genome it came from, just use the ids
// // for (var k=0; k<fs.elements[fid].length; k++) {
// // var gid = fs.elements[fid][k];
// // }
// }
// }
// getSubmatrixStatsAndRender();
// },
// function(error) {
// self.clientError(error);
// });
// } else {
// getSubmatrixStatsAndRender();
// }
},

render: function(){
var $overviewContainer = $("<div/>");
var $overviewContainer = $('<div/>');
this.$elem.append( $overviewContainer );
this.buildOverviewDiv( $overviewContainer );

// Separator
this.$elem.append( $('<div style="margin-top:1em"></div>') );

var $vizContainer = $("<div/>");
var $vizContainer = $('<div/>');
this.$elem.append( $vizContainer );
this.buildWidget( $vizContainer );
},
Expand All @@ -203,43 +148,41 @@ define([
var self = this;
var pref = this.pref;

var $overviewSwitch = $("<a/>").html('[Show/Hide Selected Conditions]');
var $overviewSwitch = $('<a/>').html('[Show/Hide Selected Conditions]');
$containerDiv.append($overviewSwitch);

var $overvewContainer = $('<div hidden style="margin:1em 0 4em 0"/>');
$containerDiv.append($overvewContainer);

var $overviewContainer = $('<div hidden style="margin:1em 0 4em 0"/>');
$containerDiv.append($overviewContainer);

var conditionsData = self.buildConditionsTableData();
var iDisplayLength = 10;
var style = 'lftip';
if(conditionsData.length<=iDisplayLength) { style = 'fti'; }

var tableGenes = $('<table id="'+pref+'condition-table" \
$overviewContainer.append($('<table id="'+pref+'condition-table" \
class="table table-bordered table-striped" style="width: 100%; margin-left: 0px; margin-right: 0px;">\
</table>')
.appendTo($overvewContainer)
.dataTable( {
"sDom": style,
"iDisplayLength": iDisplayLength,
"aaData": conditionsData,
"aoColumns": [
{ sTitle: "Name", mData: "id"},
'sDom': style,
'iDisplayLength': iDisplayLength,
'aaData': conditionsData,
'aoColumns': [
{ sTitle: 'Name', mData: 'id'},
// { sTitle: "Function", mData: "function"},
{ sTitle: "Min", mData:"min" },
{ sTitle: "Max", mData:"max" },
{ sTitle: "Avg", mData:"avg" },
{ sTitle: "Std", mData:"std"},
{ sTitle: "Missing", mData:"missing_values" }
{ sTitle: 'Min', mData:'min' },
{ sTitle: 'Max', mData:'max' },
{ sTitle: 'Avg', mData:'avg' },
{ sTitle: 'Std', mData:'std'},
{ sTitle: 'Missing', mData:'missing_values' }
],
"oLanguage": {
"sEmptyTable": "No conditions found!",
"sSearch": "Search: "
'oLanguage': {
'sEmptyTable': 'No conditions found!',
'sSearch': 'Search: '
}
} );
}));

$overviewSwitch.click(function(){
$overvewContainer.toggle();
$overviewContainer.toggle();
});
},

Expand Down Expand Up @@ -268,24 +211,24 @@ define([
},

// To be overriden
buildWidget: function($containerDiv){},
buildWidget: null,

makeRow: function(name, value) {
var $row = $("<tr/>")
.append($("<th />").css('width','20%').append(name))
.append($("<td />").append(value));
var $row = $('<tr/>')
.append($('<th />').css('width','20%').append(name))
.append($('<td />').append(value));
return $row;
},

loading: function(isLoading) {
if (isLoading)
this.showMessage("<img src='" + this.options.loadingImage + "'/>");
this.showMessage('<img src=\'' + this.options.loadingImage + '\'/>');
else
this.hideMessage();
},

showMessage: function(message) {
var span = $("<span/>").append(message);
var span = $('<span/>').append(message);

this.$messagePane.append(span);
this.$messagePane.show();
Expand All @@ -298,29 +241,29 @@ define([

clientError: function(error){
this.loading(false);
var errString = "Unknown error.";
var errString = 'Unknown error.';
console.error(error);
if (typeof error === "string")
if (typeof error === 'string')
errString = error;
else if (error.error && error.error.message)
errString = error.error.message;
else if (error.error && error.error.error && typeof error.error.error==='string') {
errString = error.error.error;
if(errString.indexOf("java.lang.NullPointerException") > -1 &&
errString.indexOf("buildIndeces(KBaseFeatureValuesImpl.java:708)") > -1) {
if(errString.indexOf('java.lang.NullPointerException') > -1 &&
errString.indexOf('buildIndeces(KBaseFeatureValuesImpl.java:708)') > -1) {
// this is a null pointer due to an unknown feature ID. TODO: handle this gracefully
errString = "Feature IDs not found.<br><br>";
errString += "Currently all Features included in a FeatureSet must be present" +
" in the Expression Data Matrix. Please rebuild the FeatureSet " +
"so that it only includes these features. This is a known issue "+
"and will be fixed shortly."
errString = 'Feature IDs not found.<br><br>';
errString += 'Currently all Features included in a FeatureSet must be present' +
' in the Expression Data Matrix. Please rebuild the FeatureSet ' +
'so that it only includes these features. This is a known issue '+
'and will be fixed shortly.';
}
}

var $errorDiv = $("<div>")
.addClass("alert alert-danger")
.append("<b>Error:</b>")
.append("<br>" + errString);
var $errorDiv = $('<div>')
.addClass('alert alert-danger')
.append('<b>Error:</b>')
.append('<br>' + errString);
this.$elem.empty();
this.$elem.append($errorDiv);
},
Expand Down
Loading

0 comments on commit ac4b069

Please sign in to comment.