diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py
index 376696bb842..4c825ff1a59 100644
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1070,11 +1070,10 @@ class Tool:
def parse_redirect_url( self, inp_data, param_dict ):
"""Parse the REDIRECT_URL tool param"""
- # Tools that send data to an external application via a redirect must include the following 3
- # tool params:
+ # Tools that send data to an external application via a redirect must include the following 3 tool params:
# REDIRECT_URL - the url to which the data is being sent
# DATA_URL - the url to which the receiving application will send an http post to retrieve the Galaxy data
- # GALAXY_URL - the to which the external application may post data as a response
+ # GALAXY_URL - the url to which the external application may post data as a response
redirect_url = param_dict.get( 'REDIRECT_URL' )
redirect_url_params = self.build_redirect_url_params( param_dict )
# Add the parameters to the redirect url. We're splitting the param string on '**^**'
diff --git a/tool_conf.xml.sample b/tool_conf.xml.sample
index 7ca2a09835a..ec5807f9dce 100644
--- a/tool_conf.xml.sample
+++ b/tool_conf.xml.sample
@@ -10,6 +10,7 @@
+
diff --git a/tools/data_destination/epigraph.xml b/tools/data_destination/epigraph.xml
index bb2bd9b1b5d..be2e9d2aae2 100644
--- a/tools/data_destination/epigraph.xml
+++ b/tools/data_destination/epigraph.xml
@@ -1,6 +1,6 @@
-
- Genome analysis and prediction
+
+ analysis and prediction with EpiGRAPH
GENOME=${input1.dbkey} NAME=${input1.name} INFO=${input1.info}
diff --git a/tools/data_source/epigraph.py b/tools/data_source/epigraph.py
new file mode 100644
index 00000000000..769d9923ab6
--- /dev/null
+++ b/tools/data_source/epigraph.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#Retreives data from EpiGRAPH and stores in a file. EpiGRAPH request parameters are provided in the input/output file.
+import urllib, sys, os, gzip, tempfile, shutil
+from galaxy import eggs
+from galaxy.datatypes import data
+
+assert sys.version_info[:2] >= ( 2, 4 )
+
+def stop_err( msg ):
+ sys.stderr.write( msg )
+ sys.exit()
+
+def check_gzip( filename ):
+ temp = open( filename, "U" )
+ magic_check = temp.read( 2 )
+ temp.close()
+ if magic_check != data.gzip_magic:
+ return False
+ return True
+
+def __main__():
+ filename = sys.argv[1]
+ params = {}
+ for line in open( filename, 'r' ):
+ try:
+ line = line.strip()
+ fields = line.split( '\t' )
+ params[ fields[0] ] = fields[1]
+ except:
+ continue
+ URL = params.get( 'URL', None )
+ if not URL:
+ open( filename, 'w' ).write( "" )
+ stop_err( 'EpiGRAPH has not sent back a URL parameter.' )
+ out = open( filename, 'w' )
+ CHUNK_SIZE = 2**20 # 1Mb
+ try:
+ page = urllib.urlopen( URL, urllib.urlencode( params ) )
+ except:
+ stop_err( 'It appears that the EpiGRAPH server is currently off-line. Please try again later.' )
+ while 1:
+ chunk = page.read( CHUNK_SIZE )
+ if not chunk:
+ break
+ out.write( chunk )
+ out.close()
+ if check_gzip( filename ):
+ fd, uncompressed = tempfile.mkstemp()
+ gzipped_file = gzip.GzipFile( filename )
+ while 1:
+ try:
+ chunk = gzipped_file.read( CHUNK_SIZE )
+ except IOError:
+ os.close( fd )
+ os.remove( uncompressed )
+ gzipped_file.close()
+ stop_err( 'Problem uncompressing gzipped data, please try retrieving the data uncompressed.' )
+ if not chunk:
+ break
+ os.write( fd, chunk )
+ os.close( fd )
+ gzipped_file.close()
+ # Replace the gzipped file with the uncompressed file
+ shutil.move( uncompressed, filename )
+
+if __name__ == "__main__": __main__()
diff --git a/tools/data_source/epigraph_code.py b/tools/data_source/epigraph_code.py
new file mode 100644
index 00000000000..35aa0a7dadb
--- /dev/null
+++ b/tools/data_source/epigraph_code.py
@@ -0,0 +1,41 @@
+#Code for direct connection to EpiGRAPH
+from galaxy.datatypes import sniff
+import urllib
+
+def exec_before_job( app, inp_data, out_data, param_dict, tool=None ):
+ """
+ EpiGRAPH sends data to Galaxy by passing the following parameters in the request:
+ 1. URL - the url to which Galaxy should post a request to retrieve the data
+ 2. GENOME - the name of the UCSC genome assembly (e.g. hg18), dbkey in Galaxy
+ 3. NAME - data.name in Galaxy
+ 4. INFO - data.info in Galaxy
+ """
+ items = out_data.items()
+ for name, data in items:
+ NAME = urllib.unquote( param_dict.get( 'NAME', None ) )
+ if NAME is not None:
+ data.name = NAME
+ INFO = urllib.unquote( param_dict.get( 'INFO', None ) )
+ if INFO is not None:
+ data.info = INFO
+ GENOME = urllib.unquote( param_dict.get( 'GENOME', None ) )
+ if GENOME is not None:
+ data.dbkey = GENOME
+ else:
+ data.dbkey = '?'
+ # Store EpiGRAPH request parameters temporarily in output file
+ out = open( data.file_name, 'w' )
+ for key, value in param_dict.items():
+ print >> out, "%s\t%s" % ( key, value )
+ out.close()
+ out_data[ name ] = data
+
+def exec_after_process( app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None ):
+ """Verifies the datatype after the run"""
+ name, data = out_data.items()[0]
+ if data.extension == 'txt':
+ data_type = sniff.guess_ext( data.file_name, sniff_order=app.datatypes_registry.sniff_order )
+ data = app.datatypes_registry.change_datatype( data, data_type )
+ data.set_peek()
+ data.set_size()
+ data.flush()
diff --git a/tools/data_source/epigraph_import.xml b/tools/data_source/epigraph_import.xml
new file mode 100644
index 00000000000..bf62ed6188b
--- /dev/null
+++ b/tools/data_source/epigraph_import.xml
@@ -0,0 +1,15 @@
+
+
+ server
+ epigraph.py $output
+
+ go to EpiGRAPH server $GALAXY_URL
+
+
+
+
+
+
+
+
+