Changeset 1021:13d8b4560298

Show
Ignore:
Timestamp:
03/04/08 16:55:16 (10 months ago)
Author:
Greg Von Kuster <greg@bx.psu.edu>
branch:
default
convert_revision:
svn:9bcadc22-80f8-0310-8a53-c8f022958886/galaxy/trunk@2380
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/galaxy/datatypes/registry.py

    r1007 r1021  
    5353                'scf'         : images.Scf(), 
    5454                'tabular'     : tabular.Tabular(), 
     55                'taxonomy'    : tabular.Taxonomy(), 
    5556                'txt'         : data.Text(), 
    5657                'txtseq.zip'  : images.Txtseq(), 
     
    7374                'scf'         : 'application/octet-stream', 
    7475                'tabular'     : 'text/plain', 
     76                'taxonomy'    : 'text/plani', 
    7577                'txt'         : 'text/plain', 
    7678                'txtseq.zip'  : 'application/zip', 
  • lib/galaxy/datatypes/tabular.py

    r1018 r1021  
    131131 
    132132class Taxonomy( Tabular ): 
    133     pass 
     133    def __init__(self, **kwd): 
     134        """Initialize taxonomy datatype""" 
     135        Tabular.__init__( self, **kwd ) 
     136        self.column_names = ['Name', 'GI', 'Root', 'Superkingdom', 'Kingdom', 'Subkingdom', 
     137                             'Superphylum', 'Phylum', 'Subphylum', 'Superclass', 'Class', 'Subclass', 
     138                             'Superorder', 'Order', 'Suborder', 'Superfamily', 'Family', 'Subfamily', 
     139                             'Tribe', 'Subtribe', 'Genus', 'Subgenus', 'Species', 'Subspecies' 
     140                             ] 
     141 
     142    def make_html_table( self, data, skipchar=None ): 
     143        """Create HTML table, used for displaying peek""" 
     144        out = ['<table cellspacing="0" cellpadding="3">'] 
     145        first = True 
     146        comments = [] 
     147        try: 
     148            lines =  data.splitlines() 
     149            for line in lines: 
     150                line = line.rstrip( '\r\n' ) 
     151                if not line: 
     152                    continue 
     153                if skipchar and line.startswith( skipchar ): 
     154                    comments.append( line ) 
     155                    continue 
     156 
     157                elems = line.split( '\t' ) 
     158                # This data type requires at least 24 columns in the data 
     159                int_col_headers = len( elems ) - len( self.column_names ) 
     160 
     161                if first: #generate header 
     162                    first = False 
     163                    out.append( '<tr>' ) 
     164                    for index, elem in enumerate( elems[0:int_col_headers] ): 
     165                        out.append( "<th>%s</th>" % ( index+1 ) ) 
     166                    for index, name in enumerate( self.column_names ): 
     167                        out.append( "<th>%s</th>" % name ) 
     168                    out.append( '</tr>' ) 
     169                 
     170                while len( comments ) > 0: 
     171                    out.append( '<tr><td colspan="100%">' ) 
     172                    out.append( escape( comments.pop( 0 ) ) ) 
     173                    out.append( '</td></tr>' ) 
     174                 
     175                out.append( '<tr>' ) # body 
     176                for elem in elems: 
     177                    elem = escape( elem ) 
     178                    out.append( "<td>%s</td>" % elem ) 
     179                out.append( '</tr>' ) 
     180            out.append( '</table>' ) 
     181            out = "".join( out ) 
     182        except Exception, exc: 
     183            out = "Can't create peek %s" % exc 
     184        return out 
     185 
  • universe_wsgi.ini.sample

    r997 r1021  
    182182qualityscore = galaxy.datatypes.qualityscore:QualityScore 
    183183scf = galaxy.datatypes.images:Scf,application/octet-stream 
     184taxonomy = galaxy.datatypes.tabular:Taxonomy 
    184185tabular = galaxy.datatypes.tabular:Tabular 
    185186txt = galaxy.datatypes.data:Text