Skip to content

Commit

Permalink
add a universal workbench for noctua for doing arbitrary sparql queri…
Browse files Browse the repository at this point in the history
…es; as this can be very easily transferred to a model workbench (would need to extend bbop-manager-sparql to just return filled templates) this is essentially completion for geneontology/go-graphstore#9 and #465; TODO: track down cross-site issue
  • Loading branch information
kltm committed Sep 15, 2017
1 parent 5d6c0de commit 602e29d
Show file tree
Hide file tree
Showing 6 changed files with 69,081 additions and 0 deletions.
164 changes: 164 additions & 0 deletions workbenches/gosling/Gosling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
////
//// A little fun driving a view with YAS*.
////

// Let jshint pass over over our external globals (browserify takes
// care of it all).
/* global YASQE */
/* global YASR */
/* global jQuery */
/* global global_barista_token */
/* global global_barista_location */
/* global global_sparql_templates_universal */

var us = require('underscore');
var bbop = require('bbop-core');
//var bbop = require('bbop').bbop;
//var bbopx = require('bbopx');
var amigo_inst = require('amigo2-instance-data');
var amigo = new amigo_inst();
var bbop_legacy = require('bbop').bbop;

// Help with strings and colors--configured separately.
var aid = new bbop_legacy.context(amigo.data.context);

var widgetry = require('noctua-widgetry');

// Aliases
var each = us.each;
var uuid = bbop.uuid;

// Code here will be ignored by JSHint, as we are technically
// "redefining" jQuery (although we are not).
/* jshint ignore:start */
var jQuery = require('jquery');
/* jshint ignore:end */

//
var json_response = require('bbop-rest-response');
var jquery_engine = require('bbop-rest-manager').jquery;
var sparql_manager = require('bbop-manager-sparql');

///
/// ...
///

var sparql_select_id = 'spqlsel';
var yasqe_id = 'yasqe';
var yasr_id = 'yasr';

// Make the default ours at least.
YASQE.defaults.sparql.endpoint = "http://rdf.geneontology.org/sparql";

///
var GoslingInit = function(){

var logger = new bbop.logger('gosling');
logger.DEBUG = true;
function ll(str){ logger.kvetch(str); }

///
/// Add option to dropdown.
///

// Attach to interface.
var app_map = {};
var selopts_str = [];
us.each(global_sparql_templates_universal, function(tmpl){
var uuid = bbop.uuid();

// Mental.
app_map[uuid] = tmpl;

// Physical.
var str = '<option value="' + uuid + '">' + tmpl.title + '</option>';
selopts_str.push(str);
});
jQuery('#'+sparql_select_id).append(selopts_str.join(''));

///
/// Setup and glue YAS*.
///

var yasqe = YASQE(document.getElementById("yasqe"), {
sparql: {
showQueryButton: true,
endpoint: 'http://rdf.geneontology.org/sparql'
}
});
var yasr = YASR(document.getElementById("yasr"), {
//this way, the URLs in the results are prettified using the
//defined prefixes in the query
getUsedPrefixes: yasqe.getPrefixesFromQuery
});

//link both together
yasqe.options.sparql.callbacks.complete = yasr.setResponse;

///
/// ...
///

function _insertion(tmpl){

var prefixes = '';
us.each(tmpl['prefixes'], function(prefix){
prefixes +=
'PREFIX '+ prefix['prefix'] +':'+ prefix['expansion'] +'\n';
});
var qstr = prefixes + tmpl['query'];

yasqe.setValue(qstr);
if( tmpl['endpoint'] ){
var ep = tmpl['endpoint'];
//yasqe.endpoint(tmpl['endpoint']);
//YASQE.defaults.sparql.endpoint = ep;
//yasqe.defaults.sparql.endpoint = ep;
}
}

// Make the interface live.
jQuery("#"+sparql_select_id).change(function(){
var tmpl_id = jQuery(this).val();
console.log(tmpl_id);
var tmpl = app_map[tmpl_id];
console.log(tmpl);
console.log(app_map);
_insertion(tmpl);
});

// Insert first item.
var stu = global_sparql_templates_universal;
if( stu && stu[0] ){
_insertion(stu[0]);
}
};

// Start the day the jQuery way.
jQuery(document).ready(function(){
console.log('jQuery ready');

// Try to define token.
var start_token = null;
if( global_barista_token ){
start_token = global_barista_token;
}

// Next we need a manager to try and pull in the model.
if( typeof(global_minerva_definition_name) === 'undefined' ||
typeof(global_barista_location) === 'undefined' ){
alert('environment not ready');
}else{
// Only roll if the env is correct.
// Will use the above variables internally (sorry).
GoslingInit();

// When all is said and done, let's also fillout the user
// name just for niceness. This is also a test of CORS in
// express.
if( start_token ){
widgetry.user_check(global_barista_location,
start_token, 'user_name_info', false);
}
}
});
4 changes: 4 additions & 0 deletions workbenches/gosling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```
npm install
npm run build
```
11 changes: 11 additions & 0 deletions workbenches/gosling/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
menu-name: "Gosling (Noctua's little GOOSE)"
page-name: "Gosling (Noctua's little GOOSE)"
type: "universal"
help-link: "http://github.com/geneontology/noctua/issues"
javascript:
- http://cdn.jsdelivr.net/yasqe/2.11.10/yasqe.bundled.min.js
- http://cdn.jsdelivr.net/yasr/2.10.8/yasr.bundled.min.js
- GoslingBundle.js
css:
- http://cdn.jsdelivr.net/yasqe/2.11.10/yasqe.min.css
- http://cdn.jsdelivr.net/yasr/2.10.8/yasr.min.css
91 changes: 91 additions & 0 deletions workbenches/gosling/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "workbench-go-gosling",
"version": "0.0.1",
"license": "BSD-3-Clause",
"description": "Experimental GOOOSE-like Noctua interface for the Gene Ontology.",
"keywords": [
"workbench",
"gene ontology",
"GO",
"bbop",
"SPARQL",
"GOOSE",
"YASGUI",
"noctua"
],
"author": "SJC <[email protected]> (http://berkeleybop.org/)",
"homepage": "http://berkeleybop.org/",
"repository": {
"type": "git",
"url": "git+https://github.com/geneontology/noctua.git"
},
"engines": {
"node": ">= 4.4",
"npm": ">= 2.15"
},
"dependencies": {
"amigo2-instance-data": "2.5.7",
"amigo2": "2.4.3",
"bbop": "2.4.3",
"bbop-core": "0.0.5",
"bbop-graph-noctua": "0.0.32",
"bbop-manager-sparql": "0.0.5",
"bbop-rest-manager": "0.0.17",
"bbop-rest-response": "0.0.4",
"gulp": "^3.9.1",
"jquery": "^2.2.4",
"underscore": "1.8.3"
},
"devDependencies": {
"browserify": "^13.0.1",
"browserify-shim": "^3.8.12",
"chai": "^3.5.0",
"eslint": "^2.13.1",
"gulp-bump": "^2.1.0",
"gulp-git": "^1.7.2",
"gulp-jsdoc": "^0.1.5",
"gulp-jshint": "^2.0.1",
"gulp-mocha": "^2.2.0",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^1.5.3",
"jsdoc": "^3.4.0",
"jshint": "^2.9.3",
"uglifyify": "^3.0.2",
"vinyl-source-stream": "1.1.0",
"wait-on": "^1.5.2",
"watchify": "^3.7.0"
},
"browserify": {
"transform": [
"browserify-shim"
]
},
"browser": {
"jquery": "./node_modules/jquery/dist/jquery.min.js",
"bootstrap": "./node_modules/bootstrap/dist/js/bootstrap.min.js",
"jquery-ui": "./external_js/jquery-ui-1.10.3.custom.min.js",
"noctua-widgetry": "../../js/lib/noctua-widgetry/widgetry.js"
},
"browserify-shim": {
"jquery": {
"exports": "global:jQuery"
},
"jquery-ui": {
"depends": [
"jquery"
]
}
},
"bundleDependencies": [],
"private": false,
"main": null,
"bugs": {
"url": "https://github.com/geneontology/noctua/issues"
},
"directories": {
},
"scripts": {
"build": "./node_modules/.bin/browserify Gosling.js -o public/GoslingBundle.js --exclude ringo/httpclient",
"test": "echo \"Error: no test specified\" && exit 1"
}
}
Loading

0 comments on commit 602e29d

Please sign in to comment.