mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #9363 from nsoranzo/release_20.01_remove_GenomeSpace
[20.01] Remove GenomeSpace tools, OpenID, UI and requirements
This commit is contained in:
@@ -90,9 +90,6 @@ export default {
|
||||
case "custom_builds":
|
||||
activeLinks[key]["onclick"] = this.openManageCustomBuilds;
|
||||
break;
|
||||
case "genomespace":
|
||||
activeLinks[key]["onclick"] = this.requestGenomeSpace;
|
||||
break;
|
||||
case "logout":
|
||||
activeLinks[key]["onclick"] = this.signOut;
|
||||
break;
|
||||
@@ -138,9 +135,6 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
requestGenomeSpace() {
|
||||
window.location.href = `${getAppRoot()}openid/openid_auth?openid_provider=genomespace`;
|
||||
},
|
||||
signOut() {
|
||||
const Galaxy = getGalaxyInstance();
|
||||
Galaxy.modal.show({
|
||||
|
||||
@@ -73,11 +73,6 @@ export const getUserPreferencesModel = () => {
|
||||
description: _l("Add or remove custom builds using history datasets."),
|
||||
icon: "fa-cubes"
|
||||
},
|
||||
genomespace: {
|
||||
title: _l("Request GenomeSpace token"),
|
||||
description: _l("Requests token through OpenID."),
|
||||
icon: "fa-openid"
|
||||
},
|
||||
logout: {
|
||||
title: _l("Sign out"),
|
||||
description: _l("Click here to sign out of all sessions."),
|
||||
|
||||
@@ -9,7 +9,6 @@ import Ui from "mvc/ui/ui-misc";
|
||||
import SelectContent from "mvc/ui/ui-select-content";
|
||||
import SelectLibrary from "mvc/ui/ui-select-library";
|
||||
import SelectFtp from "mvc/ui/ui-select-ftp";
|
||||
import SelectGenomeSpace from "mvc/ui/ui-select-genomespace";
|
||||
import RulesEdit from "mvc/ui/ui-rules-edit";
|
||||
import ColorPicker from "mvc/ui/ui-color-picker";
|
||||
import DataPicker from "mvc/ui/ui-data-picker";
|
||||
@@ -38,7 +37,6 @@ export default Backbone.Model.extend({
|
||||
ftpfile: "_fieldFtp",
|
||||
upload: "_fieldUpload",
|
||||
rules: "_fieldRulesEdit",
|
||||
genomespacefile: "_fieldGenomeSpace",
|
||||
data_dialog: "_fieldDialog"
|
||||
},
|
||||
|
||||
@@ -237,15 +235,6 @@ export default Backbone.Model.extend({
|
||||
});
|
||||
},
|
||||
|
||||
/** GenomeSpace file select field
|
||||
*/
|
||||
_fieldGenomeSpace: function(input_def) {
|
||||
return new SelectGenomeSpace.View({
|
||||
id: `field-${input_def.id}`,
|
||||
onchange: input_def.onchange
|
||||
});
|
||||
},
|
||||
|
||||
_fieldRulesEdit: function(input_def) {
|
||||
return new RulesEdit.View({
|
||||
id: `field-${input_def.id}`,
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Provides support for interacting with the GenomeSpace File Browser popup dialogue
|
||||
import { getGalaxyInstance } from "app";
|
||||
|
||||
// tool form templates
|
||||
export default {
|
||||
openFileBrowser: function(options) {
|
||||
const Galaxy = getGalaxyInstance();
|
||||
var GS_UI_URL = 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");
|
||||
|
||||
window.addEventListener(
|
||||
"message",
|
||||
e => {
|
||||
if (options.successCallback && e.data.destination) {
|
||||
options.successCallback(e.data);
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
newWin.focus();
|
||||
|
||||
if (options["errorCallback"] != null) newWin.setCallbackOnGSUploadError = Galaxy.config["errorCallback"];
|
||||
}
|
||||
};
|
||||
@@ -1,79 +0,0 @@
|
||||
import Backbone from "backbone";
|
||||
import _l from "utils/localization";
|
||||
import Ui from "mvc/ui/ui-misc";
|
||||
import GenomespaceBrowser from "mvc/tool/tool-genomespace";
|
||||
/**
|
||||
* GenomeSpace file selector
|
||||
*/
|
||||
var View = Backbone.View.extend({
|
||||
// initialize
|
||||
initialize: function(options) {
|
||||
// link this
|
||||
var self = this;
|
||||
this.options = options;
|
||||
|
||||
// create insert new list element button
|
||||
this.browse_button = new Ui.Button({
|
||||
title: _l("Browse"),
|
||||
icon: "fa fa-sign-in",
|
||||
cls: "btn btn-secondary float-left",
|
||||
tooltip: _l("Browse GenomeSpace"),
|
||||
onclick: function() {
|
||||
self.browseGenomeSpace(options);
|
||||
}
|
||||
});
|
||||
|
||||
// create genomespace filepath textbox
|
||||
this.filename_textbox = new Ui.Input();
|
||||
|
||||
// create elements
|
||||
this.setElement(this._template(options));
|
||||
this.$(".ui-browse-button").append(this.browse_button.$el);
|
||||
this.$(".ui-filename-textbox").append(this.filename_textbox.$el);
|
||||
},
|
||||
|
||||
/** Browse GenomeSpace */
|
||||
browseGenomeSpace: function(options) {
|
||||
var self = this;
|
||||
GenomespaceBrowser.openFileBrowser({
|
||||
successCallback: function(data) {
|
||||
self.value(data.destination);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Main Template */
|
||||
_template: function(options) {
|
||||
return `<div class="row">
|
||||
<div class="ui-browse-button col-3" />
|
||||
<div class="ui-filename-textbox col"/>
|
||||
</div>`;
|
||||
},
|
||||
|
||||
/** Return/Set currently selected genomespace filename */
|
||||
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();
|
||||
},
|
||||
|
||||
// set value
|
||||
_setValue: function(new_value) {
|
||||
if (new_value) {
|
||||
this.filename_textbox.value(new_value);
|
||||
}
|
||||
this.options.onchange && this.options.onchange(new_value);
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
View: View
|
||||
};
|
||||
@@ -339,9 +339,6 @@ define({
|
||||
"Delete this repeat block": false,
|
||||
placeholder: false,
|
||||
Repeat: false,
|
||||
// ---------------------------------------------------------------------------- ui-select-genomespace
|
||||
"Browse GenomeSpace": false,
|
||||
Browse: false,
|
||||
// ---------------------------------------------------------------------------- ui-frames
|
||||
Error: false,
|
||||
Close: false,
|
||||
|
||||
@@ -339,9 +339,6 @@ define({
|
||||
"Delete this repeat block": false,
|
||||
placeholder: false,
|
||||
Repeat: false,
|
||||
// ---------------------------------------------------------------------------- ui-select-genomespace
|
||||
"Browse GenomeSpace": false,
|
||||
Browse: false,
|
||||
// ---------------------------------------------------------------------------- ui-frames
|
||||
Error: false,
|
||||
Close: false,
|
||||
|
||||
@@ -1584,17 +1584,6 @@
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
``genomespace_ui_url``
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
Points to the GenomeSpace UI service which will be used by the
|
||||
GenomeSpace importer and exporter tools
|
||||
:Default: ``https://gsui.genomespace.org/jsui/``
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
``terms_url``
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -837,10 +837,6 @@ galaxy:
|
||||
# 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.
|
||||
|
||||
@@ -16,12 +16,9 @@
|
||||
<tool file="data_source/wormbase.xml" />
|
||||
<tool file="data_source/zebrafishmine.xml" />
|
||||
<tool file="data_source/eupathdb.xml" />
|
||||
<tool file="genomespace/genomespace_importer.xml" />
|
||||
<tool file="genomespace/genomespace_push.xml" />
|
||||
</section>
|
||||
<section id="send" name="Send Data">
|
||||
<tool file="cloud/send.xml" />
|
||||
<tool file="genomespace/genomespace_exporter.xml" />
|
||||
</section>
|
||||
<section id="liftOver" name="Lift-Over">
|
||||
<tool file="extract/liftOver_wrapper.xml" />
|
||||
|
||||
@@ -20,12 +20,9 @@
|
||||
<tool file="data_source/zebrafishmine.xml" />
|
||||
<tool file="data_source/eupathdb.xml" />
|
||||
<tool file="data_source/hbvar.xml" />
|
||||
<tool file="genomespace/genomespace_importer.xml" />
|
||||
<tool file="genomespace/genomespace_push.xml" />
|
||||
</section>
|
||||
<section id="send" name="Send Data">
|
||||
<tool file="cloud/send.xml" />
|
||||
<tool file="genomespace/genomespace_exporter.xml" />
|
||||
</section>
|
||||
<section id="collection_operations" name="Collection Operations">
|
||||
<tool file="${model_tools_path}/unzip_collection.xml" />
|
||||
|
||||
@@ -78,7 +78,7 @@ svgwrite = "*"
|
||||
pyparsing = "*"
|
||||
"Fabric3" = "*"
|
||||
paramiko = "*"
|
||||
python-genomespaceclient = "<2.0"
|
||||
cloudbridge = "*"
|
||||
social_auth_core = {version = "==3.1.0+gx0", extras = ['openidconnect']}
|
||||
cloudauthz = "==0.6.0"
|
||||
gxformat2 = "*"
|
||||
|
||||
@@ -44,21 +44,20 @@ pytest-postgresql==1.4.1
|
||||
pytest-pythonpath==0.7.3
|
||||
pytest==4.6.6
|
||||
pytz==2019.3
|
||||
pyyaml==5.2
|
||||
recommonmark==0.6.0
|
||||
requests==2.22.0
|
||||
scandir==1.10.0 ; python_version < '3.5'
|
||||
selenium==3.141.0
|
||||
six==1.11.0
|
||||
snowballstemmer==2.0.0
|
||||
sphinx-markdown-tables==0.0.10
|
||||
sphinx-markdown-tables==0.0.12
|
||||
sphinx-rtd-theme==0.4.3
|
||||
sphinx==1.8.5
|
||||
sphinxcontrib-websupport==1.1.2
|
||||
testfixtures==6.10.3
|
||||
twill==0.9.1 ; python_version < '3'
|
||||
typing==3.7.4.1 ; python_version < '3.5'
|
||||
urllib3==1.25.7 ; python_version == '2.7'
|
||||
urllib3==1.25.7
|
||||
watchdog==0.9.0
|
||||
wcwidth==0.1.7 ; sys_platform != 'win32'
|
||||
wcwidth==0.1.7
|
||||
zipp==0.6.0
|
||||
|
||||
@@ -60,7 +60,7 @@ funcsigs==1.0.2 ; python_version < '3.3'
|
||||
functools32==3.2.3.post2 ; python_version < '3.2'
|
||||
future==0.18.2
|
||||
futures==3.3.0 ; python_version == '2.6' or python_version == '2.7'
|
||||
galaxy-sequence-utils==1.1.3
|
||||
galaxy-sequence-utils==1.1.4
|
||||
google-api-python-client==1.7.8
|
||||
google-auth-httplib2==0.0.3
|
||||
google-auth==1.7.1
|
||||
@@ -127,7 +127,7 @@ pulsar-galaxy-lib==0.14.0.dev1
|
||||
pyasn1-modules==0.2.7
|
||||
pyasn1==0.4.8
|
||||
pycparser==2.19
|
||||
pycryptodome==3.9.4
|
||||
pycryptodome==3.9.6
|
||||
pyeventsystem==0.1.0
|
||||
pyinotify==0.9.6 ; sys_platform != 'win32' and sys_platform != 'darwin' and sys_platform != 'sunos5'
|
||||
pyjwt==1.7.1
|
||||
@@ -141,7 +141,6 @@ pysam==0.15.2
|
||||
pysftp==0.2.9
|
||||
python-cinderclient==4.0.0
|
||||
python-dateutil==2.8.1
|
||||
python-genomespaceclient==1.2.0
|
||||
python-glanceclient==2.12.0
|
||||
python-jose==3.0.1
|
||||
python-keystoneclient==3.17.0
|
||||
@@ -187,7 +186,7 @@ typing==3.7.4.1 ; python_version < '3.5'
|
||||
tzlocal==2.0.0
|
||||
unicodecsv==0.14.1 ; python_version < '3.0'
|
||||
uritemplate==3.0.0
|
||||
urllib3==1.25.7 ; python_version == '2.7'
|
||||
urllib3==1.25.7
|
||||
vine==1.3.0
|
||||
warlock==1.3.3
|
||||
wcwidth==0.1.7 ; sys_platform != 'win32'
|
||||
|
||||
@@ -73,6 +73,7 @@ for env in $ENVS; do
|
||||
-e "s/^\(python-dateutil==[^ ;]\{1,\}\).*$/\1/" \
|
||||
-e "s/^\(subprocess32==[^ ;]\{1,\}\).*$/\1 ; python_version < '3.0'/" \
|
||||
-e "s/^\(typing==[^ ;]\{1,\}\).*$/\1 ; python_version < '3.5'/" \
|
||||
-e "s/^\(urllib3==[^ ;]\{1,\}\).*$/\1/" \
|
||||
pinned-requirements.txt pinned-dev-requirements.txt
|
||||
if ! grep '==' pinned-dev-requirements.txt ; then
|
||||
rm -f pinned-dev-requirements.txt
|
||||
|
||||
@@ -51,7 +51,6 @@ class ConfigSerializer(base.ModelSerializer):
|
||||
'search_url' : _required_attribute,
|
||||
'mailing_lists' : _defaults_to(self.app.config.mailing_lists_url),
|
||||
'screencasts_url' : _required_attribute,
|
||||
'genomespace_ui_url' : _required_attribute,
|
||||
'citation_url' : _required_attribute,
|
||||
'support_url' : _required_attribute,
|
||||
'helpsite_url' : _required_attribute,
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<provider id="genomespace" name="GenomeSpace">
|
||||
<op_endpoint_url>https://identity.genomespace.org/identityServer/xrd.jsp</op_endpoint_url>
|
||||
<sreg>
|
||||
<field name="nickname" required="True">
|
||||
<use_for name="username"/>
|
||||
<store_user_preference name="genomespace_username"/>
|
||||
</field>
|
||||
<field name="email" required="False">
|
||||
<use_for name="email"/>
|
||||
</field>
|
||||
<field name="gender" required="True">
|
||||
<store_user_preference name="genomespace_token"/>
|
||||
</field>
|
||||
</sreg>
|
||||
</provider>
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<openid>
|
||||
<provider file="genomespace.xml" />
|
||||
</openid>
|
||||
|
||||
@@ -177,8 +177,6 @@ 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.
|
||||
|
||||
@@ -648,19 +648,6 @@ class FTPFileToolParameter(ToolParameter):
|
||||
return d
|
||||
|
||||
|
||||
class GenomespaceFileToolParameter(ToolParameter):
|
||||
"""
|
||||
Parameter that takes one of two values.
|
||||
"""
|
||||
|
||||
def __init__(self, tool, input_source):
|
||||
super(GenomespaceFileToolParameter, self).__init__(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.
|
||||
@@ -2351,7 +2338,6 @@ parameter_types = dict(
|
||||
baseurl=BaseURLToolParameter,
|
||||
file=FileToolParameter,
|
||||
ftpfile=FTPFileToolParameter,
|
||||
genomespacefile=GenomespaceFileToolParameter,
|
||||
data=DataToolParameter,
|
||||
data_collection=DataCollectionToolParameter,
|
||||
library_data=LibraryDatasetToolParameter,
|
||||
|
||||
@@ -1179,14 +1179,6 @@ mapping:
|
||||
desc: |
|
||||
The URL linked by the "Videos" link in the "Help" menu.
|
||||
|
||||
genomespace_ui_url:
|
||||
type: str
|
||||
default: https://gsui.genomespace.org/jsui/
|
||||
required: false
|
||||
desc: |
|
||||
Points to the GenomeSpace UI service which will be used by
|
||||
the GenomeSpace importer and exporter tools
|
||||
|
||||
terms_url:
|
||||
type: str
|
||||
required: false
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from datetime import timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from galaxy.util import listify
|
||||
from galaxy_test.driver.driver_util import GalaxyTestDriver
|
||||
|
||||
|
||||
"""
|
||||
This tests: (1) automatic creation of configuration properties; and
|
||||
(2) assignment of default values that are specified in the schema and, in
|
||||
@@ -35,9 +25,16 @@ Configuration options NOT tested:
|
||||
- job_config (no obvious testable defaults)
|
||||
"""
|
||||
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from datetime import timedelta
|
||||
|
||||
OptionData = namedtuple('OptionData', 'key, expected, loaded')
|
||||
import pytest
|
||||
|
||||
from galaxy.util import listify
|
||||
from galaxy_test.driver.driver_util import GalaxyTestDriver
|
||||
|
||||
OptionData = namedtuple('OptionData', ('key', 'expected', 'loaded'))
|
||||
|
||||
# Configuration properties that are paths should be absolute paths, by default resolved w.r.t root.
|
||||
PATH_CONFIG_PROPERTIES = [
|
||||
@@ -155,6 +152,7 @@ DO_NOT_TEST = [
|
||||
'allow_user_deletion', # broken: default overridden
|
||||
'amqp_internal_connection', # may or may not be testable; refactor config/
|
||||
'api_allow_run_as', # may or may not be testable: test value assigned
|
||||
'build_sites_config_file', # broken: remove 'config/' prefix from schema
|
||||
'chunk_upload_size', # broken: default overridden
|
||||
'cleanup_job', # broken: default overridden
|
||||
'conda_auto_init', # broken: default overridden
|
||||
@@ -203,7 +201,7 @@ DO_NOT_TEST = [
|
||||
'user_tool_label_filters', # broken: default overridden
|
||||
'user_tool_section_filters', # broken: default overridden
|
||||
'webhooks_dir', # broken; also remove 'config/' prefix from schema
|
||||
'workflow_resource_params_mapper', # broken
|
||||
'workflow_resource_params_mapper', # broken: remove 'config/' prefix from schema
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import argparse
|
||||
import binascii
|
||||
import os
|
||||
import sys
|
||||
|
||||
from genomespaceclient import GenomeSpaceClient
|
||||
|
||||
|
||||
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 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 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'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace Exporter" id="genomespace_exporter" require_login="True" version="0.0.7" profile="16.04">
|
||||
<description> - send data to GenomeSpace</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.')
|
||||
$token
|
||||
</environment_variable>
|
||||
</environment_variables>
|
||||
<command detect_errors="exit_code">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
|
||||
--input_file '${ binascii.hexlify(str($input1).encode("utf8")) }'
|
||||
#if $filename:
|
||||
--target_url '${ binascii.hexlify(str($target_folder + "/" + str($filename)).encode("utf8") ) }'
|
||||
#else:
|
||||
--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
|
||||
</command>
|
||||
<inputs>
|
||||
<param format="data" name="input1" type="data" label="Send this dataset to GenomeSpace" />
|
||||
<!-- 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="auto" name="output_log" />
|
||||
</outputs>
|
||||
<help>
|
||||
This Tool allows you to export data to GenomeSpace. Click the Browse button to select a file to export.
|
||||
|
||||
To use this tool, you must have logged in using your GenomeSpace OpenID.
|
||||
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>
|
||||
</tool>
|
||||
@@ -1,260 +0,0 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from genomespaceclient import GenomeSpaceClient
|
||||
|
||||
import galaxy
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy.datatypes.registry import Registry
|
||||
|
||||
|
||||
# Mappings for known genomespace formats to galaxy formats
|
||||
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'}
|
||||
|
||||
|
||||
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:
|
||||
rval.append(str(value))
|
||||
return rval
|
||||
|
||||
|
||||
def _prepare_json_param_dict(param_dict):
|
||||
"""
|
||||
JSON serialization Support functions for exec_before_job hook
|
||||
"""
|
||||
rval = {}
|
||||
for key, value in param_dict.items():
|
||||
if isinstance(value, dict):
|
||||
rval[key] = _prepare_json_param_dict(value)
|
||||
elif isinstance(value, list):
|
||||
rval[key] = _prepare_json_list(value)
|
||||
else:
|
||||
rval[key] = str(value)
|
||||
return rval
|
||||
|
||||
|
||||
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.items()):
|
||||
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 Exception:
|
||||
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.data_format.name if metadata.data_format 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" % (metadata.name))))
|
||||
else:
|
||||
metadata_parameter_file.write("%s\n" % json.dumps(dict(type='new_primary_dataset',
|
||||
base_dataset_id=dataset_id,
|
||||
ext=file_type,
|
||||
filename=output_filename,
|
||||
name="GenomeSpace importer on %s" % (metadata.name))))
|
||||
|
||||
|
||||
def download_single_file(gs_client, input_url, json_params,
|
||||
primary_dataset=False):
|
||||
# 1. Get file metadata
|
||||
metadata = gs_client.get_metadata(input_url)
|
||||
|
||||
# 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,39 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<tool name="GenomeSpace Importer" id="genomespace_importer" tool_type="output_parameter_json" require_login="True" version="0.0.6">
|
||||
<description> - receive data from GenomeSpace</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.')
|
||||
$token
|
||||
</environment_variable>
|
||||
</environment_variables>
|
||||
<command><![CDATA[
|
||||
python $__tool_directory__/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 the path to the GenomeSpaceFile + the security token
|
||||
separated by a ^ as follows: GenomeSpaceFilePath^Token -->
|
||||
<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 allows you to import data from GenomeSpace. Click the Browse button to select a file to import.
|
||||
|
||||
To use this tool, you must have logged in using your GenomeSpace OpenID.
|
||||
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>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?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.6">
|
||||
<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.')
|
||||
$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