Example GOlr Sessions: Difference between revisions
Line 76: | Line 76: | ||
function jumper(arg1){ alert(arg1); }; | function jumper(arg1){ alert(arg1); }; | ||
var ac = new bbop.widget.search_box(gloc, gconf, 'in1', | var ac = new bbop.widget.search_box(gloc, gconf, 'in1', | ||
{ | |||
'label_template': | |||
<nowiki>'{{annotation_class_label}} ({{annotation_class}})',</nowiki> | |||
<nowiki>'value_template': '{{annotation_class}}',</nowiki> | |||
'list_select_callback': jumper | |||
}); | |||
ac.set_personality('bbop_term_ac'); | ac.set_personality('bbop_term_ac'); | ||
ac.add_query_filter('document_category', 'ontology_class'); | ac.add_query_filter('document_category', 'ontology_class'); |
Revision as of 19:56, 12 June 2013
Overview
This page has examples of various kinds things that you can with a BBOP JS session on the GO Solr (GOlr) data store.
More documentation soon...
Usage
The is a standard JS environment that makes use of
More documentation soon...
JS add.
This adds two numbers.
Session:
1 + 2;
Use a pre-defined output div.
Put something into one of the pre-defined output divs.
Session:
empty('div1'); append('div1', 'Hello, World!');
Simple loop (each) use.
An example of how to use the loop (each) iterator.
Session:
loop(['X', 'Y', 'Z'], function(item, i){ empty('div' + (i +1)); append('div' + (i +1), 'Hi, ' + item + '!'); });
Write to the log.
Write an arbitrary something to the REPL console log.
Session:
ll('Hello, World!');
Display the GAF URL (for current filters).
This doesn't do much, but illustrates how to get a link out.
Session:
empty('div3'); append('div3', go.gaf_url());
Add a trivial autocomplete box.
Add in an autocomplete at 'div2'.
Session:
empty('div2'); var in1 = new bbop.html.input({'id':'in1', 'style':'border:1px solid black;'}); // in1.to_string(); // in1.to_string().length; append('div2', in1.to_string()); var ac = new bbop.widget.search_box(gloc, gconf, 'in1'); ac.set_personality('bbop_ont');
Add a autocomplete box just for GO terms, with trivial callback
Add in an autocomplete at 'div2' for just GO terms using the somewhat slimmer 'bbop_term_ac' personality. This example also contains the addition of a trivial callback function that is triggered on selection.
Session:
empty('div2'); var in1 = new bbop.html.input({'id':'in1', 'style':'border:1px solid black;'}); append('div2', in1.to_string()); function jumper(arg1){ alert(arg1); }; var ac = new bbop.widget.search_box(gloc, gconf, 'in1', { 'label_template': '{{annotation_class_label}} ({{annotation_class}})', 'value_template': '{{annotation_class}}', 'list_select_callback': jumper }); ac.set_personality('bbop_term_ac'); ac.add_query_filter('document_category', 'ontology_class'); ac.add_query_filter('source', '(biological_process OR molecular_function OR cellular_component)');
PANTHER family annotation count for experimental evidence.
The REPL code for a familiar simple operation.
Session:
var print_panther = function(){ loop(data.facet_field('panther_family_label'), function(pitem){ ll(pitem[0] + ': ' + pitem[1]); }); }; go.set_personality('bbop_ann') go.add_query_filter('evidence_type_closure', 'experimental evidence'); go.set_results_count(0); go.set_facet_limit(-1); go.register('search', 'panther', print_panther, -10); go.search()
Startup code for REPL environment.
The code that is used to initialize the GOlr/BBOP JS REPL environment.
Session:
// Simplify our environment. var loop = bbop.core.each; var dump = bbop.core.dump; var what_is = bbop.core.what_is; // Defined a global logger. var logger = new bbop.logger(); logger.DEBUG = true; function ll(str){ return logger.kvetch(str); } // Get our data env right. var server_meta = new amigo.data.server(); var gloc = server_meta.golr_base(); var gconf = new bbop.golr.conf(amigo.data.golr); // Support a call back to data. var data = null; function callback(response){ data = response; ll('// Returned value placed in [data].'); } // Get a global manager. var go = new bbop.golr.manager.jquery(gloc, gconf); go.register('search', 's', callback); // Add GO-specific methods to our manager. bbop.golr.manager.prototype.gaf_url = function(){ return this.get_download_url(['source', 'bioentity_internal_id', 'bioentity_label', 'qualifier', 'annotation_class', 'reference', 'evidence_type', 'evidence_with', 'aspect', 'bioentity_name', 'synonym', 'type', 'taxon', 'date', 'assigned_by', 'annotation_extension_class', 'bioentity_isoform']); }; bbop.golr.manager.prototype.doc_type = function(t){ return this.add_query_filter('document_type', t); }; // jQuery helpers. var empty = function(did){ jQuery('#' + did).empty(); }; var append = function(did, str){ jQuery('#' + did).append(str); };
Create a popup search pane.
This creates a dialog box with a set id, then populates it with a search pane.
Session:
bbop.widget.dialog('<br />;<div id="popup-search-display" style="font-size: 75%"></div>', {width: '800', title: 'search prototype'}); var search = new bbop.widget.search_pane(gloc, gconf, 'popup-search-display'); search.include_highlighting(true); search.set_personality('bbop_ann'); search.add_query_filter('document_category', 'annotation', ['*']); search.establish_display(); search.reset();