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

Galaxy Workflow support for GenomeSpace #1814

Merged
merged 15 commits into from Aug 18, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions client/galaxy/scripts/mvc/form/form-parameters.js
Expand Up @@ -6,8 +6,9 @@ define(['utils/utils',
'mvc/ui/ui-select-content',
'mvc/ui/ui-select-library',
'mvc/ui/ui-select-ftp',
'mvc/ui/ui-select-genomespace',
'mvc/ui/ui-color-picker'],
function( Utils, Ui, SelectContent, SelectLibrary, SelectFtp, ColorPicker ) {
function( Utils, Ui, SelectContent, SelectLibrary, SelectFtp, SelectGenomeSpace, ColorPicker ) {

// create form view
return Backbone.Model.extend({
Expand All @@ -30,7 +31,8 @@ define(['utils/utils',
'baseurl' : '_fieldHidden',
'library_data' : '_fieldLibrary',
'ftpfile' : '_fieldFtp',
'upload' : '_fieldUpload'
'upload' : '_fieldUpload',
'genomespacefile' : '_fieldGenomeSpace'
},

/** Returns an input field for a given field type */
Expand Down Expand Up @@ -216,6 +218,18 @@ define(['utils/utils',
});
},

/** GenomeSpace file select field
*/
_fieldGenomeSpace: function( input_def ) {
var self = this;
return new SelectGenomeSpace.View({
id : 'field-' + input_def.id,
onchange : function() {
self.app.trigger( 'change' );
}
});
},

/** Upload file field */
_fieldUpload: function( input_def ) {
return new Ui.Upload({
Expand Down
24 changes: 24 additions & 0 deletions client/galaxy/scripts/mvc/tool/tool-genomespace.js
@@ -0,0 +1,24 @@
// Provides support for interacting with the GenomeSpace File Browser popup dialogue
define([], function() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this folder is the best location for this support module.


// tool form templates
return {
openFileBrowser: function( options ) {
var GS_UI_URL = window.Galaxy.config.genomespace_ui_url;
var GS_UPLOAD_URL = GS_UI_URL + 'upload/loadUrlToGenomespace.html?getLocation=true'

var newWin = window.open(GS_UPLOAD_URL, "GenomeSpace File Browser", "height=360px,width=600px");

successCalBack = options['successCallback'];
window.addEventListener( "message", function (e) {
successCalBack(e.data);
}, false);

newWin.focus();

if (options['errorCallback'] != null) newWin.setCallbackOnGSUploadError = config['errorCallback'];
}

};

});
96 changes: 96 additions & 0 deletions client/galaxy/scripts/mvc/ui/ui-select-genomespace.js
@@ -0,0 +1,96 @@
// dependencies
define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tool/tool-genomespace'],
function(Utils, Ui, GenomespaceBrowser) {

/**
* GenomeSpace file selector
*/
var View = Backbone.View.extend({
// initialize
initialize : function(options) {

// link this
var self = this;

// create insert new list element button
this.browse_button = new Ui.ButtonIcon({
title : 'Browse',
icon : 'fa fa-sign-in',
tooltip : 'Browse GenomeSpace',
onclick : function() {
self.browseGenomeSpace();
}
});

// create genomespace filepath textbox
this.filename_textbox = new Ui.Input();

// create genomespace token textbox
this.token_textbox = new Ui.Input({
type : 'password'
});

// create elements
this.setElement(this._template(options));
this.$('.ui-gs-browse-button').append(this.browse_button.$el);
this.$('.ui-gs-filename-textbox').append(this.filename_textbox.$el);
this.$('.ui-gs-token-textbox').append(this.token_textbox.$el);
},

/** Browse GenomeSpace */
browseGenomeSpace: function(options) {
var self = this;
GenomespaceBrowser.openFileBrowser({
successCallback: function(data) {
self.value(data.destination + "^" + data.token);
}
});
},

/** Main Template */
_template: function(options) {
return '<div class="ui-gs-select-file">' +
'<div class="ui-gs-browse-field">' +
'<span class="ui-gs-browse-button" />' +
'<span class="ui-gs-filename-textbox" />' +
'</div>' +
'<div class="ui-gs-token-field">' +
'<span class=ui-gs-label"><div class="ui-gs-token-label">Token</div></span>' +
'<span class="ui-gs-token-textbox" />' +
'</div>' +
'</div>';
},

/** Return/Set currently selected genomespace filename/token */
value : function (new_value) {
// check if new_value is defined
if (new_value !== undefined) {
this._setValue(new_value);
}
else {
return this._getValue();
}
},

// get value
_getValue: function() {
return this.filename_textbox.value() +
"^" + this.token_textbox.value();
},

// set value
_setValue: function(new_value) {
if (new_value) {
values = new_value.split("^");
this.filename_textbox.value(values[0]);
this.token_textbox.value(values[1]);
}
},

});

return {
View: View
}

});
28 changes: 28 additions & 0 deletions client/galaxy/style/less/ui.less
Expand Up @@ -879,6 +879,34 @@
}
}

.ui-gs-select-file {
.ui-gs-filename-textbox {
float: right;
width: ~'calc(100% - 76px)';
}
.ui-gs-token-textbox {
float: right;
width: ~'calc(100% - 76px)';
}
.ui-gs-browse-button {
float: left;
.ui-button-icon {
margin-top: 3px;
margin-right: 5px;
}
}
.ui-gs-token-label {
margin-top: 5px;
margin-left: 32px;
margin-right: 5px;
float: left;
}
.ui-gs-token-field {
clear: both;
padding-top: 5px;
}
}

.ui-select {
position: relative;
.icon-dropdown {
Expand Down
4 changes: 4 additions & 0 deletions config/galaxy.ini.sample
Expand Up @@ -632,6 +632,10 @@ nglims_config_file = tool-data/nglims.yaml
# The URL linked by the "Videos" link in the "Help" menu.
#screencasts_url = https://vimeo.com/galaxyproject

# Points to the GenomeSpace UI service which will be used by
# the GenomeSpace importer and exporter tools
#genomespace_ui_url = https://gsui.genomespace.org/jsui/

# The URL linked by the "Terms and Conditions" link in the "Help" menu, as well
# as on the user registration and login forms and in the activation emails.
#terms_url = None
Expand Down
2 changes: 1 addition & 1 deletion config/tool_conf.xml.main
Expand Up @@ -15,8 +15,8 @@
<tool file="data_source/wormbase.xml" />
<tool file="data_source/zebrafishmine.xml" />
<tool file="data_source/eupathdb.xml" />
<tool file="genomespace/genomespace_file_browser_prod.xml" />
<tool file="genomespace/genomespace_importer.xml" />
<tool file="genomespace/genomespace_push.xml" />
</section>
<section id="send" name="Send Data">
<tool file="genomespace/genomespace_exporter.xml" />
Expand Down
2 changes: 1 addition & 1 deletion config/tool_conf.xml.sample
Expand Up @@ -24,8 +24,8 @@
<tool file="data_source/zebrafishmine.xml" />
<tool file="data_source/eupathdb.xml" />
<tool file="data_source/hbvar.xml" />
<tool file="genomespace/genomespace_file_browser_prod.xml" />
<tool file="genomespace/genomespace_importer.xml" />
<tool file="genomespace/genomespace_push.xml" />
</section>
<section id="send" name="Send Data">
<tool file="genomespace/genomespace_exporter.xml" />
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/config.py
Expand Up @@ -382,6 +382,7 @@ def __init__(self, **kwargs):
self.wiki_url = kwargs.get('wiki_url', 'https://galaxyproject.org/')
self.blog_url = kwargs.get('blog_url', None)
self.screencasts_url = kwargs.get('screencasts_url', None)
self.genomespace_ui_url = kwargs.get('genomespace_ui_url', 'https://gsui.genomespace.org/jsui/')
self.library_import_dir = kwargs.get('library_import_dir', None)
self.user_library_import_dir = kwargs.get('user_library_import_dir', None)
# Searching data libraries
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/dependencies/pinned-requirements.txt
Expand Up @@ -78,3 +78,6 @@ pysam==0.8.4+gx5

# Chronos client
chronos-python==0.38.0

# GenomeSpace dependencies
python-genomespaceclient==0.1.8
1 change: 1 addition & 0 deletions lib/galaxy/managers/configuration.py
Expand Up @@ -45,6 +45,7 @@ def _defaults_to(default):
'search_url' : _defaults_to(self.app.config.wiki_url.rstrip("/") + "/search/"),
'mailing_lists' : _defaults_to(self.app.config.wiki_url.rstrip("/") + "/mailing-lists/"),
'screencasts_url' : _defaults_to("https://vimeo.com/galaxyproject"),
'genomespace_ui_url' : _defaults_to(None),
'citation_url' : _defaults_to(self.app.config.citation_url),
'support_url' : _defaults_to(self.app.config.support_url),
'lims_doc_url' : _defaults_to("https://usegalaxy.org/u/rkchak/p/sts"),
Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/tools/__init__.py
Expand Up @@ -154,6 +154,8 @@
"gd_phylogenetic_tree",
"gd_population_structure",
"gd_prepare_population_structure",
# Datasources
"genomespace_importer"
]
# Tools that needed galaxy on the PATH in the past but no longer do along
# with the version at which they were fixed.
Expand Down
15 changes: 15 additions & 0 deletions lib/galaxy/tools/parameters/basic.py
Expand Up @@ -626,6 +626,20 @@ def to_dict(self, trans, other_values=None):
return d


class GenomespaceFileToolParameter(ToolParameter):
"""
Parameter that takes one of two values.
"""

def __init__(self, tool, input_source):
input_source = ensure_input_source(input_source)
ToolParameter.__init__(self, tool, input_source)
self.value = input_source.get('value')

def get_initial_value(self, trans, other_values):
return self.value


class HiddenToolParameter(ToolParameter):
"""
Parameter that takes one of two values.
Expand Down Expand Up @@ -2087,6 +2101,7 @@ def to_dict(self, trans, other_values=None):
baseurl=BaseURLToolParameter,
file=FileToolParameter,
ftpfile=FTPFileToolParameter,
genomespacefile=GenomespaceFileToolParameter,
data=DataToolParameter,
data_collection=DataCollectionToolParameter,
library_data=LibraryDatasetToolParameter,
Expand Down
21 changes: 21 additions & 0 deletions lib/galaxy/web/form_builder.py
Expand Up @@ -208,6 +208,27 @@ def get_html(self, prefix=""):
return unicodify('<input type="file" name="%s%s"%s%s>' % (prefix, self.name, ajax_text, value_text))


class GenomespaceFileField(BaseField):
"""
A genomspace file browser field.
"""
def __init__(self, name, value=None):
self.name = name
self.value = value or ""

def get_html(self, prefix=""):
return unicodify('<script src="https://gsui.genomespace.org/jsui/upload/gsuploadwindow.js"></script>'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we originally started working on this, the tool parameters were still being rendered on the server side. Since it's now being rendered on the client-side, we've added a backbone component for it, but also left this bit as is since workflows don't fully support client-side rendering yet. Once that conversion is done, I hope that this bit can be nuked, preferably from orbit :-)

'<input type="text" name="{0}{1}" value="{2}">&nbsp;'
'<a href="javascript:gsLocationByGet({{ successCallback: function(config)'
' {{ selector_name = \'{0}{1}\'; selector = \'input[name=\' + selector_name.replace(\'|\', \'\\\\|\') + \']\';'
' $(selector).val(config.destination + \'^\' + config.token); }} }});">'
'Browse</a>'.format(prefix, self.name, escape(str(self.value), quote=True)))

def to_dict(self):
return dict(name=self.name,
token_field=self.token_field)


class HiddenField(BaseField):
"""
A hidden field.
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/form/form-parameters.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.