diff --git a/tool_conf.xml.sample b/tool_conf.xml.sample
index 5405c591cb7..2e038351e73 100644
--- a/tool_conf.xml.sample
+++ b/tool_conf.xml.sample
@@ -149,6 +149,7 @@
+
diff --git a/tools/stats/MINE.xml b/tools/stats/MINE.xml
new file mode 100644
index 00000000000..7f8666b28ec
--- /dev/null
+++ b/tools/stats/MINE.xml
@@ -0,0 +1,82 @@
+
+ - Maximal Information-based Nonparametric Exploration
+
+ MINE
+
+ mine_wrapper.py
+ --jar "${GALAXY_DATA_INDEX_DIR}/shared/jars/mine/MINE.jar"
+
+ --infile "${input_file}"
+
+ #if str( $master_variable_type.master_variable_type_selector ) in [ 'allPairs', 'adjacentPairs' ]:
+ --master_variable "${master_variable_type.master_variable_type_selector}"
+ #else:
+ --master_variable "${master_variable_type.master_variable}"
+ #end if
+
+ --cv "${cv}"
+
+ --exp "${exp}"
+
+ --c "${c}"
+
+ ##--gc ##skip
+
+
+ #if str( $master_variable_type.master_variable_type_selector ) != 'allPairs' and $master_variable_type.permute:
+ --permute
+ #end if
+
+ --output_results "${output_results}"
+
+ --output_log "${output_log}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**What it does**
+
+Applies the Maximal Information-based Nonparametric Exploration strategy to an input dataset.
+
+See http://www.exploredata.net/ for more information.
+
+------
+
+**Citation**
+
+For the underlying tool, please cite `David N. Reshef, Yakir A. Reshef, Hilary K. Finucane5, Sharon R. Grossman, Gilean McVean, Peter J. Turnbaugh, Eric S. Lander, Michael Mitzenmacher, Pardis C. Sabeti Detecting Novel Associations in Large Data Sets. Science. 2011 Dec. <http://www.sciencemag.org/content/334/6062/1518>`_
+
+If you use this tool in Galaxy, please cite Blankenberg D, et al. *In preparation.*
+
+
+
diff --git a/tools/stats/mine_wrapper.py b/tools/stats/mine_wrapper.py
new file mode 100644
index 00000000000..4e8b30b0dd3
--- /dev/null
+++ b/tools/stats/mine_wrapper.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+#Dan Blankenberg
+
+"""
+A wrapper script for running the MINE.jar commands.
+"""
+
+import sys, optparse, os, tempfile, subprocess, shutil
+
+CHUNK_SIZE = 2**20 #1mb
+
+BASE_NAME = "galaxy_mime_file.txt"
+JOB_ID = "galaxy_mine"
+
+def cleanup_before_exit( tmp_dir ):
+ if tmp_dir and os.path.exists( tmp_dir ):
+ print os.listdir( tmp_dir )
+ shutil.rmtree( tmp_dir )
+
+def open_file_from_option( filename, mode = 'rb' ):
+ if filename:
+ return open( filename, mode = mode )
+ return None
+
+
+def __main__():
+ #Parse Command Line
+ parser = optparse.OptionParser()
+ parser.add_option( '-j', '--jar', dest='jar', action='store', type="string", help='Location of JAR file' )
+ parser.add_option( '-i', '--infile', dest='infile', action='store', type="string", help='infile' )
+ parser.add_option( '-m', '--master_variable', dest='master_variable', action='store', type="string", help='master_variable' )
+ parser.add_option( '-v', '--cv', dest='cv', action='store', type="string", help='cv' )
+ parser.add_option( '-e', '--exp', dest='exp', action='store', type="string", help='exp' )
+ parser.add_option( '-c', '--c', dest='c', action='store', type="string", help='c' )
+ parser.add_option( '-p', '--permute', dest='permute', action='store_true', default=False, help='permute' )
+ parser.add_option( '-o', '--output_results', dest='output_results', action='store', type="string", help='output_results' )
+ parser.add_option( '-l', '--output_log', dest='output_log', action='store', type="string", help='output_log' )
+ parser.add_option( '', '--stdout', dest='stdout', action='store', type="string", default=None, help='If specified, the output of stdout will be written to this file.' )
+ parser.add_option( '', '--stderr', dest='stderr', action='store', type="string", default=None, help='If specified, the output of stderr will be written to this file.' )
+ (options, args) = parser.parse_args()
+
+ tmp_dir = tempfile.mkdtemp( prefix='tmp-MINE-' )
+ tmp_input_name = os.path.join( tmp_dir, BASE_NAME )
+ if options.permute:
+ permute = "-permute"
+ else:
+ permute = ""
+
+ os.symlink( options.infile, tmp_input_name )
+
+ cmd = 'java -jar "%s" "%s" %s -cv%s -exp%s -c%s %s "%s"' % ( options.jar, tmp_input_name, options.master_variable, options.cv, options.exp, options.c, permute, JOB_ID )
+ print cmd
+
+ #set up stdout and stderr output options
+ stdout = open_file_from_option( options.stdout, mode = 'wb' )
+ stderr = open_file_from_option( options.stderr, mode = 'wb' )
+ #if no stderr file is specified, we'll use our own
+ if stderr is None:
+ stderr = tempfile.NamedTemporaryFile( prefix="MINE-stderr-", dir=tmp_dir )
+
+ proc = subprocess.Popen( args=cmd, stdout=stdout, stderr=stderr, shell=True, cwd=tmp_dir )
+ return_code = proc.wait()
+
+ if return_code:
+ stderr_target = sys.stderr
+ else:
+ stderr_target = sys.stdout
+ stderr.flush()
+ stderr.seek(0)
+ while True:
+ chunk = stderr.read( CHUNK_SIZE )
+ if chunk:
+ stderr_target.write( chunk )
+ else:
+ break
+ stderr.close()
+
+ print os.listdir( tmp_dir )
+
+ shutil.move( '%s,%s,Results.csv' % ( tmp_input_name, JOB_ID ), options.output_results )
+ shutil.move( '%s,%s,Status.csv' % ( tmp_input_name, JOB_ID ), options.output_log )
+
+ cleanup_before_exit( tmp_dir )
+
+if __name__=="__main__": __main__()