# HG changeset patch
# User kevyin
# Date 1354001673 18000
# Node ID 74c1fc7bb164d3028f73792e810f67af78c9b6f0
# Parent 4ea55669f00ec4938c73a247a66c33c0bee2006d
display tag directories with html
diff -r 4ea55669f00e -r 74c1fc7bb164 README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,13 @@
+Homer wrapper for Galaxy
+
+Code repo: https://bitbucket.org/gvl/homer
+
+=========================================:
+LICENSE for this wrapper:
+=========================================:
+Kevin Ying
+Garvan Institute: http://www.garvan.org.au
+GVL: https://genome.edu.au/wiki/GVL
+
+http://opensource.org/licenses/mit-license.php
+
diff -r 4ea55669f00e -r 74c1fc7bb164 annotatePeaks.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/annotatePeaks.xml Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,41 @@
+
+
+ homer
+
+
+
+
+ annotatePeaks.pl $input_bed $genome_selector 1> $out_annotated
+ 2> $out_log || echo "Error running annotatePeaks." >&2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+ **Homer annoatePeaks**
+ More information on accepted formats
+ http://biowhat.ucsd.edu/homer/ngs/annotation.html
+
+
+
+
+
diff -r 4ea55669f00e -r 74c1fc7bb164 bed2pos.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bed2pos.xml Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,34 @@
+
+
+ homer
+
+
+
+
+ bed2pos.pl $input_bed 1> $out_pos
+ 2> $out_log || echo "Error running bed2pos." >&2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+ **Homer bed2pos.pl**
+ http://biowhat.ucsd.edu/homer/ngs/miscellaneous.html
+
+
+
diff -r 4ea55669f00e -r 74c1fc7bb164 datatypes_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/datatypes_conf.xml Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff -r 4ea55669f00e -r 74c1fc7bb164 findPeaks.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/findPeaks.xml Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,52 @@
+
+
+ homer
+
+ Homer's peakcaller. Requires tag directories (see makeTagDirectory)
+
+
+ findPeaks $tagDir.extra_files_path $options -o $outputPeakFile
+
+ #if $control_tagDir:
+ -i $control_tagDir.extra_files_path
+ #end if
+
+ 2> $out_log || echo "Error running findPeaks." >&2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+ **Homer findPeaks**
+ http://biowhat.ucsd.edu/homer/ngs/peaks.html
+
+
+
+
diff -r 4ea55669f00e -r 74c1fc7bb164 homerDatatypes.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/homerDatatypes.py Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,122 @@
+"""
+homer composite datatypes
+NOTE: makeTagDirectory doesn't actually use this!!!! It uses html as the format
+ I've never got it to properly display the contents of the datatype for after
+ clicking the "eye" icon, so using html instead
+
+Use at your peril
+Kevin Ying
+for the homer wrapper
+
+Dec 2012
+"""
+
+import logging, os, sys, time, tempfile, shutil, string, glob
+import data
+from galaxy import util
+from cgi import escape
+import urllib, binascii
+from galaxy.web import url_for
+from galaxy.datatypes import metadata
+from galaxy.datatypes.metadata import MetadataElement
+from galaxy.datatypes.data import Text
+from galaxy.datatypes.tabular import Tabular
+from galaxy.datatypes.images import Html
+from galaxy.datatypes.interval import Interval
+from galaxy.util.hash_util import *
+
+gal_Log = logging.getLogger(__name__)
+verbose = False
+
+class HomerTagDirectory(Html):
+ """
+ base class to use for homer tag directory datatypes
+ composite datatype elements
+ stored in extra files path
+ """
+
+ #MetadataElement( name="base_name", desc="base name for all transformed versions of this genetic dataset", default='HomerTagDirectory',
+ #readonly=True, set_in_upload=False)
+
+ composite_type = 'auto_primary_file'
+ #allow_datatype_change = False
+ file_ext = 'homerTagDirectory'
+
+ def __init__(self, **kwd):
+ Html.__init__(self, **kwd)
+ self.add_composite_file('tagInfo.txt', description="tagInfo")
+ self.add_composite_file('tagAutocorrelation.txt', description="tagAutocorrelation")
+ self.add_composite_file('tagCountDistribution.txt', description="tagCountDistribution")
+ self.add_composite_file('tagLengthDistribution.txt', description="tagLengthDistribution")
+
+ def generate_primary_file(self, dataset=None):
+ rval = ['
Homer Tag Directory Galaxy Composite Dataset ']
+ rval.append('This composite dataset is composed of the following files:
')
+ for composite_name, composite_file in self.get_composite_files( dataset = dataset ).iteritems():
+ fn = composite_name
+ opt_text = ''
+ if composite_file.optional:
+ opt_text = ' (optional)'
+ if composite_file.get('description'):
+ rval.append( '- %s (%s)%s
' % ( fn, fn, composite_file.get('description'), opt_text ) )
+ else:
+ rval.append( '- %s%s
' % ( fn, fn, opt_text ) )
+ rval.append( '
' )
+ return "\n".join( rval )
+
+
+ def regenerate_primary_file(self,dataset):
+ """
+ cannot do this until we are setting metadata
+ """
+ #bn = dataset.metadata.base_name
+ efp = dataset.extra_files_path
+ flist = os.listdir(efp)
+ rval = ['Files for Composite Dataset %sComposite %s contains:' % (dataset.name,dataset.name)]
+ for i,fname in enumerate(flist):
+ sfname = os.path.split(fname)[-1]
+ f,e = os.path.splitext(fname)
+ rval.append( '- %s
' % ( sfname, sfname) )
+ rval.append( '
' )
+ f = file(dataset.file_name,'w')
+ f.write("\n".join( rval ))
+ f.write('\n')
+ f.close()
+
+ def get_mime(self):
+ """Returns the mime type of the datatype"""
+ return 'text/html'
+
+ def set_meta( self, dataset, **kwd ):
+
+ """
+ for homer maketagdirectory eg
+
+ """
+ Html.set_meta( self, dataset, **kwd )
+ if kwd.get('overwrite') == False:
+ if verbose:
+ gal_Log.debug('@@@ HomerTagDirectory set_meta called with overwrite = False')
+ return True
+ try:
+ efp = dataset.extra_files_path
+ except:
+ if verbose:
+ gal_Log.debug('@@@ HomerTagDirectory set_meta failed %s - dataset %s has no efp ?' % (sys.exc_info()[0], dataset.name))
+ return False
+ try:
+ flist = os.listdir(efp)
+ except:
+ if verbose: gal_Log.debug('@@@ HomerTagDirectory set_meta failed %s - dataset %s has no efp ?' % (sys.exc_info()[0],dataset.name))
+ return False
+ if len(flist) == 0:
+ if verbose:
+ gal_Log.debug('@@@ HomerTagDirectory set_meta failed - %s efp %s is empty?' % (dataset.name,efp))
+ return False
+ self.regenerate_primary_file(dataset)
+ if not dataset.info:
+ dataset.info = 'Galaxy HomerTagDirectory datatype object'
+ if not dataset.blurb:
+ dataset.blurb = 'Composite file - Homer Galaxy toolkit'
+ return True
+
diff -r 4ea55669f00e -r 74c1fc7bb164 makeTagDirectory.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/makeTagDirectory.py Tue Nov 27 02:34:33 2012 -0500
@@ -0,0 +1,94 @@
+"""
+
+
+"""
+import re
+import os
+import sys
+import subprocess
+import optparse
+import shutil
+import tempfile
+
+def getFileString(fpath, outpath):
+ """
+ format a nice file size string
+ """
+ size = ''
+ fp = os.path.join(outpath, fpath)
+ s = '? ?'
+ if os.path.isfile(fp):
+ n = float(os.path.getsize(fp))
+ if n > 2**20:
+ size = ' (%1.1f MB)' % (n/2**20)
+ elif n > 2**10:
+ size = ' (%1.1f KB)' % (n/2**10)
+ elif n > 0:
+ size = ' (%d B)' % (int(n))
+ s = '%s %s' % (fpath, size)
+ return s
+
+class makeTagDirectory():
+ """wrapper
+ """
+
+ def __init__(self,opts=None, args=None):
+ self.opts = opts
+ self.args = args
+
+ def run_makeTagDirectory(self):
+ """
+ makeTagDirectory