mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #1814 from gvlproject/genomespace_workflows
Galaxy Workflow support for GenomeSpace
This commit is contained in:
@@ -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({
|
||||
@@ -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 */
|
||||
@@ -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({
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Provides support for interacting with the GenomeSpace File Browser popup dialogue
|
||||
define([], function() {
|
||||
|
||||
// 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'];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
@@ -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
|
||||
}
|
||||
|
||||
});
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -382,6 +382,7 @@ class Configuration(object):
|
||||
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
|
||||
|
||||
@@ -78,3 +78,6 @@ pysam==0.8.4+gx5
|
||||
|
||||
# Chronos client
|
||||
chronos-python==0.38.0
|
||||
|
||||
# GenomeSpace dependencies
|
||||
python-genomespaceclient==0.1.8
|
||||
@@ -45,6 +45,7 @@ class ConfigSerializer(base.ModelSerializer):
|
||||
'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"),
|
||||
|
||||
@@ -154,6 +154,8 @@ GALAXY_LIB_TOOLS_UNVERSIONED = [
|
||||
"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.
|
||||
|
||||
@@ -626,6 +626,20 @@ class FTPFileToolParameter(ToolParameter):
|
||||
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.
|
||||
@@ -2087,6 +2101,7 @@ parameter_types = dict(
|
||||
baseurl=BaseURLToolParameter,
|
||||
file=FileToolParameter,
|
||||
ftpfile=FTPFileToolParameter,
|
||||
genomespacefile=GenomespaceFileToolParameter,
|
||||
data=DataToolParameter,
|
||||
data_collection=DataCollectionToolParameter,
|
||||
library_data=LibraryDatasetToolParameter,
|
||||
|
||||
@@ -208,6 +208,27 @@ class FileField(BaseField):
|
||||
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>'
|
||||
'<input type="text" name="{0}{1}" value="{2}"> '
|
||||
'<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.
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"form-parameters.js","sources":["../../../src/mvc/form/form-parameters.js"],"names":["define","Utils","Ui","SelectContent","SelectLibrary","SelectFtp","ColorPicker","Backbone","Model","extend","types","text","password","select","data_column","genomebuild","data","data_collection","integer","float","boolean","drill_down","color","hidden","hidden_data","baseurl","library_data","ftpfile","upload","create","input_def","fieldClass","this","type","field","call","options","_fieldSelect","_fieldText","Galaxy","emit","debug","undefined","value","_fieldData","View","id","extensions","optional","multiple","flavor","onchange","is_workflow","error_text","_","each","option","push","label","SelectClass","Select","display","Checkbox","Radio","RadioButton","individual","searchable","_fieldDrilldown","Drilldown","area","isEmpty","$","isArray","str_value","i","String","Input","readonly","placeholder","datalist","_fieldSlider","Slider","precise","min","max","_fieldHidden","Hidden","info","_fieldBoolean","_fieldColor","_fieldLibrary","_fieldFtp","_fieldUpload","Upload"],"mappings":"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"}
|
||||
{"version":3,"file":"form-parameters.js","sources":["../../../src/mvc/form/form-parameters.js"],"names":["define","Utils","Ui","SelectContent","SelectLibrary","SelectFtp","SelectGenomeSpace","ColorPicker","Backbone","Model","extend","types","text","password","select","data_column","genomebuild","data","data_collection","integer","float","boolean","drill_down","color","hidden","hidden_data","baseurl","library_data","ftpfile","upload","genomespacefile","create","input_def","fieldClass","this","type","field","call","options","_fieldSelect","_fieldText","Galaxy","emit","debug","undefined","value","_fieldData","View","id","extensions","optional","multiple","flavor","onchange","is_workflow","error_text","_","each","option","push","label","SelectClass","Select","display","Checkbox","Radio","RadioButton","individual","searchable","_fieldDrilldown","Drilldown","area","isEmpty","$","isArray","str_value","i","String","Input","readonly","placeholder","datalist","_fieldSlider","Slider","precise","min","max","_fieldHidden","Hidden","info","_fieldBoolean","_fieldColor","_fieldLibrary","_fieldFtp","_fieldGenomeSpace","self","app","trigger","_fieldUpload","Upload"],"mappings":"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"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tool-genomespace.js","sources":["../../../src/mvc/tool/tool-genomespace.js"],"names":["define","openFileBrowser","options","GS_UI_URL","window","Galaxy","config","genomespace_ui_url","GS_UPLOAD_URL","newWin","open","successCalBack","addEventListener","e","data","focus","setCallbackOnGSUploadError"],"mappings":"AACAA,UAAW,WAGX,OACIC,gBAAiB,SAAUC,GACvB,GAAIC,GAAYC,OAAOC,OAAOC,OAAOC,mBACjCC,EAAgBL,EAAY,oDAE5BM,EAASL,OAAOM,KAAKF,EAAe,2BAA4B,2BAEpEG,gBAAiBT,EAAyB,gBAC1CE,OAAOQ,iBAAkB,UAAW,SAAUC,GACzCF,eAAeE,EAAEC,QACjB,GAELL,EAAOM,QAEyB,MAA5Bb,EAAuB,gBAAWO,EAAOO,2BAA6BV,OAAsB"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ui-select-genomespace.js","sources":["../../../src/mvc/ui/ui-select-genomespace.js"],"names":["define","Utils","Ui","GenomespaceBrowser","View","Backbone","extend","initialize","options","self","this","browse_button","ButtonIcon","title","icon","tooltip","onclick","browseGenomeSpace","filename_textbox","Input","token_textbox","type","setElement","_template","$","append","$el","openFileBrowser","successCallback","data","value","destination","token","new_value","undefined","_getValue","_setValue","values","split"],"mappings":"AACAA,QAAQ,cAAe,iBAAkB,6BACjC,SAASC,EAAOC,EAAIC,GAK5B,GAAIC,GAAOC,SAASD,KAAKE,QAErBC,WAAa,SAASC,GAGlB,GAAIC,GAAOC,IAGXA,MAAKC,cAAgB,GAAIT,GAAGU,YACxBC,MAAc,SACdC,KAAc,gBACdC,QAAc,qBACdC,QAAc,WACVP,EAAKQ,uBAKbP,KAAKQ,iBAAmB,GAAIhB,GAAGiB,MAG/BT,KAAKU,cAAgB,GAAIlB,GAAGiB,OAC1BE,KAAa,aAIfX,KAAKY,WAAWZ,KAAKa,UAAUf,IAC/BE,KAAKc,EAAE,wBAAwBC,OAAOf,KAAKC,cAAce,KACzDhB,KAAKc,EAAE,2BAA2BC,OAAOf,KAAKQ,iBAAiBQ,KAC/DhB,KAAKc,EAAE,wBAAwBC,OAAOf,KAAKU,cAAcM,MAI7DT,kBAAmB,WACf,GAAIR,GAAOC,IACXP,GAAmBwB,iBACfC,gBAAiB,SAASC,GACtBpB,EAAKqB,MAAMD,EAAKE,YAAc,IAAMF,EAAKG,WAMrDT,UAAW,WACP,MAAQ,6SAaZO,MAAQ,SAAUG,GAEd,MAAkBC,UAAdD,EAIKvB,KAAKyB,gBAHVzB,MAAK0B,UAAUH,IAQvBE,UAAW,WACP,MAAOzB,MAAKQ,iBAAiBY,QACzB,IAAMpB,KAAKU,cAAcU,SAIjCM,UAAW,SAASH,GACZA,IACFI,OAASJ,EAAUK,MAAM,KACzB5B,KAAKQ,iBAAiBY,MAAMO,OAAO,IACnC3B,KAAKU,cAAcU,MAAMO,OAAO,OAM1C,QACIjC,KAAMA"}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
webpackJsonp([5],[function(e,i,n){(function(e,i){var a=n(1),t=a,r=n(49).GalaxyApp,o=n(6),l=n(50);window.app=function(n,c){window.Galaxy=new r(n,c),Galaxy.debug("login app");var p=encodeURI(n.redirect);if(!n.show_welcome_with_login){var d=a.param({use_panels:"True",redirect:p});return void(window.location.href=Galaxy.root+"user/login?"+d)}var w=e.View.extend({initialize:function(i){this.page=i,this.model=new e.Model({title:o("Login required")}),this.setElement(this._template())},render:function(){this.page.$("#galaxy_main").prop("src",n.welcome_url)},_template:function(){var e=n.root+"user/login?"+t.param({redirect:p});return'<iframe src="'+e+'" frameborder="0" style="width: 100%; height: 100%;"/>'}});t(function(){Galaxy.page=new l.View(i.extend(n,{Right:w}))})}}).call(i,n(2),n(3))}]);
|
||||
webpackJsonp([5],[function(e,i,n){(function(e,i){var a=n(1),t=a,r=n(51).GalaxyApp,o=n(6),l=n(52);window.app=function(n,c){window.Galaxy=new r(n,c),Galaxy.debug("login app");var p=encodeURI(n.redirect);if(!n.show_welcome_with_login){var d=a.param({use_panels:"True",redirect:p});return void(window.location.href=Galaxy.root+"user/login?"+d)}var w=e.View.extend({initialize:function(i){this.page=i,this.model=new e.Model({title:o("Login required")}),this.setElement(this._template())},render:function(){this.page.$("#galaxy_main").prop("src",n.welcome_url)},_template:function(){var e=n.root+"user/login?"+t.param({redirect:p});return'<iframe src="'+e+'" frameborder="0" style="width: 100%; height: 100%;"/>'}});t(function(){Galaxy.page=new l.View(i.extend(n,{Right:w}))})}}).call(i,n(2),n(3))}]);
|
||||
//# sourceMappingURL=login.bundled.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["webpack:///login.bundled.js","webpack:///./galaxy/scripts/apps/login.js"],"names":["webpackJsonp","module","exports","__webpack_require__","Backbone","_","jQuery","$","GalaxyApp","_l","Page","window","app","options","bootstrapped","Galaxy","debug","redirect","encodeURI","show_welcome_with_login","params","param","use_panels","location","href","root","LoginPage","View","extend","initialize","page","this","model","Model","title","setElement","_template","render","prop","welcome_url","login_url","Right","call"],"mappings":"AAAAA,cAAc,IAER,SAAUC,EAAQC,EAASC,ICFjC,SAAAC,EAAAC,GAAA,GAAIC,GAASH,EAAS,GAClBI,EAAID,EACJE,EAAYL,EAAS,IAAWK,UAChCC,EAAKN,EAAS,GACdO,EAAOP,EAAS,GAEpBQ,QAAOC,IAAM,SAAcC,EAASC,GAChCH,OAAOI,OAAS,GAAIP,GAAWK,EAASC,GACxCC,OAAOC,MAAO,YACd,IAAIC,GAAWC,UAAWL,EAAQI,SAIlC,KAAKJ,EAAQM,wBAAyB,CAClC,GAAIC,GAASd,EAAOe,OAAQC,WAAa,OAAQL,SAAWA,GAE5D,aADAN,OAAOY,SAASC,KAAOT,OAAOU,KAAO,cAAgBL,GAIzD,GAAIM,GAAYtB,EAASuB,KAAKC,QAC1BC,WAAY,SAAUC,GAClBC,KAAKD,KAAOA,EACZC,KAAKC,MAAQ,GAAI5B,GAAS6B,OAAQC,MAAQzB,EAAI,oBAC9CsB,KAAKI,WAAYJ,KAAKK,cAE1BC,OAAQ,WACJN,KAAKD,KAAKvB,EAAG,gBAAiB+B,KAAM,MAAOzB,EAAQ0B,cAEvDH,UAAY,WACR,GAAII,GAAY3B,EAAQY,KAAO,cAAgBlB,EAAEc,OAASJ,SAAWA,GACrE,OAAO,gBAAkBuB,EAAY,2DAI7CjC,GAAE,WACEQ,OAAOe,KAAO,GAAIpB,GAAKiB,KAAMtB,EAAEuB,OAAQf,GACnC4B,MAAQf,UDQUgB,KAAKxC,EAASC,EAAoB,GAAIA,EAAoB","file":"login.bundled.js","sourcesContent":["webpackJsonp([5],[\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Backbone, _) {var jQuery = __webpack_require__(1),\n\t $ = jQuery,\n\t GalaxyApp = __webpack_require__(49).GalaxyApp,\n\t _l = __webpack_require__(6),\n\t Page = __webpack_require__(50);\n\t\n\twindow.app = function app(options, bootstrapped) {\n\t window.Galaxy = new GalaxyApp(options, bootstrapped);\n\t Galaxy.debug('login app');\n\t var redirect = encodeURI(options.redirect);\n\t\n\t // TODO: remove iframe for user login (at least) and render login page from here\n\t // then remove this redirect\n\t if (!options.show_welcome_with_login) {\n\t var params = jQuery.param({ use_panels: 'True', redirect: redirect });\n\t window.location.href = Galaxy.root + 'user/login?' + params;\n\t return;\n\t }\n\t\n\t var LoginPage = Backbone.View.extend({\n\t initialize: function (page) {\n\t this.page = page;\n\t this.model = new Backbone.Model({ title: _l('Login required') });\n\t this.setElement(this._template());\n\t },\n\t render: function () {\n\t this.page.$('#galaxy_main').prop('src', options.welcome_url);\n\t },\n\t _template: function () {\n\t var login_url = options.root + 'user/login?' + $.param({ redirect: redirect });\n\t return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n\t }\n\t });\n\t\n\t $(function () {\n\t Galaxy.page = new Page.View(_.extend(options, {\n\t Right: LoginPage\n\t }));\n\t });\n\t};\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(3)))\n\n/***/ })\n]);\n\n\n// WEBPACK FOOTER //\n// login.bundled.js","var jQuery = require( 'jquery' ),\n $ = jQuery,\n GalaxyApp = require( 'galaxy' ).GalaxyApp,\n _l = require( 'utils/localization' ),\n Page = require( 'layout/page' );\n\nwindow.app = function app( options, bootstrapped ){\n window.Galaxy = new GalaxyApp( options, bootstrapped );\n Galaxy.debug( 'login app' );\n var redirect = encodeURI( options.redirect );\n\n // TODO: remove iframe for user login (at least) and render login page from here\n // then remove this redirect\n if( !options.show_welcome_with_login ){\n var params = jQuery.param({ use_panels : 'True', redirect : redirect });\n window.location.href = Galaxy.root + 'user/login?' + params;\n return;\n }\n\n var LoginPage = Backbone.View.extend({\n initialize: function( page ) {\n this.page = page;\n this.model = new Backbone.Model({ title : _l( 'Login required' ) } );\n this.setElement( this._template() );\n },\n render: function() {\n this.page.$( '#galaxy_main' ).prop( 'src', options.welcome_url );\n },\n _template : function() {\n var login_url = options.root + 'user/login?' + $.param( { redirect : redirect } );\n return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n }\n });\n\n $(function(){\n Galaxy.page = new Page.View( _.extend( options, {\n Right : LoginPage\n } ) );\n });\n};\n\n\n\n// WEBPACK FOOTER //\n// ./galaxy/scripts/apps/login.js"],"sourceRoot":""}
|
||||
{"version":3,"sources":["webpack:///login.bundled.js","webpack:///./galaxy/scripts/apps/login.js"],"names":["webpackJsonp","module","exports","__webpack_require__","Backbone","_","jQuery","$","GalaxyApp","_l","Page","window","app","options","bootstrapped","Galaxy","debug","redirect","encodeURI","show_welcome_with_login","params","param","use_panels","location","href","root","LoginPage","View","extend","initialize","page","this","model","Model","title","setElement","_template","render","prop","welcome_url","login_url","Right","call"],"mappings":"AAAAA,cAAc,IAER,SAAUC,EAAQC,EAASC,ICFjC,SAAAC,EAAAC,GAAA,GAAIC,GAASH,EAAS,GAClBI,EAAID,EACJE,EAAYL,EAAS,IAAWK,UAChCC,EAAKN,EAAS,GACdO,EAAOP,EAAS,GAEpBQ,QAAOC,IAAM,SAAcC,EAASC,GAChCH,OAAOI,OAAS,GAAIP,GAAWK,EAASC,GACxCC,OAAOC,MAAO,YACd,IAAIC,GAAWC,UAAWL,EAAQI,SAIlC,KAAKJ,EAAQM,wBAAyB,CAClC,GAAIC,GAASd,EAAOe,OAAQC,WAAa,OAAQL,SAAWA,GAE5D,aADAN,OAAOY,SAASC,KAAOT,OAAOU,KAAO,cAAgBL,GAIzD,GAAIM,GAAYtB,EAASuB,KAAKC,QAC1BC,WAAY,SAAUC,GAClBC,KAAKD,KAAOA,EACZC,KAAKC,MAAQ,GAAI5B,GAAS6B,OAAQC,MAAQzB,EAAI,oBAC9CsB,KAAKI,WAAYJ,KAAKK,cAE1BC,OAAQ,WACJN,KAAKD,KAAKvB,EAAG,gBAAiB+B,KAAM,MAAOzB,EAAQ0B,cAEvDH,UAAY,WACR,GAAII,GAAY3B,EAAQY,KAAO,cAAgBlB,EAAEc,OAASJ,SAAWA,GACrE,OAAO,gBAAkBuB,EAAY,2DAI7CjC,GAAE,WACEQ,OAAOe,KAAO,GAAIpB,GAAKiB,KAAMtB,EAAEuB,OAAQf,GACnC4B,MAAQf,UDQUgB,KAAKxC,EAASC,EAAoB,GAAIA,EAAoB","file":"login.bundled.js","sourcesContent":["webpackJsonp([5],[\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Backbone, _) {var jQuery = __webpack_require__(1),\n\t $ = jQuery,\n\t GalaxyApp = __webpack_require__(51).GalaxyApp,\n\t _l = __webpack_require__(6),\n\t Page = __webpack_require__(52);\n\t\n\twindow.app = function app(options, bootstrapped) {\n\t window.Galaxy = new GalaxyApp(options, bootstrapped);\n\t Galaxy.debug('login app');\n\t var redirect = encodeURI(options.redirect);\n\t\n\t // TODO: remove iframe for user login (at least) and render login page from here\n\t // then remove this redirect\n\t if (!options.show_welcome_with_login) {\n\t var params = jQuery.param({ use_panels: 'True', redirect: redirect });\n\t window.location.href = Galaxy.root + 'user/login?' + params;\n\t return;\n\t }\n\t\n\t var LoginPage = Backbone.View.extend({\n\t initialize: function (page) {\n\t this.page = page;\n\t this.model = new Backbone.Model({ title: _l('Login required') });\n\t this.setElement(this._template());\n\t },\n\t render: function () {\n\t this.page.$('#galaxy_main').prop('src', options.welcome_url);\n\t },\n\t _template: function () {\n\t var login_url = options.root + 'user/login?' + $.param({ redirect: redirect });\n\t return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n\t }\n\t });\n\t\n\t $(function () {\n\t Galaxy.page = new Page.View(_.extend(options, {\n\t Right: LoginPage\n\t }));\n\t });\n\t};\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(3)))\n\n/***/ })\n]);\n\n\n// WEBPACK FOOTER //\n// login.bundled.js","var jQuery = require( 'jquery' ),\n $ = jQuery,\n GalaxyApp = require( 'galaxy' ).GalaxyApp,\n _l = require( 'utils/localization' ),\n Page = require( 'layout/page' );\n\nwindow.app = function app( options, bootstrapped ){\n window.Galaxy = new GalaxyApp( options, bootstrapped );\n Galaxy.debug( 'login app' );\n var redirect = encodeURI( options.redirect );\n\n // TODO: remove iframe for user login (at least) and render login page from here\n // then remove this redirect\n if( !options.show_welcome_with_login ){\n var params = jQuery.param({ use_panels : 'True', redirect : redirect });\n window.location.href = Galaxy.root + 'user/login?' + params;\n return;\n }\n\n var LoginPage = Backbone.View.extend({\n initialize: function( page ) {\n this.page = page;\n this.model = new Backbone.Model({ title : _l( 'Login required' ) } );\n this.setElement( this._template() );\n },\n render: function() {\n this.page.$( '#galaxy_main' ).prop( 'src', options.welcome_url );\n },\n _template : function() {\n var login_url = options.root + 'user/login?' + $.param( { redirect : redirect } );\n return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n }\n });\n\n $(function(){\n Galaxy.page = new Page.View( _.extend( options, {\n Right : LoginPage\n } ) );\n });\n};\n\n\n\n// WEBPACK FOOTER //\n// ./galaxy/scripts/apps/login.js"],"sourceRoot":""}
|
||||
@@ -1,2 +1,2 @@
|
||||
define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-select-content","mvc/ui/ui-select-library","mvc/ui/ui-select-ftp","mvc/ui/ui-color-picker"],function(a,b,c,d,e,f){return Backbone.Model.extend({types:{text:"_fieldText",password:"_fieldText",select:"_fieldSelect",data_column:"_fieldSelect",genomebuild:"_fieldSelect",data:"_fieldData",data_collection:"_fieldData",integer:"_fieldSlider","float":"_fieldSlider","boolean":"_fieldBoolean",drill_down:"_fieldDrilldown",color:"_fieldColor",hidden:"_fieldHidden",hidden_data:"_fieldHidden",baseurl:"_fieldHidden",library_data:"_fieldLibrary",ftpfile:"_fieldFtp",upload:"_fieldUpload"},create:function(a){var b=this.types[a.type],c="function"==typeof this[b]?this[b].call(this,a):null;return c||(c=a.options?this._fieldSelect(a):this._fieldText(a),Galaxy.emit.debug("form-parameters::_addRow()","Auto matched field type ("+a.type+").")),void 0===a.value&&(a.value=null),c.value(a.value),c},_fieldData:function(a){return new c.View({id:"field-"+a.id,extensions:a.extensions,optional:a.optional,multiple:a.multiple,type:a.type,flavor:a.flavor,data:a.options,onchange:a.onchange})},_fieldSelect:function(a){if(a.is_workflow)return this._fieldText(a);"data_column"==a.type&&(a.error_text="Missing columns in referenced dataset.");var c=a.data;c||(c=[],_.each(a.options,function(a){c.push({label:a[0],value:a[1]})}));var d=b.Select;switch(a.display){case"checkboxes":d=b.Checkbox;break;case"radio":d=b.Radio;break;case"radiobutton":d=b.RadioButton}return new d.View({id:"field-"+a.id,data:c,error_text:a.error_text||"No options available",multiple:a.multiple,optional:a.optional,onchange:a.onchange,individual:a.individual,searchable:"workflow"!==a.flavor})},_fieldDrilldown:function(a){return a.is_workflow?this._fieldText(a):new b.Drilldown.View({id:"field-"+a.id,data:a.options,display:a.display,optional:a.optional,onchange:a.onchange})},_fieldText:function(c){if(c.options&&c.data)if(c.area=c.multiple,a.isEmpty(c.value))c.value=null;else if($.isArray(c.value)){var d="";for(var e in c.value){if(d+=String(c.value[e]),!c.multiple)break;d+="\n"}c.value=d}return new b.Input({id:"field-"+c.id,type:c.type,area:c.area,readonly:c.readonly,placeholder:c.placeholder,datalist:c.datalist,onchange:c.onchange})},_fieldSlider:function(a){return new b.Slider.View({id:"field-"+a.id,precise:"float"==a.type,is_workflow:a.is_workflow,min:a.min,max:a.max,onchange:a.onchange})},_fieldHidden:function(a){return new b.Hidden({id:"field-"+a.id,info:a.info})},_fieldBoolean:function(a){return new b.RadioButton.View({id:"field-"+a.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}],onchange:a.onchange})},_fieldColor:function(a){return new f({id:"field-"+a.id,onchange:a.onchange})},_fieldLibrary:function(a){return new d.View({id:"field-"+a.id,optional:a.optional,multiple:a.multiple,onchange:a.onchange})},_fieldFtp:function(a){return new e.View({id:"field-"+a.id,optional:a.optional,multiple:a.multiple,onchange:a.onchange})},_fieldUpload:function(a){return new b.Upload({id:"field-"+a.id,onchange:a.onchange})}})});
|
||||
define(["utils/utils","mvc/ui/ui-misc","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(a,b,c,d,e,f,g){return Backbone.Model.extend({types:{text:"_fieldText",password:"_fieldText",select:"_fieldSelect",data_column:"_fieldSelect",genomebuild:"_fieldSelect",data:"_fieldData",data_collection:"_fieldData",integer:"_fieldSlider","float":"_fieldSlider","boolean":"_fieldBoolean",drill_down:"_fieldDrilldown",color:"_fieldColor",hidden:"_fieldHidden",hidden_data:"_fieldHidden",baseurl:"_fieldHidden",library_data:"_fieldLibrary",ftpfile:"_fieldFtp",upload:"_fieldUpload",genomespacefile:"_fieldGenomeSpace"},create:function(a){var b=this.types[a.type],c="function"==typeof this[b]?this[b].call(this,a):null;return c||(c=a.options?this._fieldSelect(a):this._fieldText(a),Galaxy.emit.debug("form-parameters::_addRow()","Auto matched field type ("+a.type+").")),void 0===a.value&&(a.value=null),c.value(a.value),c},_fieldData:function(a){return new c.View({id:"field-"+a.id,extensions:a.extensions,optional:a.optional,multiple:a.multiple,type:a.type,flavor:a.flavor,data:a.options,onchange:a.onchange})},_fieldSelect:function(a){if(a.is_workflow)return this._fieldText(a);"data_column"==a.type&&(a.error_text="Missing columns in referenced dataset.");var c=a.data;c||(c=[],_.each(a.options,function(a){c.push({label:a[0],value:a[1]})}));var d=b.Select;switch(a.display){case"checkboxes":d=b.Checkbox;break;case"radio":d=b.Radio;break;case"radiobutton":d=b.RadioButton}return new d.View({id:"field-"+a.id,data:c,error_text:a.error_text||"No options available",multiple:a.multiple,optional:a.optional,onchange:a.onchange,individual:a.individual,searchable:"workflow"!==a.flavor})},_fieldDrilldown:function(a){return a.is_workflow?this._fieldText(a):new b.Drilldown.View({id:"field-"+a.id,data:a.options,display:a.display,optional:a.optional,onchange:a.onchange})},_fieldText:function(c){if(c.options&&c.data)if(c.area=c.multiple,a.isEmpty(c.value))c.value=null;else if($.isArray(c.value)){var d="";for(var e in c.value){if(d+=String(c.value[e]),!c.multiple)break;d+="\n"}c.value=d}return new b.Input({id:"field-"+c.id,type:c.type,area:c.area,readonly:c.readonly,placeholder:c.placeholder,datalist:c.datalist,onchange:c.onchange})},_fieldSlider:function(a){return new b.Slider.View({id:"field-"+a.id,precise:"float"==a.type,is_workflow:a.is_workflow,min:a.min,max:a.max,onchange:a.onchange})},_fieldHidden:function(a){return new b.Hidden({id:"field-"+a.id,info:a.info})},_fieldBoolean:function(a){return new b.RadioButton.View({id:"field-"+a.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}],onchange:a.onchange})},_fieldColor:function(a){return new g({id:"field-"+a.id,onchange:a.onchange})},_fieldLibrary:function(a){return new d.View({id:"field-"+a.id,optional:a.optional,multiple:a.multiple,onchange:a.onchange})},_fieldFtp:function(a){return new e.View({id:"field-"+a.id,optional:a.optional,multiple:a.multiple,onchange:a.onchange})},_fieldGenomeSpace:function(a){var b=this;return new f.View({id:"field-"+a.id,onchange:function(){b.app.trigger("change")}})},_fieldUpload:function(a){return new b.Upload({id:"field-"+a.id,onchange:a.onchange})}})});
|
||||
//# sourceMappingURL=../../../maps/mvc/form/form-parameters.js.map
|
||||
@@ -0,0 +1,2 @@
|
||||
define([],function(){return{openFileBrowser:function(a){var b=window.Galaxy.config.genomespace_ui_url,c=b+"upload/loadUrlToGenomespace.html?getLocation=true",d=window.open(c,"GenomeSpace File Browser","height=360px,width=600px");successCalBack=a.successCallback,window.addEventListener("message",function(a){successCalBack(a.data)},!1),d.focus(),null!=a.errorCallback&&(d.setCallbackOnGSUploadError=config.errorCallback)}}});
|
||||
//# sourceMappingURL=../../../maps/mvc/tool/tool-genomespace.js.map
|
||||
@@ -0,0 +1,2 @@
|
||||
define(["utils/utils","mvc/ui/ui-misc","mvc/tool/tool-genomespace"],function(a,b,c){var d=Backbone.View.extend({initialize:function(a){var c=this;this.browse_button=new b.ButtonIcon({title:"Browse",icon:"fa fa-sign-in",tooltip:"Browse GenomeSpace",onclick:function(){c.browseGenomeSpace()}}),this.filename_textbox=new b.Input,this.token_textbox=new b.Input({type:"password"}),this.setElement(this._template(a)),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)},browseGenomeSpace:function(){var a=this;c.openFileBrowser({successCallback:function(b){a.value(b.destination+"^"+b.token)}})},_template:function(){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>'},value:function(a){return void 0===a?this._getValue():void this._setValue(a)},_getValue:function(){return this.filename_textbox.value()+"^"+this.token_textbox.value()},_setValue:function(a){a&&(values=a.split("^"),this.filename_textbox.value(values[0]),this.token_textbox.value(values[1]))}});return{View:d}});
|
||||
//# sourceMappingURL=../../../maps/mvc/ui/ui-select-genomespace.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,334 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# Dan Blankenberg
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
import argparse
|
||||
import binascii
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import tempfile
|
||||
import sys
|
||||
|
||||
import six
|
||||
from six.moves import http_cookiejar
|
||||
from six.moves.urllib.error import HTTPError
|
||||
from six.moves.urllib.parse import quote, urlencode, urljoin
|
||||
from six.moves.urllib.request import build_opener, HTTPCookieProcessor, Request, urlopen
|
||||
|
||||
log = logging.getLogger("tools.genomespace.genomespace_exporter")
|
||||
|
||||
try:
|
||||
import boto
|
||||
from boto.s3.connection import S3Connection
|
||||
except ImportError:
|
||||
boto = None
|
||||
|
||||
GENOMESPACE_API_VERSION_STRING = "v1.0"
|
||||
GENOMESPACE_SERVER_URL_PROPERTIES = "https://dm.genomespace.org/config/%s/serverurl.properties" % (GENOMESPACE_API_VERSION_STRING)
|
||||
DEFAULT_GENOMESPACE_TOOLNAME = 'Galaxy'
|
||||
|
||||
CHUNK_SIZE = 2 ** 20 # 1mb
|
||||
|
||||
# TODO: TARGET_SPLIT_SIZE and TARGET_SIMPLE_PUT_UPLOAD_SIZE are arbitrarily defined
|
||||
# we should programmatically determine these, based upon the current environment
|
||||
TARGET_SPLIT_SIZE = 250 * 1024 * 1024 # 250 mb
|
||||
MIN_MULTIPART_UPLOAD_SIZE = 5 * 1024 * 1024 # 5mb
|
||||
MAX_SIMPLE_PUT_UPLOAD_SIZE = 5 * 1024 * 1024 * 1024 # 5gb
|
||||
TARGET_SIMPLE_PUT_UPLOAD_SIZE = MAX_SIMPLE_PUT_UPLOAD_SIZE / 2
|
||||
|
||||
# Some basic Caching, so we don't have to reload and download everything every time,
|
||||
# especially now that we are calling the parameter's get options method 5 times
|
||||
# (6 on reload) when a user loads the tool interface
|
||||
# For now, we'll use 30 seconds as the cache valid time
|
||||
CACHE_TIME = datetime.timedelta(seconds=30)
|
||||
GENOMESPACE_DIRECTORIES_BY_USER = {}
|
||||
from genomespaceclient import GenomeSpaceClient
|
||||
|
||||
|
||||
def chunk_write(source_stream, target_stream, source_method="read", target_method="write"):
|
||||
source_method = getattr(source_stream, source_method)
|
||||
target_method = getattr(target_stream, target_method)
|
||||
while True:
|
||||
chunk = source_method(CHUNK_SIZE)
|
||||
if chunk:
|
||||
target_method(chunk)
|
||||
else:
|
||||
break
|
||||
def upload_to_genomespace(token, input_file, target_url):
|
||||
token = token or os.environ.get('GS_TOKEN')
|
||||
gs_client = GenomeSpaceClient(token=token)
|
||||
gs_client.copy(input_file, target_url)
|
||||
print("File successfully copied.")
|
||||
|
||||
|
||||
def get_cookie_opener(gs_username, gs_token, gs_toolname=None):
|
||||
""" Create a GenomeSpace cookie opener """
|
||||
cj = http_cookiejar.CookieJar()
|
||||
for cookie_name, cookie_value in [('gs-token', gs_token), ('gs-username', gs_username)]:
|
||||
# create a super-cookie, valid for all domains
|
||||
cookie = http_cookiejar.Cookie(version=0, name=cookie_name, value=cookie_value, port=None, port_specified=False, domain='', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False)
|
||||
cj.set_cookie(cookie)
|
||||
cookie_opener = build_opener(HTTPCookieProcessor(cj))
|
||||
cookie_opener.addheaders.append(('gs-toolname', gs_toolname or DEFAULT_GENOMESPACE_TOOLNAME))
|
||||
return cookie_opener
|
||||
def process_args(args):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-i', '--input_file', type=str,
|
||||
help="File to export", required=True)
|
||||
parser.add_argument('-o', '--target_url', type=str,
|
||||
help="GenomeSpace output target folder location", required=True)
|
||||
parser.add_argument('-t', '--token', type=str,
|
||||
help="Optional OpenID/GenomeSpace token if not passed in as part of the URL as URLs^Token."
|
||||
" If none, the environment variable GS_TOKEN will be respected.", required=False)
|
||||
|
||||
args = parser.parse_args(args[1:])
|
||||
return args
|
||||
|
||||
|
||||
def get_genomespace_site_urls():
|
||||
genomespace_sites = {}
|
||||
for line in urlopen(GENOMESPACE_SERVER_URL_PROPERTIES).read().split('\n'):
|
||||
line = line.rstrip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
server, line = line.split('.', 1)
|
||||
if server not in genomespace_sites:
|
||||
genomespace_sites[server] = {}
|
||||
line = line.split("=", 1)
|
||||
genomespace_sites[server][line[0]] = line[1]
|
||||
return genomespace_sites
|
||||
def main():
|
||||
args = process_args(sys.argv)
|
||||
upload_to_genomespace(args.token,
|
||||
binascii.unhexlify(args.input_file).decode('utf-8'),
|
||||
binascii.unhexlify(args.target_url).decode('utf-8'))
|
||||
|
||||
|
||||
def get_directory(url_opener, dm_url, path):
|
||||
url = dm_url
|
||||
i = None
|
||||
dir_dict = {}
|
||||
for i, sub_path in enumerate(path):
|
||||
url = "%s/%s" % (url, sub_path)
|
||||
dir_request = Request(url, headers={'Content-Type': 'application/json', 'Accept': 'application/json'})
|
||||
dir_request.get_method = lambda: 'GET'
|
||||
try:
|
||||
dir_dict = json.loads(url_opener.open(dir_request).read())
|
||||
except HTTPError:
|
||||
# print "e", e, url #punting, assuming lack of permissions at this low of a level...
|
||||
continue
|
||||
break
|
||||
if i is not None:
|
||||
path = path[i + 1:]
|
||||
else:
|
||||
path = []
|
||||
return (dir_dict, path)
|
||||
|
||||
|
||||
def get_default_directory(url_opener, dm_url):
|
||||
return get_directory(url_opener, dm_url, ["%s/defaultdirectory" % (GENOMESPACE_API_VERSION_STRING)])[0]
|
||||
|
||||
|
||||
def get_personal_directory(url_opener, dm_url):
|
||||
return get_directory(url_opener, dm_url, ["%s/personaldirectory" % (GENOMESPACE_API_VERSION_STRING)])[0]
|
||||
|
||||
|
||||
def create_directory(url_opener, directory_dict, new_dir, dm_url):
|
||||
payload = {"isDirectory": True}
|
||||
for dir_slice in new_dir:
|
||||
if dir_slice in ('', '/', None):
|
||||
continue
|
||||
url = '/'.join((directory_dict['url'], quote(dir_slice.replace('/', '_'), safe='')))
|
||||
new_dir_request = Request(url, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, data=json.dumps(payload))
|
||||
new_dir_request.get_method = lambda: 'PUT'
|
||||
directory_dict = json.loads(url_opener.open(new_dir_request).read())
|
||||
return directory_dict
|
||||
|
||||
|
||||
def get_genome_space_launch_apps(atm_url, url_opener, file_url, file_type):
|
||||
gs_request = Request("%s/%s/webtool/descriptor" % (atm_url, GENOMESPACE_API_VERSION_STRING))
|
||||
gs_request.get_method = lambda: 'GET'
|
||||
opened_gs_request = url_opener.open(gs_request)
|
||||
webtool_descriptors = json.loads(opened_gs_request.read())
|
||||
webtools = []
|
||||
for webtool in webtool_descriptors:
|
||||
webtool_name = webtool.get('name')
|
||||
base_url = webtool.get('baseUrl')
|
||||
use_tool = False
|
||||
for param in webtool.get('fileParameters', []):
|
||||
for format in param.get('formats', []):
|
||||
if format.get('name') == file_type:
|
||||
use_tool = True
|
||||
break
|
||||
if use_tool:
|
||||
file_param_name = param.get('name')
|
||||
# file_name_delimiters = param.get( 'nameDelimiters' )
|
||||
if '?' in base_url:
|
||||
url_delimiter = "&"
|
||||
else:
|
||||
url_delimiter = "?"
|
||||
launch_url = "%s%s%s" % (base_url, url_delimiter, urlencode([(file_param_name, file_url)]))
|
||||
webtools.append((launch_url, webtool_name))
|
||||
break
|
||||
return webtools
|
||||
|
||||
|
||||
def galaxy_code_get_genomespace_folders(genomespace_site='prod', trans=None, value=None, base_url=None, **kwd):
|
||||
if value:
|
||||
if isinstance(value, list):
|
||||
value = value[0] # single select, only 1 value
|
||||
elif not isinstance(value, six.string_types):
|
||||
# unvalidated value
|
||||
value = value.value
|
||||
if isinstance(value, list):
|
||||
value = value[0] # single select, only 1 value
|
||||
|
||||
def recurse_directory_dict(url_opener, cur_options, url):
|
||||
cur_directory = Request(url, headers={'Content-Type': 'application/json', 'Accept': 'application/json, text/plain'})
|
||||
cur_directory.get_method = lambda: 'GET'
|
||||
# get url to upload to
|
||||
try:
|
||||
cur_directory = url_opener.open(cur_directory).read()
|
||||
except HTTPError as e:
|
||||
log.debug('GenomeSpace export tool failed reading a directory "%s": %s' % (url, e))
|
||||
return # bad url, go to next
|
||||
cur_directory = json.loads(cur_directory)
|
||||
directory = cur_directory.get('directory', {})
|
||||
contents = cur_directory.get('contents', [])
|
||||
if directory.get('isDirectory', False):
|
||||
selected = directory.get('path') == value
|
||||
cur_options.append({'name': directory.get('name'), 'value': directory.get('path'), 'options': [], 'selected': selected})
|
||||
for sub_dir in contents:
|
||||
if sub_dir.get('isDirectory', False):
|
||||
recurse_directory_dict(url_opener, cur_options[-1]['options'], sub_dir.get('url'))
|
||||
|
||||
rval = []
|
||||
if trans and trans.user:
|
||||
username = trans.user.preferences.get('genomespace_username', None)
|
||||
token = trans.user.preferences.get('genomespace_token', None)
|
||||
if None not in (username, token):
|
||||
# NB: it is possible, but unlikely for a user to swap GenomeSpace accounts around
|
||||
# in the middle of interacting with tools, so we'll have several layers of caching by ids/values
|
||||
if trans.user in GENOMESPACE_DIRECTORIES_BY_USER:
|
||||
if username in GENOMESPACE_DIRECTORIES_BY_USER[trans.user]:
|
||||
if token in GENOMESPACE_DIRECTORIES_BY_USER[trans.user][username]:
|
||||
cache_dict = GENOMESPACE_DIRECTORIES_BY_USER[trans.user][username][token]
|
||||
if datetime.datetime.now() - cache_dict.get('time_loaded') > CACHE_TIME:
|
||||
# cache too old, need to reload, we'll just kill the whole trans.user
|
||||
del GENOMESPACE_DIRECTORIES_BY_USER[trans.user]
|
||||
else:
|
||||
rval = cache_dict.get('rval')
|
||||
else:
|
||||
del GENOMESPACE_DIRECTORIES_BY_USER[trans.user]
|
||||
else:
|
||||
del GENOMESPACE_DIRECTORIES_BY_USER[trans.user]
|
||||
if not rval:
|
||||
url_opener = get_cookie_opener(username, token, gs_toolname=os.environ.get('GENOMESPACE_TOOLNAME', None))
|
||||
genomespace_site_dict = get_genomespace_site_urls()[genomespace_site]
|
||||
dm_url = genomespace_site_dict['dmServer']
|
||||
# get export root directory
|
||||
# directory_dict = get_default_directory( url_opener, dm_url ).get( 'directory', None ) #This directory contains shares and other items outside of the users home
|
||||
directory_dict = get_personal_directory(url_opener, dm_url).get('directory', None) # Limit export list to only user's home dir
|
||||
if directory_dict is not None:
|
||||
recurse_directory_dict(url_opener, rval, directory_dict.get('url'))
|
||||
# Save the cache
|
||||
GENOMESPACE_DIRECTORIES_BY_USER[trans.user] = {username: {token: {'time_loaded': datetime.datetime.now(), 'rval': rval}}}
|
||||
if not rval:
|
||||
if not base_url:
|
||||
base_url = '..'
|
||||
rval = [{'name': 'Your GenomeSpace token appears to be <strong>expired</strong>, please <a href="%s">reauthenticate</a>.' % (urljoin(base_url, 'user/openid_auth?openid_provider=genomespace&auto_associate=True')), 'value': '', 'options': [], 'selected': False}]
|
||||
return rval
|
||||
|
||||
|
||||
def send_file_to_genomespace(genomespace_site, username, token, source_filename, target_directory, target_filename, file_type, content_type, log_filename, gs_toolname):
|
||||
target_filename = target_filename.replace('/', '-') # Slashes no longer allowed in filenames
|
||||
url_opener = get_cookie_opener(username, token, gs_toolname=gs_toolname)
|
||||
genomespace_site_dict = get_genomespace_site_urls()[genomespace_site]
|
||||
dm_url = genomespace_site_dict['dmServer']
|
||||
# get default directory
|
||||
if target_directory and target_directory[0] == '/':
|
||||
directory_dict, target_directory = get_directory(url_opener, dm_url, ["%s/%s/%s" % (GENOMESPACE_API_VERSION_STRING, 'file', target_directory[1])] + target_directory[2:])
|
||||
directory_dict = directory_dict['directory']
|
||||
else:
|
||||
directory_dict = get_personal_directory(url_opener, dm_url)['directory'] # this is the base for the auto-generated galaxy export directories
|
||||
# what directory to stuff this in
|
||||
target_directory_dict = create_directory(url_opener, directory_dict, target_directory, dm_url)
|
||||
content_length = os.path.getsize(source_filename)
|
||||
input_file = open(source_filename, 'rb')
|
||||
if content_length > TARGET_SIMPLE_PUT_UPLOAD_SIZE:
|
||||
# Determine sizes of each part.
|
||||
split_count = content_length / TARGET_SPLIT_SIZE
|
||||
last_size = content_length - (split_count * TARGET_SPLIT_SIZE)
|
||||
sizes = [TARGET_SPLIT_SIZE] * split_count
|
||||
if last_size:
|
||||
if last_size < MIN_MULTIPART_UPLOAD_SIZE:
|
||||
if sizes:
|
||||
sizes[-1] = sizes[-1] + last_size
|
||||
else:
|
||||
sizes = [last_size]
|
||||
else:
|
||||
sizes.append(last_size)
|
||||
print("Performing multi-part upload in %i parts." % (len(sizes)))
|
||||
# get upload url
|
||||
upload_url = "uploadinfo"
|
||||
upload_url = "%s/%s/%s%s/%s" % (dm_url, GENOMESPACE_API_VERSION_STRING, upload_url, target_directory_dict['path'], quote(target_filename, safe=''))
|
||||
upload_request = Request(upload_url, headers={'Content-Type': 'application/json', 'Accept': 'application/json'})
|
||||
upload_request.get_method = lambda: 'GET'
|
||||
upload_info = json.loads(url_opener.open(upload_request).read())
|
||||
conn = S3Connection(aws_access_key_id=upload_info['amazonCredentials']['accessKey'],
|
||||
aws_secret_access_key=upload_info['amazonCredentials']['secretKey'],
|
||||
security_token=upload_info['amazonCredentials']['sessionToken'])
|
||||
# Cannot use conn.get_bucket due to permissions, manually create bucket object
|
||||
bucket = boto.s3.bucket.Bucket(connection=conn, name=upload_info['s3BucketName'])
|
||||
mp = bucket.initiate_multipart_upload(upload_info['s3ObjectKey'])
|
||||
for i, part_size in enumerate(sizes, start=1):
|
||||
fh = tempfile.TemporaryFile('wb+')
|
||||
while part_size:
|
||||
if CHUNK_SIZE > part_size:
|
||||
read_size = part_size
|
||||
else:
|
||||
read_size = CHUNK_SIZE
|
||||
chunk = input_file.read(read_size)
|
||||
fh.write(chunk)
|
||||
part_size = part_size - read_size
|
||||
fh.flush()
|
||||
fh.seek(0)
|
||||
mp.upload_part_from_file(fh, i)
|
||||
fh.close()
|
||||
upload_result = mp.complete_upload()
|
||||
else:
|
||||
print('Performing simple put upload.')
|
||||
upload_url = "uploadurl"
|
||||
content_md5 = hashlib.md5()
|
||||
chunk_write(input_file, content_md5, target_method="update")
|
||||
input_file.seek(0) # back to start, for uploading
|
||||
|
||||
upload_params = {'Content-Length': content_length, 'Content-MD5': base64.standard_b64encode(content_md5.digest()), 'Content-Type': content_type}
|
||||
upload_url = "%s/%s/%s%s/%s?%s" % (dm_url, GENOMESPACE_API_VERSION_STRING, upload_url, target_directory_dict['path'], quote(target_filename, safe=''), urlencode(upload_params))
|
||||
new_file_request = Request(upload_url) # , headers = { 'Content-Type': 'application/json', 'Accept': 'application/text' } ) #apparently http://www.genomespace.org/team/specs/updated-dm-rest-api:"Every HTTP request to the Data Manager should include the Accept header with a preference for the media types application/json and application/text." is not correct
|
||||
new_file_request.get_method = lambda: 'GET'
|
||||
# get url to upload to
|
||||
target_upload_url = url_opener.open(new_file_request).read()
|
||||
# upload file to determined url
|
||||
upload_headers = dict(upload_params)
|
||||
# upload_headers[ 'x-amz-meta-md5-hash' ] = content_md5.hexdigest()
|
||||
upload_headers['Accept'] = 'application/json'
|
||||
upload_file_request = Request(target_upload_url, headers=upload_headers, data=input_file)
|
||||
upload_file_request.get_method = lambda: 'PUT'
|
||||
upload_result = urlopen(upload_file_request).read()
|
||||
result_url = "%s/%s" % (target_directory_dict['url'], quote(target_filename, safe=''))
|
||||
# determine available gs launch apps
|
||||
web_tools = get_genome_space_launch_apps(genomespace_site_dict['atmServer'], url_opener, result_url, file_type)
|
||||
if log_filename:
|
||||
log_file = open(log_filename, 'wb')
|
||||
log_file.write("<html><head><title>File uploaded to GenomeSpace from Galaxy</title></head><body>\n")
|
||||
log_file.write('<p>Uploaded <a href="%s">%s/%s</a> to GenomeSpace.</p>\n' % (result_url, target_directory_dict['path'], target_filename))
|
||||
if web_tools:
|
||||
log_file.write("<p>You may open this file directly in the following applications:</p>\n")
|
||||
log_file.write('<p><ul>\n')
|
||||
for web_tool in web_tools:
|
||||
log_file.write('<li><a href="%s">%s</a></li>\n' % (web_tool))
|
||||
log_file.write('</p></ul>\n')
|
||||
else:
|
||||
log_file.write('<p>There are no GenomeSpace applications available for file type: %s</p>\n' % (file_type))
|
||||
log_file.write("</body></html>\n")
|
||||
return upload_result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Parse Command Line
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-s', '--genomespace_site', dest='genomespace_site', action='store', type="string", default=None, help='genomespace_site')
|
||||
parser.add_option('-t', '--token', dest='token', action='store', type="string", default=None, help='token')
|
||||
parser.add_option('-u', '--username', dest='username', action='store', type="string", default=None, help='username')
|
||||
parser.add_option('-d', '--dataset', dest='dataset', action='store', type="string", default=None, help='dataset')
|
||||
parser.add_option('-f', '--filename', dest='filename', action='store', type="string", default=None, help='filename')
|
||||
parser.add_option('-y', '--subdirectory', dest='subdirectory', action='append', type="string", default=None, help='subdirectory')
|
||||
parser.add_option('', '--file_type', dest='file_type', action='store', type="string", default=None, help='file_type')
|
||||
parser.add_option('-c', '--content_type', dest='content_type', action='store', type="string", default=None, help='content_type')
|
||||
parser.add_option('-l', '--log', dest='log', action='store', type="string", default=None, help='log')
|
||||
parser.add_option('', '--genomespace_toolname', dest='genomespace_toolname', action='store', type="string", default=DEFAULT_GENOMESPACE_TOOLNAME, help='value to use for gs-toolname, used in GenomeSpace internal logging')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
send_file_to_genomespace(options.genomespace_site, options.username, options.token, options.dataset, [binascii.unhexlify(_) for _ in options.subdirectory], binascii.unhexlify(options.filename), options.file_type, options.content_type, options.log, options.genomespace_toolname)
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
@@ -1,54 +1,44 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace Exporter" id="genomespace_exporter" require_login="True" version="0.0.4">
|
||||
<tool name="GenomeSpace Exporter" id="genomespace_exporter" version="0.0.5">
|
||||
<description> - send data to GenomeSpace</description>
|
||||
<command interpreter="python">genomespace_exporter.py
|
||||
--genomespace_site "prod"
|
||||
#assert $__user__, Exception( 'You must be logged in to use this tool.' )
|
||||
#set $username = $__user__.preferences.get( 'genomespace_username', None )
|
||||
#set $token = $__user__.preferences.get( 'genomespace_token', None )
|
||||
#assert None not in ( $username, $token ), Exception( 'You must associate a GenomeSpace OpenID with your account and log in with it.' )
|
||||
<environment_variables>
|
||||
<environment_variable name="GS_TOKEN">
|
||||
#set $token = $genomespace_browser.split('^')[1] or $__user__.preferences.get('genomespace_token', None)
|
||||
#assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID or select a valid folder via the GenomeSpace browse dialog.')
|
||||
$token
|
||||
</environment_variable>
|
||||
</environment_variables>
|
||||
<command>python $__tool_directory__/genomespace_exporter.py
|
||||
#set $target_folder = $genomespace_browser.split('^')[0]
|
||||
#assert $target_folder, Exception('You must select a valid target folder.')
|
||||
|
||||
#import binascii
|
||||
--username "${username}"
|
||||
--token "${token}"
|
||||
--dataset "${input1}"
|
||||
#if $subdirectory:
|
||||
#for $subd in str( $subdirectory ).split( '/' ):
|
||||
#if not $subd:
|
||||
--subdirectory "${ binascii.hexlify( '/' ) }"
|
||||
#else:
|
||||
--subdirectory "${ binascii.hexlify( $subd ) }"
|
||||
#end if
|
||||
#end for
|
||||
#else:
|
||||
--subdirectory "${ binascii.hexlify( 'galaxy_export' ) }"
|
||||
--subdirectory "${ binascii.hexlify( str( $base_url ).split( '://', 1 )[-1] ) }" ##Protocol removed by request
|
||||
#end if
|
||||
--input_file '${ binascii.hexlify(str($input1).encode("utf8")) }'
|
||||
#if $filename:
|
||||
--filename "${ binascii.hexlify( str( $filename ) ) }"
|
||||
--target_url '${ binascii.hexlify(str($target_folder + "/" + str($filename)).encode("utf8") ) }'
|
||||
#else:
|
||||
--filename "${ binascii.hexlify( "Galaxy History Item %s (%s) - %s: %s.%s" % ( $__app__.security.encode_id( $input1.id ), $__app__.security.encode_id( $output_log.id ), $input1.hid, $input1.name, $input1.ext ) ) }"
|
||||
--target_url '${ binascii.hexlify(($target_folder + "/" + "Galaxy History Item %s (%s) - %s: %s.%s" % ($__app__.security.encode_id($input1.id), $__app__.security.encode_id($output_log.id), $input1.hid, $input1.element_identifier.replace("/", "_"), $input1.ext)).encode("utf8")) }'
|
||||
#end if
|
||||
--file_type "${input1.ext}"
|
||||
--content_type "${input1.get_mime()}"
|
||||
--log "${output_log}"
|
||||
--genomespace_toolname="\${GENOMESPACE_TOOLNAME:-Galaxy}"
|
||||
</command>
|
||||
<inputs>
|
||||
<param format="data" name="input1" type="data" label="Send this dataset to GenomeSpace" />
|
||||
<param name="base_url" type="baseurl" />
|
||||
<param name="subdirectory" type="drill_down" display="radio" hierarchy="exact" multiple="False" optional="True" label="Choose Target Directory" dynamic_options="galaxy_code_get_genomespace_folders( genomespace_site = 'prod', trans=__trans__, value=__value__, input_dataset=input1, base_url=base_url )" help="Leave blank to generate automatically"/>
|
||||
<param name="filename" type="text" size="80" label="Filename" help="Leave blank to generate automatically" />
|
||||
<!-- If using this tool through bioblend, the genomespace_browser parameter should contain the path to the GenomeSpaceFile + the security token
|
||||
separated by a ^ as follows: GenomeSpaceFilePath^Token -->
|
||||
<param name="genomespace_browser" type="genomespacefile" label="Choose Target Directory" select_type="FOLDER" />
|
||||
<param name="filename" type="text" label="Filename" help="Leave blank to generate automatically" />
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="html" name="output_log" />
|
||||
<data format="auto" name="output_log" />
|
||||
</outputs>
|
||||
<help>
|
||||
This Tool allows you to export data to GenomeSpace. You must have logged in using your GenomeSpace OpenID. You can associate your OpenID credentials under the User Preferences panel.
|
||||
This Tool allows you to export data to GenomeSpace. Click the Browse button to select a file to export. The tool will automatically
|
||||
fetch your GenomeSpace token when you select a file from the export dialog.
|
||||
|
||||
If you are having trouble with this tool, click here_ to refresh your GenomeSpace token before reporting errors.
|
||||
Alternatively, you can be logged in using your GenomeSpace OpenID, and the tool will use this ID if no token is entered.
|
||||
This allows you to simply paste the filepath into the location box and leave the token empty.
|
||||
You can associate your OpenID credentials under the User Preferences panel.
|
||||
Click here_ to refresh your GenomeSpace token.
|
||||
|
||||
.. _here: ${static_path}/../user/openid_auth?openid_provider=genomespace&auto_associate=True
|
||||
</help>
|
||||
<options refresh="True"/>
|
||||
<code file="genomespace_exporter.py" />
|
||||
</tool>
|
||||
|
||||
@@ -1,217 +0,0 @@
|
||||
# Dan Blankenberg
|
||||
import json
|
||||
import optparse
|
||||
import os
|
||||
|
||||
from six.moves import http_cookiejar
|
||||
from six.moves.urllib.parse import unquote_plus, urlencode, urlparse
|
||||
from six.moves.urllib.request import build_opener, HTTPCookieProcessor, Request, urlopen
|
||||
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy.datatypes.registry import Registry
|
||||
|
||||
GENOMESPACE_API_VERSION_STRING = "v1.0"
|
||||
GENOMESPACE_SERVER_URL_PROPERTIES = "https://dm.genomespace.org/config/%s/serverurl.properties" % (GENOMESPACE_API_VERSION_STRING)
|
||||
DEFAULT_GENOMESPACE_TOOLNAME = 'Galaxy'
|
||||
FILENAME_VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
|
||||
|
||||
CHUNK_SIZE = 2**20 # 1mb
|
||||
|
||||
AUTO_GALAXY_EXT = "auto"
|
||||
DEFAULT_GALAXY_EXT = "data"
|
||||
|
||||
# genomespace format identifier is the URL
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT = {} # TODO: fix this so it is not a global variable
|
||||
# TODO: we should use a better way to set up this mapping
|
||||
GENOMESPACE_EXT_TO_GALAXY_EXT = {'rifles': 'rifles',
|
||||
'lifes': 'lifes',
|
||||
'cn': 'cn',
|
||||
'GTF': 'gtf',
|
||||
'res': 'res',
|
||||
'xcn': 'xcn',
|
||||
'lowercasetxt': 'lowercasetxt',
|
||||
'bed': 'bed',
|
||||
'CBS': 'cbs',
|
||||
'genomicatab': 'genomicatab',
|
||||
'gxp': 'gxp',
|
||||
'reversedtxt': 'reversedtxt',
|
||||
'nowhitespace': 'nowhitespace',
|
||||
'unknown': 'unknown',
|
||||
'txt': 'txt',
|
||||
'uppercasetxt': 'uppercasetxt',
|
||||
'GISTIC': 'gistic',
|
||||
'GFF': 'gff',
|
||||
'gmt': 'gmt',
|
||||
'gct': 'gct'}
|
||||
|
||||
GENOMESPACE_UNKNOWN_FORMAT_KEY = 'unknown'
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_UNKNOWN = None
|
||||
|
||||
|
||||
def chunk_write(source_stream, target_stream, source_method="read", target_method="write"):
|
||||
source_method = getattr(source_stream, source_method)
|
||||
target_method = getattr(target_stream, target_method)
|
||||
while True:
|
||||
chunk = source_method(CHUNK_SIZE)
|
||||
if chunk:
|
||||
target_method(chunk)
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
def get_cookie_opener(gs_username, gs_token, gs_toolname=None):
|
||||
""" Create a GenomeSpace cookie opener """
|
||||
cj = http_cookiejar.CookieJar()
|
||||
for cookie_name, cookie_value in [('gs-token', gs_token), ('gs-username', gs_username)]:
|
||||
# create a super-cookie, valid for all domains
|
||||
cookie = http_cookiejar.Cookie(version=0, name=cookie_name, value=cookie_value, port=None, port_specified=False, domain='', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False)
|
||||
cj.set_cookie(cookie)
|
||||
cookie_opener = build_opener(HTTPCookieProcessor(cj))
|
||||
cookie_opener.addheaders.append(('gs-toolname', gs_toolname or DEFAULT_GENOMESPACE_TOOLNAME))
|
||||
return cookie_opener
|
||||
|
||||
|
||||
def get_galaxy_ext_from_genomespace_format_url(url_opener, file_format_url):
|
||||
ext = GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT.get(file_format_url, None)
|
||||
if ext is not None:
|
||||
ext = GENOMESPACE_EXT_TO_GALAXY_EXT.get(ext, None)
|
||||
if ext is None:
|
||||
# could check content type, etc here
|
||||
ext = AUTO_GALAXY_EXT
|
||||
return ext
|
||||
|
||||
|
||||
def get_genomespace_site_urls():
|
||||
genomespace_sites = {}
|
||||
for line in urlopen(GENOMESPACE_SERVER_URL_PROPERTIES).read().split('\n'):
|
||||
line = line.rstrip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
server, line = line.split('.', 1)
|
||||
if server not in genomespace_sites:
|
||||
genomespace_sites[server] = {}
|
||||
line = line.split("=", 1)
|
||||
genomespace_sites[server][line[0]] = line[1]
|
||||
return genomespace_sites
|
||||
|
||||
|
||||
def set_genomespace_format_identifiers(url_opener, dm_site):
|
||||
gs_request = Request("%s/%s/dataformat/list" % (dm_site, GENOMESPACE_API_VERSION_STRING))
|
||||
gs_request.get_method = lambda: 'GET'
|
||||
opened_gs_request = url_opener.open(gs_request)
|
||||
genomespace_formats = json.loads(opened_gs_request.read())
|
||||
for format in genomespace_formats:
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT[format['url']] = format['name']
|
||||
global GENOMESPACE_FORMAT_IDENTIFIER_UNKNOWN
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_UNKNOWN = dict((x[1], x[0]) for x in GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT.items()).get(GENOMESPACE_UNKNOWN_FORMAT_KEY, GENOMESPACE_FORMAT_IDENTIFIER_UNKNOWN)
|
||||
|
||||
|
||||
def download_from_genomespace_file_browser(json_parameter_file, genomespace_site, gs_toolname):
|
||||
json_params = json.loads(open(json_parameter_file, 'r').read())
|
||||
datasource_params = json_params.get('param_dict')
|
||||
username = datasource_params.get("gs-username", None)
|
||||
token = datasource_params.get("gs-token", None)
|
||||
assert None not in [username, token], "Missing GenomeSpace username or token."
|
||||
output_filename = datasource_params.get("output", None)
|
||||
dataset_id = json_params['output_data'][0]['dataset_id']
|
||||
hda_id = json_params['output_data'][0]['hda_id']
|
||||
url_opener = get_cookie_opener(username, token, gs_toolname=gs_toolname)
|
||||
# load and set genomespace format ids to galaxy exts
|
||||
genomespace_site_dict = get_genomespace_site_urls()[genomespace_site]
|
||||
set_genomespace_format_identifiers(url_opener, genomespace_site_dict['dmServer'])
|
||||
|
||||
file_url_prefix = "fileUrl"
|
||||
file_type_prefix = "fileFormat"
|
||||
metadata_parameter_file = open(json_params['job_config']['TOOL_PROVIDED_JOB_METADATA_FILE'], 'wb')
|
||||
|
||||
# setup datatypes registry for sniffing
|
||||
datatypes_registry = Registry()
|
||||
datatypes_registry.load_datatypes(root_dir=json_params['job_config']['GALAXY_ROOT_DIR'], config=json_params['job_config']['GALAXY_DATATYPES_CONF_FILE'])
|
||||
|
||||
file_numbers = []
|
||||
for name in datasource_params.keys():
|
||||
if name.startswith(file_url_prefix):
|
||||
name = name[len(file_url_prefix):]
|
||||
file_numbers.append(int(name))
|
||||
if not file_numbers:
|
||||
if output_filename:
|
||||
open(output_filename, 'wb') # erase contents of file
|
||||
raise Exception("You must select at least one file to import into Galaxy.")
|
||||
file_numbers.sort()
|
||||
used_filenames = []
|
||||
for file_num in file_numbers:
|
||||
url_key = "%s%i" % (file_url_prefix, file_num)
|
||||
download_url = datasource_params.get(url_key, None)
|
||||
if download_url is None:
|
||||
break
|
||||
filetype_key = "%s%i" % (file_type_prefix, file_num)
|
||||
filetype_url = datasource_params.get(filetype_key, None)
|
||||
galaxy_ext = get_galaxy_ext_from_genomespace_format_url(url_opener, filetype_url)
|
||||
formatted_download_url = "%s?%s" % (download_url, urlencode([('dataformat', filetype_url)]))
|
||||
new_file_request = Request(formatted_download_url)
|
||||
new_file_request.get_method = lambda: 'GET'
|
||||
target_download_url = url_opener.open(new_file_request)
|
||||
filename = None
|
||||
if 'Content-Disposition' in target_download_url.info():
|
||||
# If the response has Content-Disposition, try to get filename from it
|
||||
content_disposition = dict(x.strip().split('=') if '=' in x else (x.strip(), '') for x in target_download_url.info()['Content-Disposition'].split(';'))
|
||||
if 'filename' in content_disposition:
|
||||
filename = content_disposition['filename'].strip("\"'")
|
||||
if not filename:
|
||||
parsed_url = urlparse(download_url)
|
||||
filename = unquote_plus(parsed_url[2].split('/')[-1])
|
||||
if not filename:
|
||||
filename = download_url
|
||||
metadata_dict = None
|
||||
original_filename = filename
|
||||
if output_filename is None:
|
||||
filename = ''.join(c in FILENAME_VALID_CHARS and c or '-' for c in filename)
|
||||
while filename in used_filenames:
|
||||
filename = "-%s" % filename
|
||||
used_filenames.append(filename)
|
||||
output_filename = os.path.join(os.getcwd(), 'primary_%i_%s_visible_%s' % (hda_id, filename, galaxy_ext))
|
||||
|
||||
metadata_dict = dict(type='new_primary_dataset',
|
||||
base_dataset_id=dataset_id,
|
||||
ext=galaxy_ext,
|
||||
filename=output_filename,
|
||||
name="GenomeSpace import on %s" % (original_filename))
|
||||
else:
|
||||
if dataset_id is not None:
|
||||
metadata_dict = dict(type='dataset',
|
||||
dataset_id=dataset_id,
|
||||
ext=galaxy_ext,
|
||||
name="GenomeSpace import on %s" % (filename))
|
||||
output_file = open(output_filename, 'wb')
|
||||
chunk_write(target_download_url, output_file)
|
||||
output_file.close()
|
||||
|
||||
if (galaxy_ext == AUTO_GALAXY_EXT or filetype_url == GENOMESPACE_FORMAT_IDENTIFIER_UNKNOWN) and metadata_dict:
|
||||
# try to sniff datatype
|
||||
try:
|
||||
galaxy_ext = sniff.handle_uploaded_dataset_file(output_filename, datatypes_registry)
|
||||
except:
|
||||
# sniff failed
|
||||
galaxy_ext = original_filename.rsplit('.', 1)[-1]
|
||||
if galaxy_ext not in datatypes_registry.datatypes_by_extension:
|
||||
galaxy_ext = DEFAULT_GALAXY_EXT
|
||||
metadata_dict['ext'] = galaxy_ext
|
||||
|
||||
output_filename = None # only have one filename available
|
||||
|
||||
# write out metadata info
|
||||
if metadata_dict:
|
||||
metadata_parameter_file.write("%s\n" % json.dumps(metadata_dict))
|
||||
|
||||
metadata_parameter_file.close()
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-p', '--json_parameter_file', dest='json_parameter_file', action='store', type="string", default=None, help='json_parameter_file')
|
||||
parser.add_option('-s', '--genomespace_site', dest='genomespace_site', action='store', type="string", default=None, help='genomespace_site')
|
||||
parser.add_option('', '--genomespace_toolname', dest='genomespace_toolname', action='store', type="string", default=DEFAULT_GENOMESPACE_TOOLNAME, help='value to use for gs-toolname, used in GenomeSpace internal logging')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
download_from_genomespace_file_browser(options.json_parameter_file, options.genomespace_site, options.genomespace_toolname)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace import" id="genomespace_file_browser_dev" tool_type="data_source" add_galaxy_url="False" force_history_refresh="True" version="0.0.1">
|
||||
<description>from file browser (development)</description>
|
||||
<command interpreter="python">genomespace_file_browser.py --json_parameter_file "${output}" --genomespace_site "dev" --genomespace_toolname="\${GENOMESPACE_TOOLNAME:-Galaxy}"</command>
|
||||
<inputs action="https://dmdev.genomespace.org:8444/datamanager/defaultdirectory" check_values="False" method="post">
|
||||
<display>go to GenomeSpace Data Manager </display>
|
||||
<param name="appCallbackUrl" type="baseurl" value="/tool_runner?tool_id=genomespace_file_browser_dev&runtool_btn=Execute" />
|
||||
<param name="appName" type="hidden" value="Galaxy" />
|
||||
</inputs>
|
||||
<uihints minwidth="800"/>
|
||||
<outputs>
|
||||
<data name="output" format="auto" />
|
||||
</outputs>
|
||||
<options sanitize="False" refresh="True"/>
|
||||
</tool>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace import" id="genomespace_file_browser_prod" tool_type="data_source" add_galaxy_url="False" force_history_refresh="True" version="0.0.1">
|
||||
<description>from file browser</description>
|
||||
<command interpreter="python">genomespace_file_browser.py --json_parameter_file "${output}" --genomespace_site "prod" --genomespace_toolname="\${GENOMESPACE_TOOLNAME:-Galaxy}"</command>
|
||||
<inputs action="https://dm.genomespace.org/datamanager/defaultdirectory" check_values="False" method="post">
|
||||
<display>go to GenomeSpace Data Manager </display>
|
||||
<param name="appCallbackUrl" type="baseurl" value="/tool_runner?tool_id=genomespace_file_browser_prod&runtool_btn=Execute" />
|
||||
<param name="appName" type="hidden" value="Galaxy" />
|
||||
</inputs>
|
||||
<uihints minwidth="800"/>
|
||||
<outputs>
|
||||
<data name="output" format="auto" />
|
||||
</outputs>
|
||||
<options sanitize="False" refresh="True"/>
|
||||
</tool>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace import" id="genomespace_file_browser_test" tool_type="data_source" add_galaxy_url="False" force_history_refresh="True" version="0.0.1">
|
||||
<description>from file browser (test)</description>
|
||||
<command interpreter="python">genomespace_file_browser.py --json_parameter_file "${output}" --genomespace_site "test" --genomespace_toolname="\${GENOMESPACE_TOOLNAME:-Galaxy}"</command>
|
||||
<inputs action="https://dmtest.genomespace.org:8444/datamanager/defaultdirectory" check_values="False" method="post">
|
||||
<display>go to GenomeSpace Data Manager </display>
|
||||
<param name="appCallbackUrl" type="baseurl" value="/tool_runner?tool_id=genomespace_file_browser_test&runtool_btn=Execute" />
|
||||
<param name="appName" type="hidden" value="Galaxy" />
|
||||
</inputs>
|
||||
<uihints minwidth="800"/>
|
||||
<outputs>
|
||||
<data name="output" format="auto" />
|
||||
</outputs>
|
||||
<options sanitize="False" refresh="True"/>
|
||||
</tool>
|
||||
@@ -1,39 +1,26 @@
|
||||
# Dan Blankenberg
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import optparse
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from six.moves import http_cookiejar
|
||||
from six.moves.urllib.parse import parse_qs, unquote_plus, urlparse
|
||||
from six.moves.urllib.request import build_opener, HTTPCookieProcessor, Request, urlopen
|
||||
from genomespaceclient import GenomeSpaceClient
|
||||
|
||||
import galaxy
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy.datatypes.registry import Registry
|
||||
|
||||
GENOMESPACE_API_VERSION_STRING = "v1.0"
|
||||
GENOMESPACE_SERVER_URL_PROPERTIES = "https://dm.genomespace.org/config/%s/serverurl.properties" % (GENOMESPACE_API_VERSION_STRING)
|
||||
DEFAULT_GENOMESPACE_TOOLNAME = 'Galaxy'
|
||||
FILENAME_VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
|
||||
|
||||
CHUNK_SIZE = 2**20 # 1mb
|
||||
|
||||
DEFAULT_GALAXY_EXT = "data"
|
||||
|
||||
# genomespace format identifier is the URL
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT = {} # TODO: fix this so it is not a global variable
|
||||
# TODO: we should use a better way to set up this mapping
|
||||
# Mappings for known genomespace formats to galaxy formats
|
||||
GENOMESPACE_EXT_TO_GALAXY_EXT = {'rifles': 'rifles',
|
||||
'lifes': 'lifes',
|
||||
'cn': 'cn',
|
||||
'GTF': 'gtf',
|
||||
'gtf': 'gtf',
|
||||
'res': 'res',
|
||||
'xcn': 'xcn',
|
||||
'lowercasetxt': 'lowercasetxt',
|
||||
'bed': 'bed',
|
||||
'CBS': 'cbs',
|
||||
'cbs': 'cbs',
|
||||
'genomicatab': 'genomicatab',
|
||||
'gxp': 'gxp',
|
||||
'reversedtxt': 'reversedtxt',
|
||||
@@ -41,180 +28,233 @@ GENOMESPACE_EXT_TO_GALAXY_EXT = {'rifles': 'rifles',
|
||||
'unknown': 'unknown',
|
||||
'txt': 'txt',
|
||||
'uppercasetxt': 'uppercasetxt',
|
||||
'GISTIC': 'gistic',
|
||||
'GFF': 'gff',
|
||||
'gistic': 'gistic',
|
||||
'gff': 'gff',
|
||||
'gmt': 'gmt',
|
||||
'gct': 'gct'}
|
||||
|
||||
|
||||
def chunk_write(source_stream, target_stream, source_method="read", target_method="write"):
|
||||
source_method = getattr(source_stream, source_method)
|
||||
target_method = getattr(target_stream, target_method)
|
||||
while True:
|
||||
chunk = source_method(CHUNK_SIZE)
|
||||
if chunk:
|
||||
target_method(chunk)
|
||||
def _prepare_json_list(param_list):
|
||||
"""
|
||||
JSON serialization Support functions for exec_before_job hook
|
||||
"""
|
||||
rval = []
|
||||
for value in param_list:
|
||||
if isinstance(value, dict):
|
||||
rval.append(_prepare_json_param_dict(value))
|
||||
elif isinstance(value, list):
|
||||
rval.append(_prepare_json_list(value))
|
||||
else:
|
||||
break
|
||||
rval.append(str(value))
|
||||
return rval
|
||||
|
||||
|
||||
def get_cookie_opener(gs_username, gs_token, gs_toolname=None):
|
||||
""" Create a GenomeSpace cookie opener """
|
||||
cj = http_cookiejar.CookieJar()
|
||||
for cookie_name, cookie_value in [('gs-token', gs_token), ('gs-username', gs_username)]:
|
||||
# create a super-cookie, valid for all domains
|
||||
cookie = http_cookiejar.Cookie(version=0, name=cookie_name, value=cookie_value, port=None, port_specified=False, domain='', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False)
|
||||
cj.set_cookie(cookie)
|
||||
cookie_opener = build_opener(HTTPCookieProcessor(cj))
|
||||
cookie_opener.addheaders.append(('gs-toolname', gs_toolname or DEFAULT_GENOMESPACE_TOOLNAME))
|
||||
return cookie_opener
|
||||
|
||||
|
||||
def get_galaxy_ext_from_genomespace_format_url(url_opener, file_format_url, default=DEFAULT_GALAXY_EXT):
|
||||
ext = GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT.get(file_format_url, None)
|
||||
if ext is not None:
|
||||
ext = GENOMESPACE_EXT_TO_GALAXY_EXT.get(ext, None)
|
||||
if ext is None:
|
||||
# could check content type, etc here
|
||||
ext = default
|
||||
return ext
|
||||
|
||||
|
||||
def get_genomespace_site_urls():
|
||||
genomespace_sites = {}
|
||||
for line in urlopen(GENOMESPACE_SERVER_URL_PROPERTIES).read().split('\n'):
|
||||
line = line.rstrip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
server, line = line.split('.', 1)
|
||||
if server not in genomespace_sites:
|
||||
genomespace_sites[server] = {}
|
||||
line = line.split("=", 1)
|
||||
genomespace_sites[server][line[0]] = line[1]
|
||||
return genomespace_sites
|
||||
|
||||
|
||||
def set_genomespace_format_identifiers(url_opener, dm_site):
|
||||
gs_request = Request("%s/%s/dataformat/list" % (dm_site, GENOMESPACE_API_VERSION_STRING))
|
||||
gs_request.get_method = lambda: 'GET'
|
||||
opened_gs_request = url_opener.open(gs_request)
|
||||
genomespace_formats = json.loads(opened_gs_request.read())
|
||||
for format in genomespace_formats:
|
||||
GENOMESPACE_FORMAT_IDENTIFIER_TO_GENOMESPACE_EXT[format['url']] = format['name']
|
||||
|
||||
|
||||
def download_from_genomespace_importer(username, token, json_parameter_file, genomespace_site, gs_toolname):
|
||||
json_params = json.loads(open(json_parameter_file, 'r').read())
|
||||
datasource_params = json_params.get('param_dict')
|
||||
assert None not in [username, token], "Missing GenomeSpace username or token."
|
||||
output_filename = datasource_params.get("output_file1", None)
|
||||
dataset_id = base_dataset_id = json_params['output_data'][0]['dataset_id']
|
||||
hda_id = json_params['output_data'][0]['hda_id']
|
||||
url_opener = get_cookie_opener(username, token, gs_toolname=gs_toolname)
|
||||
# load and set genomespace format ids to galaxy exts
|
||||
genomespace_site_dict = get_genomespace_site_urls()[genomespace_site]
|
||||
set_genomespace_format_identifiers(url_opener, genomespace_site_dict['dmServer'])
|
||||
file_url_name = "URL"
|
||||
metadata_parameter_file = open(json_params['job_config']['TOOL_PROVIDED_JOB_METADATA_FILE'], 'wb')
|
||||
# setup datatypes registry for sniffing
|
||||
datatypes_registry = Registry()
|
||||
datatypes_registry.load_datatypes(root_dir=json_params['job_config']['GALAXY_ROOT_DIR'], config=json_params['job_config']['GALAXY_DATATYPES_CONF_FILE'])
|
||||
url_param = datasource_params.get(file_url_name, None)
|
||||
used_filenames = []
|
||||
for download_url in url_param.split(','):
|
||||
using_temp_file = False
|
||||
parsed_url = urlparse(download_url)
|
||||
query_params = parse_qs(parsed_url[4])
|
||||
# write file to disk
|
||||
new_file_request = Request(download_url)
|
||||
new_file_request.get_method = lambda: 'GET'
|
||||
target_download_url = url_opener.open(new_file_request)
|
||||
filename = None
|
||||
if 'Content-Disposition' in target_download_url.info():
|
||||
content_disposition = dict(x.strip().split('=') if '=' in x else (x.strip(), '') for x in target_download_url.info()['Content-Disposition'].split(';'))
|
||||
if 'filename' in content_disposition:
|
||||
filename = content_disposition['filename'].strip("\"'")
|
||||
if not filename:
|
||||
parsed_url = urlparse(download_url)
|
||||
query_params = parse_qs(parsed_url[4])
|
||||
filename = unquote_plus(parsed_url[2].split('/')[-1])
|
||||
if not filename:
|
||||
filename = download_url
|
||||
if output_filename is None:
|
||||
# need to use a temp file here, because we do not know the ext yet
|
||||
using_temp_file = True
|
||||
output_filename = tempfile.NamedTemporaryFile(prefix='tmp-genomespace-importer-').name
|
||||
output_file = open(output_filename, 'wb')
|
||||
chunk_write(target_download_url, output_file)
|
||||
output_file.close()
|
||||
|
||||
# determine file format
|
||||
file_type = None
|
||||
if 'dataformat' in query_params: # this is a converted dataset
|
||||
file_type = query_params['dataformat'][0]
|
||||
file_type = get_galaxy_ext_from_genomespace_format_url(url_opener, file_type)
|
||||
def _prepare_json_param_dict(param_dict):
|
||||
"""
|
||||
JSON serialization Support functions for exec_before_job hook
|
||||
"""
|
||||
rval = {}
|
||||
for key, value in param_dict.iteritems():
|
||||
if isinstance(value, dict):
|
||||
rval[key] = _prepare_json_param_dict(value)
|
||||
elif isinstance(value, list):
|
||||
rval[key] = _prepare_json_list(value)
|
||||
else:
|
||||
try:
|
||||
# get and use GSMetadata object
|
||||
download_file_path = download_url.split("%s/file/" % (genomespace_site_dict['dmServer']), 1)[-1] # FIXME: This is a very bad way to get the path for determining metadata. There needs to be a way to query API using download URLto get to the metadata object
|
||||
metadata_request = Request("%s/%s/filemetadata/%s" % (genomespace_site_dict['dmServer'], GENOMESPACE_API_VERSION_STRING, download_file_path))
|
||||
metadata_request.get_method = lambda: 'GET'
|
||||
metadata_url = url_opener.open(metadata_request)
|
||||
file_metadata_dict = json.loads(metadata_url.read())
|
||||
metadata_url.close()
|
||||
file_type = file_metadata_dict.get('dataFormat', None)
|
||||
if file_type and file_type.get('url'):
|
||||
file_type = file_type.get('url')
|
||||
file_type = get_galaxy_ext_from_genomespace_format_url(url_opener, file_type, default=None)
|
||||
except:
|
||||
pass
|
||||
if file_type is None:
|
||||
# try to sniff datatype
|
||||
try:
|
||||
file_type = sniff.handle_uploaded_dataset_file(output_filename, datatypes_registry)
|
||||
except:
|
||||
pass # sniff failed
|
||||
if file_type is None and '.' in parsed_url[2]:
|
||||
# still no known datatype, fall back to using extension
|
||||
file_type = parsed_url[2].rsplit('.', 1)[-1]
|
||||
file_type = GENOMESPACE_EXT_TO_GALAXY_EXT.get(file_type, file_type)
|
||||
if file_type is None:
|
||||
# use default extension (e.g. 'data')
|
||||
file_type = DEFAULT_GALAXY_EXT
|
||||
rval[key] = str(value)
|
||||
return rval
|
||||
|
||||
# save json info for single primary dataset
|
||||
if dataset_id is not None:
|
||||
|
||||
def exec_before_job(app, inp_data, out_data, param_dict=None, tool=None):
|
||||
"""
|
||||
Galaxy override hook
|
||||
See: https://wiki.galaxyproject.org/Admin/Tools/ToolConfigSyntax#A.3Ccode.3E_tag_set
|
||||
Since only tools with tool_type="data_source" provides functionality for having a JSON param file such as this:
|
||||
https://wiki.galaxyproject.org/Admin/Tools/DataManagers/DataManagerJSONSyntax#Example_JSON_input_to_tool,
|
||||
this hook is used to manually create a similar JSON file.
|
||||
However, this hook does not provide access to GALAXY_DATATYPES_CONF_FILE and GALAXY_ROOT_DIR
|
||||
properties, so these must be passed in as commandline params.
|
||||
"""
|
||||
if param_dict is None:
|
||||
param_dict = {}
|
||||
json_params = {}
|
||||
json_params['param_dict'] = _prepare_json_param_dict(param_dict)
|
||||
json_params['output_data'] = []
|
||||
json_params['job_config'] = dict(GALAXY_DATATYPES_CONF_FILE=param_dict.get('GALAXY_DATATYPES_CONF_FILE'),
|
||||
GALAXY_ROOT_DIR=param_dict.get('GALAXY_ROOT_DIR'),
|
||||
TOOL_PROVIDED_JOB_METADATA_FILE=galaxy.jobs.TOOL_PROVIDED_JOB_METADATA_FILE)
|
||||
json_filename = None
|
||||
for i, (out_name, data) in enumerate(out_data.iteritems()):
|
||||
file_name = data.get_file_name()
|
||||
data_dict = dict(out_data_name=out_name,
|
||||
ext=data.ext,
|
||||
dataset_id=data.dataset.id,
|
||||
hda_id=data.id,
|
||||
file_name=file_name)
|
||||
json_params['output_data'].append(data_dict)
|
||||
if json_filename is None:
|
||||
json_filename = file_name
|
||||
with open(json_filename, 'w') as out:
|
||||
out.write(json.dumps(json_params))
|
||||
|
||||
|
||||
def get_galaxy_ext_from_genomespace_format(format):
|
||||
return GENOMESPACE_EXT_TO_GALAXY_EXT.get(format, None)
|
||||
|
||||
|
||||
def get_galaxy_ext_from_file_ext(filename):
|
||||
if not filename:
|
||||
return None
|
||||
filename = filename.lower()
|
||||
ext = filename.rsplit('.', 1)[-1]
|
||||
return get_galaxy_ext_from_genomespace_format(ext)
|
||||
|
||||
|
||||
def sniff_and_handle_data_type(json_params, output_file):
|
||||
"""
|
||||
The sniff.handle_uploaded_dataset_file() method in Galaxy performs dual
|
||||
functions: it sniffs the filetype and if it's a compressed archive for
|
||||
a non compressed datatype such as fasta, it will be unpacked.
|
||||
"""
|
||||
try:
|
||||
datatypes_registry = Registry()
|
||||
datatypes_registry.load_datatypes(
|
||||
root_dir=json_params['job_config']['GALAXY_ROOT_DIR'],
|
||||
config=json_params['job_config']['GALAXY_DATATYPES_CONF_FILE'])
|
||||
file_type = sniff.handle_uploaded_dataset_file(
|
||||
output_file,
|
||||
datatypes_registry)
|
||||
return file_type
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def determine_output_filename(input_url, metadata, json_params, primary_dataset):
|
||||
"""
|
||||
Determines the output file name. If only a single output file, the dataset name
|
||||
is used. If multiple files are being downloaded, each file is given a unique dataset
|
||||
name
|
||||
"""
|
||||
output_filename = json_params['output_data'][0]['file_name']
|
||||
|
||||
if not primary_dataset or not output_filename:
|
||||
hda_id = json_params['output_data'][0]['hda_id']
|
||||
output_filename = 'primary_%i_%s_visible_%s' % (hda_id, metadata.name, uuid.uuid4())
|
||||
|
||||
return os.path.join(os.getcwd(), output_filename)
|
||||
|
||||
|
||||
def determine_file_type(input_url, output_filename, metadata, json_params, sniffed_type):
|
||||
"""
|
||||
Determine the Galaxy data format for this file.
|
||||
"""
|
||||
# Use genomespace metadata to map type
|
||||
file_format = metadata.dataFormat.name if metadata.dataFormat else None
|
||||
file_type = get_galaxy_ext_from_genomespace_format(file_format)
|
||||
|
||||
# If genomespace metadata has no identifiable format, attempt to sniff type
|
||||
if not file_type:
|
||||
file_type = sniffed_type
|
||||
|
||||
# Still no type? Attempt to use filename extension to determine a type
|
||||
if not file_type:
|
||||
file_type = get_galaxy_ext_from_file_ext(metadata.name)
|
||||
|
||||
# Nothing works, use default
|
||||
if not file_type:
|
||||
file_type = "data"
|
||||
|
||||
return file_type
|
||||
|
||||
|
||||
def save_result_metadata(output_filename, file_type, metadata, json_params,
|
||||
primary_dataset=False):
|
||||
"""
|
||||
Generates a new job metadata file (typically galaxy.json) with details of
|
||||
all downloaded files, which Galaxy can read and use to display history items
|
||||
and associated metadata
|
||||
"""
|
||||
dataset_id = json_params['output_data'][0]['dataset_id']
|
||||
with open(json_params['job_config']['TOOL_PROVIDED_JOB_METADATA_FILE'], 'ab') as metadata_parameter_file:
|
||||
if primary_dataset:
|
||||
metadata_parameter_file.write("%s\n" % json.dumps(dict(type='dataset',
|
||||
dataset_id=dataset_id,
|
||||
ext=file_type,
|
||||
name="GenomeSpace importer on %s" % (filename))))
|
||||
# if using tmp file, move the file to the new file path dir to get scooped up later
|
||||
if using_temp_file:
|
||||
original_filename = filename
|
||||
filename = ''.join(c in FILENAME_VALID_CHARS and c or '-' for c in filename)
|
||||
while filename in used_filenames:
|
||||
filename = "-%s" % filename
|
||||
used_filenames.append(filename)
|
||||
target_output_filename = os.path.join(os.getcwd(), 'primary_%i_%s_visible_%s' % (hda_id, filename, file_type))
|
||||
shutil.move(output_filename, target_output_filename)
|
||||
name="GenomeSpace importer on %s" % (metadata.name))))
|
||||
else:
|
||||
metadata_parameter_file.write("%s\n" % json.dumps(dict(type='new_primary_dataset',
|
||||
base_dataset_id=base_dataset_id,
|
||||
base_dataset_id=dataset_id,
|
||||
ext=file_type,
|
||||
filename=target_output_filename,
|
||||
name="GenomeSpace importer on %s" % (original_filename))))
|
||||
dataset_id = None # only one primary dataset available
|
||||
output_filename = None # only have one filename available
|
||||
metadata_parameter_file.close()
|
||||
return True
|
||||
filename=output_filename,
|
||||
name="GenomeSpace importer on %s" % (metadata.name))))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-p', '--json_parameter_file', dest='json_parameter_file', action='store', type="string", default=None, help='json_parameter_file')
|
||||
parser.add_option('-s', '--genomespace_site', dest='genomespace_site', action='store', type="string", default=None, help='genomespace_site')
|
||||
parser.add_option('-t', '--token', dest='token', action='store', type="string", default=None, help='token')
|
||||
parser.add_option('-u', '--username', dest='username', action='store', type="string", default=None, help='username')
|
||||
parser.add_option('', '--genomespace_toolname', dest='genomespace_toolname', action='store', type="string", default=DEFAULT_GENOMESPACE_TOOLNAME, help='value to use for gs-toolname, used in GenomeSpace internal logging')
|
||||
(options, args) = parser.parse_args()
|
||||
def download_single_file(gs_client, input_url, json_params,
|
||||
primary_dataset=False):
|
||||
# 1. Get file metadata
|
||||
metadata = gs_client.get_metadata(input_url)
|
||||
|
||||
download_from_genomespace_importer(options.username, options.token, options.json_parameter_file, options.genomespace_site, options.genomespace_toolname)
|
||||
# 2. Determine output file name
|
||||
output_filename = determine_output_filename(input_url, metadata, json_params, primary_dataset)
|
||||
|
||||
# 3. Download file
|
||||
gs_client.copy(input_url, output_filename)
|
||||
|
||||
# 4. Decompress file if compressed and sniff type
|
||||
sniffed_type = sniff_and_handle_data_type(json_params, output_filename)
|
||||
|
||||
# 5. Determine file type from available metadata
|
||||
file_type = determine_file_type(input_url, output_filename, metadata, json_params, sniffed_type)
|
||||
|
||||
# 6. Write job output metadata
|
||||
save_result_metadata(output_filename, file_type, metadata, json_params,
|
||||
primary_dataset=primary_dataset)
|
||||
|
||||
|
||||
def download_from_genomespace_importer(json_parameter_file, root, data_conf, custom_token):
|
||||
with open(json_parameter_file, 'r') as param_file:
|
||||
json_params = json.load(param_file)
|
||||
|
||||
# Add in missing job config properties that could not be set in the exec_before_job hook
|
||||
json_params['job_config']['GALAXY_ROOT_DIR'] = root
|
||||
json_params['job_config']['GALAXY_DATATYPES_CONF_FILE'] = data_conf
|
||||
|
||||
# Extract input_urls and token (format is input_urls^token). If a custom_token is
|
||||
# provided, use that instead.
|
||||
url_with_token = json_params.get('param_dict', {}).get("URL", "")
|
||||
if custom_token:
|
||||
input_urls = url_with_token.split('^')[0]
|
||||
token = custom_token
|
||||
else:
|
||||
input_urls, token = url_with_token.split('^')
|
||||
input_url_list = input_urls.split(",")
|
||||
|
||||
gs_client = GenomeSpaceClient(token=token)
|
||||
|
||||
for idx, input_url in enumerate(input_url_list):
|
||||
download_single_file(gs_client, input_url, json_params,
|
||||
primary_dataset=(idx == 0))
|
||||
|
||||
|
||||
def process_args(args):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-p', '--json_parameter_file', type=str,
|
||||
help="JSON parameter file", required=True)
|
||||
parser.add_argument('-r', '--galaxy_root', type=str,
|
||||
help="Galaxy root dir", required=True)
|
||||
parser.add_argument('-c', '--data_conf', type=str,
|
||||
help="Galaxy data types conf file for mapping file types", required=True)
|
||||
parser.add_argument('-t', '--token', type=str,
|
||||
help="Optional OpenID/GenomeSpace token if not passed in as part of the URL as URLs^Token."
|
||||
" If none, the environment variable GS_TOKEN will be respected.", required=False)
|
||||
|
||||
args = parser.parse_args(args[1:])
|
||||
return args
|
||||
|
||||
|
||||
def main():
|
||||
args = process_args(sys.argv)
|
||||
download_from_genomespace_importer(args.json_parameter_file, args.galaxy_root, args.data_conf, args.token or os.environ.get("GS_TOKEN"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace Importer" id="genomespace_importer" tool_type="data_source" force_history_refresh="True" hidden="True" display_interface="False" require_login="True" version="0.0.2">
|
||||
<tool name="GenomeSpace Importer" id="genomespace_importer" require_login="False" version="0.0.5">
|
||||
<description> - receive data from GenomeSpace</description>
|
||||
<command interpreter="python">genomespace_importer.py
|
||||
--genomespace_site "prod"
|
||||
#assert $__user__, Exception( 'You must be logged in to use this tool.' )
|
||||
#set $username = $__user__.preferences.get( 'genomespace_username', None )
|
||||
#set $token = $__user__.preferences.get( 'genomespace_token', None )
|
||||
#assert None not in ( $username, $token ), Exception( 'You must associate a GenomeSpace OpenID with your account and log in with it.' )
|
||||
--username "${username}"
|
||||
--token "${token}"
|
||||
--json_parameter_file "${output_file1}"
|
||||
--genomespace_toolname="\${GENOMESPACE_TOOLNAME:-Galaxy}"
|
||||
</command>
|
||||
<command><![CDATA[
|
||||
python $__tool_directory__/genomespace_importer.py
|
||||
#set $input_file = $URL.split('^')[0] if '^' in $URL else $URL
|
||||
#set $token = $URL.split('^')[1] if '^' in $URL and $URL.split('^')[1] else $__user__.preferences.get('genomespace_token', None)
|
||||
|
||||
#assert $input_file, Exception('You must select a valid input file.')
|
||||
#assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID.')
|
||||
--json_parameter_file '${output_file1}'
|
||||
--galaxy_root $__root_dir__
|
||||
--data_conf $__datatypes_config__
|
||||
]]></command>
|
||||
<!-- If using this tool through bioblend, the URL parameter should contain the path to the GenomeSpaceFile + the security token
|
||||
separated by a ^ as follows: GenomeSpaceFilePath^Token -->
|
||||
<inputs check_values="False">
|
||||
<!-- <param name="file_name" type="text" value="" /> -->
|
||||
<param name="URL" type="hidden" value="" />
|
||||
<param name="URL" type="genomespacefile" label="Choose Input File from GenomeSpace" select_type="FILE" />
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="auto" name="output_file1" />
|
||||
</outputs>
|
||||
<help>
|
||||
some help text here...
|
||||
This tool allows you to import data from GenomeSpace. Click the Browse button to select a file to import. The tool will automatically
|
||||
fetch your GenomeSpace token when you select a file from the import dialog.
|
||||
|
||||
Alternatively, you can be logged in using your GenomeSpace OpenID, and the tool will use this ID if no token is entered.
|
||||
This allows you to simply paste the filepath into the location box and leave the token empty.
|
||||
You can associate your OpenID credentials under the User Preferences panel.
|
||||
Click here_ to refresh your GenomeSpace token.
|
||||
|
||||
.. _here: ${static_path}/../user/openid_auth?openid_provider=genomespace&auto_associate=True
|
||||
</help>
|
||||
<code file="genomespace_importer.py"/>
|
||||
<options sanitize="False" refresh="True"/>
|
||||
</tool>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace Push" id="genomespace_push" tool_type="data_source" force_history_refresh="True" hidden="True" display_interface="False" require_login="True" version="0.0.1">
|
||||
<description> - Push data from GenomeSpace to Galaxy</description>
|
||||
<environment_variables>
|
||||
<environment_variable name="GS_TOKEN">
|
||||
#set $token = $__user__.preferences.get( 'genomespace_token', None )
|
||||
#assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID or select a valid file via the GenomeSpace browse dialog.' )
|
||||
$token
|
||||
</environment_variable>
|
||||
</environment_variables>
|
||||
<command interpreter="python">genomespace_importer.py
|
||||
#set $input_file = $URL.split("^")[0] if "^" in $URL else $URL
|
||||
|
||||
#assert $input_file, Exception( 'You must select a valid input file.' )
|
||||
--json_parameter_file '${output_file1}'
|
||||
--galaxy_root $__root_dir__
|
||||
--data_conf $__datatypes_config__
|
||||
</command>
|
||||
<!-- If using this tool through bioblend, the URL parameter should contain a comma separated list of GenomeSpace URLs -->
|
||||
<inputs check_values="False">
|
||||
<param name="URL" type="genomespacefile" label="Choose Input File from GenomeSpace" select_type="FILE" />
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="auto" name="output_file1" />
|
||||
</outputs>
|
||||
<help>
|
||||
This tool is a variant of the genomespace_importer which behaves like a data_source and allows you to pull data from GenomeSpace.
|
||||
The URL parameter must contain a comma separated list of files to pull from GenomeSpace.
|
||||
The user must be logged into GenomeSpace through OpenID so that the authentication token can be obtained.
|
||||
You can associate your OpenID credentials under the User Preferences panel.
|
||||
Click here_ to refresh your GenomeSpace token.
|
||||
|
||||
.. _here: ${static_path}/../user/openid_auth?openid_provider=genomespace&auto_associate=True
|
||||
</help>
|
||||
<options sanitize="False" refresh="True"/>
|
||||
</tool>
|
||||
Reference in New Issue
Block a user