changeset 44:da86478b1d64

clean up strange tools that just a url linkout
author jingchunzhu <jingchunzhu@gmail.com>
date Mon, 27 Jul 2015 15:30:10 -0700
parents 78d6e6772e30
children 129ba676fd68
files ucsc_xena_download.py ucsc_xenabrowser.xml
diffstat 2 files changed, 4 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/ucsc_xena_download.py	Mon Jul 27 12:21:55 2015 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-#!/usr/bin/env python
-import socket, urllib, sys, os
-from galaxy import eggs #eggs needs to be imported so that galaxy.util can find docutils egg...
-from galaxy.util.json import from_json_string, to_json_string
-from galaxy.util import get_charset_from_http_headers
-import galaxy.model # need to import model before sniff to resolve a circular import dependency
-from galaxy.datatypes import sniff
-import tarfile
-import re
-
-filemap = [
-        ('genomic', r'genomic(Segment|Matrix)$'),
-        ('clinical', r'clinicalMatrix$'),
-        ]
-
-files = {
-        'genomic': sys.argv[1],
-        'clinical': sys.argv[2]
-        }
-
-max_file_size = sys.argv[3]
-
-def file_type(file):
-    with open(file) as f:
-        return from_json_string(f.read())['type']
-
-def stop_err( msg ):
-    sys.stderr.write( msg )
-    sys.exit()
-
-def load_input_parameters( filename, erase_file = True ):
-    datasource_params = {}
-    try:
-        json_params = from_json_string( open( filename, 'r' ).read() )
-        datasource_params = json_params.get( 'param_dict' )
-    except:
-        json_params = None
-        for line in open( filename, 'r' ):
-            try:
-                line = line.strip()
-                fields = line.split( '\t' )
-                datasource_params[ fields[0] ] = fields[1]
-            except:
-                continue
-    if erase_file:
-        open( filename, 'w' ).close() #open file for writing, then close, removes params from file
-    return json_params, datasource_params
-
-def load_file(files):
-    filename = files['genomic']
-    job_params, params = load_input_parameters( filename, False )
-    URL = params.get( 'URL', None ) #using exactly URL indicates that only one dataset is being downloaded
-    URL_method = params.get( 'URL_method', None )
-    socket.setdefaulttimeout( 600 )
-    try:
-        if not URL_method or URL_method == 'get':
-            page = urllib.urlopen( URL )
-        elif URL_method == 'post':
-            page = urllib.urlopen( URL, urllib.urlencode( params ) )
-    except Exception, e:
-        stop_err( 'The remote data source application may be off line, please try again later. Error: %s' % str( e ) )
-    if max_file_size:
-        file_size = int( page.info().get( 'Content-Length', 0 ) )
-        if file_size > max_file_size:
-            stop_err( 'The size of the data (%d bytes) you have requested exceeds the maximum allowed (%d bytes) on this server.' % ( file_size, max_file_size ) )
-    try:
-        cur_filename, is_multi_byte = sniff.stream_to_open_named_file( page, os.open( filename, os.O_WRONLY | os.O_CREAT ), filename, source_encoding=get_charset_from_http_headers( page.headers ) )
-    except Exception, e:
-        stop_err( 'Unable to fetch %s:\n%s' % ( URL, e ) )
-
-load_file(files)
-
-tar = tarfile.open(files['genomic'])
-names = tar.getnames()
-metafiles = [n for n in names if n.endswith('.json')]
-tar.extractall()
-withtype = [(file_type(file), file[0:-len(".json")]) for file in metafiles]
-try:
-    renames = [((n for (t, n) in withtype if re.search(pat, t)).next(), name) for (name, pat) in filemap]
-except StopIteration:
-     stop_err( 'Missing required file type in tarball' )
-for (frm, to) in renames:
-    os.rename(frm, files[to])
--- a/ucsc_xenabrowser.xml	Mon Jul 27 12:21:55 2015 -0700
+++ b/ucsc_xenabrowser.xml	Mon Jul 27 15:30:10 2015 -0700
@@ -1,20 +1,7 @@
 <?xml version="1.0"?>
-<tool name="Xena Visualization" id="ucsc_xenabrowser" tool_type="data_source">
-    <description>UCSC Xena Browser visualization</description>
-    <command interpreter="python">ucsc_xena_download.py $genomic $clinical $__app__.config.output_size_limit</command>   
-    <inputs action="https://genome-cancer.soe.ucsc.edu/proj/site/xena/heatmap/" check_values="false" method="get">
-         <display>go to UCSC Xena Browser $GALAXY_URL</display>
-        <param name="GALAXY_URL" type="baseurl" value="/tool_runner" />
-        <param name="tool_id" type="hidden" value="ucsc_xenabrowser" />
+<tool name="Xena Visualization" id="ucsc_xenabrowser" tool_type="data_source" description="UCSC Xena Browser visualization">
+    <inputs action="https://genome-cancer.soe.ucsc.edu/proj/site/xena/heatmap/" >
+      <param name="GALAXY_URL" type="baseurl" value="/tool_runner" />
+      <param name="tool_id" type="hidden" value="ucsc_xenabrowser" />
     </inputs>
-    <request_param_translation>
-        <request_param galaxy_name="URL_method" remote_name="URL_method" missing="get" />
-        <request_param galaxy_name="URL" remote_name="URL" missing="" />
-    </request_param_translation>
-    <uihints minwidth="800"/>
-    <outputs>
-        <data name="genomic" format="tabular" label="#echo $URL.rsplit('/',1)[1].rsplit('.',1)[0]+' genomic'" />
-        <data name="clinical" format="tabular" label="#echo $URL.rsplit('/',1)[1].rsplit('.',1)[0]+' clinical'"/>
-    </outputs>
-    <options sanitize="False" refresh="True"/>
 </tool>