Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Galaxy Workflow support for GenomeSpace #1814

Merged
merged 15 commits into from Aug 18, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Moved genomespace token to environment variable

  • Loading branch information...
nuwang committed Aug 18, 2017
commit 3e8bf3c4e72ca035f98142b3dc153de0a8e9d6a1
@@ -1,32 +1,35 @@
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('-t', '--token', type=str,
help="GenomeSpace auth token", required=True)
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(binascii.unhexlify(args.token).decode('utf-8'),
upload_to_genomespace(args.token,
binascii.unhexlify(args.input_file).decode('utf-8'),
binascii.unhexlify(args.target_url).decode('utf-8'))

@@ -1,14 +1,18 @@
<?xml version="1.0"?>
<tool name="GenomeSpace Exporter" id="genomespace_exporter" version="0.0.5">
<description> - send data to GenomeSpace</description>
<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]
#set $token = $genomespace_browser.split('^')[1] if '^' in $genomespace_browser and $genomespace_browser.split('^')[1] else $__user__.preferences.get('genomespace_token', None)

#assert $target_folder, Exception('You must select a valid target folder.')
#assert $token, Exception('Invalid token. You must be logged into GenomeSpace through OpenID or select a valid folder via the GenomeSpace browse dialog.')

#import binascii
--token '${ binascii.hexlify(str(token).encode("utf-8")) }'
--input_file '${ binascii.hexlify(str($input1).encode("utf8")) }'
#if $filename:
--target_url '${ binascii.hexlify(str($target_folder + "/" + str($filename)).encode("utf8") ) }'
@@ -18,7 +22,6 @@
</command>
<inputs>
<param format="data" name="input1" type="data" label="Send this dataset to GenomeSpace" />
<param name="base_url" type="baseurl" />
<!-- 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" />
@@ -244,15 +244,16 @@ def process_args(args):
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", required=False)
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)
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__":
@@ -1,16 +1,20 @@
<?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
#set $token = $__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 or select a valid file via the GenomeSpace browse dialog.' )
--json_parameter_file '${output_file1}'
--galaxy_root $__root_dir__
--data_conf $__datatypes_config__
--token '${token}'
</command>
<!-- If using this tool through bioblend, the URL parameter should contain a comma separated list of GenomeSpace URLs -->
<inputs check_values="False">
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.