diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index a0ff29cf9b7..1c26da81b47 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -52,6 +52,7 @@ class Registry( object ): 'qualityscore': qualityscore.QualityScore(), 'scf' : images.Scf(), 'tabular' : tabular.Tabular(), + 'taxonomy' : tabular.Taxonomy(), 'txt' : data.Text(), 'txtseq.zip' : images.Txtseq(), 'wig' : interval.Wiggle() @@ -72,6 +73,7 @@ class Registry( object ): 'qualityscore': 'text/plain', 'scf' : 'application/octet-stream', 'tabular' : 'text/plain', + 'taxonomy' : 'text/plani', 'txt' : 'text/plain', 'txtseq.zip' : 'application/zip', 'wig' : 'text/plain' diff --git a/lib/galaxy/datatypes/tabular.py b/lib/galaxy/datatypes/tabular.py index 7722557d91b..1afaf8bf1c8 100644 --- a/lib/galaxy/datatypes/tabular.py +++ b/lib/galaxy/datatypes/tabular.py @@ -130,4 +130,56 @@ class Tabular( data.Text ): return m_peek class Taxonomy( Tabular ): - pass + def __init__(self, **kwd): + """Initialize taxonomy datatype""" + Tabular.__init__( self, **kwd ) + self.column_names = ['Name', 'GI', 'Root', 'Superkingdom', 'Kingdom', 'Subkingdom', + 'Superphylum', 'Phylum', 'Subphylum', 'Superclass', 'Class', 'Subclass', + 'Superorder', 'Order', 'Suborder', 'Superfamily', 'Family', 'Subfamily', + 'Tribe', 'Subtribe', 'Genus', 'Subgenus', 'Species', 'Subspecies' + ] + + def make_html_table( self, data, skipchar=None ): + """Create HTML table, used for displaying peek""" + out = [''] + first = True + comments = [] + try: + lines = data.splitlines() + for line in lines: + line = line.rstrip( '\r\n' ) + if not line: + continue + if skipchar and line.startswith( skipchar ): + comments.append( line ) + continue + + elems = line.split( '\t' ) + # This data type requires at least 24 columns in the data + int_col_headers = len( elems ) - len( self.column_names ) + + if first: #generate header + first = False + out.append( '' ) + for index, elem in enumerate( elems[0:int_col_headers] ): + out.append( "" % ( index+1 ) ) + for index, name in enumerate( self.column_names ): + out.append( "" % name ) + out.append( '' ) + + while len( comments ) > 0: + out.append( '' ) + + out.append( '' ) # body + for elem in elems: + elem = escape( elem ) + out.append( "" % elem ) + out.append( '' ) + out.append( '
%s%s
' ) + out.append( escape( comments.pop( 0 ) ) ) + out.append( '
%s
' ) + out = "".join( out ) + except Exception, exc: + out = "Can't create peek %s" % exc + return out + diff --git a/universe_wsgi.ini.sample b/universe_wsgi.ini.sample index e8bcb30f775..87ac55f15af 100644 --- a/universe_wsgi.ini.sample +++ b/universe_wsgi.ini.sample @@ -181,6 +181,7 @@ pdf = galaxy.datatypes.images:Image,application/pdf png = galaxy.datatypes.images:Image,image/png qualityscore = galaxy.datatypes.qualityscore:QualityScore scf = galaxy.datatypes.images:Scf,application/octet-stream +taxonomy = galaxy.datatypes.tabular:Taxonomy tabular = galaxy.datatypes.tabular:Tabular txt = galaxy.datatypes.data:Text txtseq.zip = galaxy.datatypes.images:Txtseq,application/zip