mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Added new 'taxonomy' datatype to config file and registry, user can now manually set this datatype for upoaded files, but no sniffer yet exists. First pass at bulding the history HTML for the dataset, but needs review.
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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 = ['<table cellspacing="0" cellpadding="3">']
|
||||
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( '<tr>' )
|
||||
for index, elem in enumerate( elems[0:int_col_headers] ):
|
||||
out.append( "<th>%s</th>" % ( index+1 ) )
|
||||
for index, name in enumerate( self.column_names ):
|
||||
out.append( "<th>%s</th>" % name )
|
||||
out.append( '</tr>' )
|
||||
|
||||
while len( comments ) > 0:
|
||||
out.append( '<tr><td colspan="100%">' )
|
||||
out.append( escape( comments.pop( 0 ) ) )
|
||||
out.append( '</td></tr>' )
|
||||
|
||||
out.append( '<tr>' ) # body
|
||||
for elem in elems:
|
||||
elem = escape( elem )
|
||||
out.append( "<td>%s</td>" % elem )
|
||||
out.append( '</tr>' )
|
||||
out.append( '</table>' )
|
||||
out = "".join( out )
|
||||
except Exception, exc:
|
||||
out = "Can't create peek %s" % exc
|
||||
return out
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user