| 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 | |
|---|