Changeset 410:d064aa689bb5
- Timestamp:
- 07/11/07 13:36:54 (1 year ago)
- Files:
-
- lib/galaxy/datatypes/data.py (modified) (10 diffs)
- lib/galaxy/datatypes/images.py (modified) (3 diffs)
- lib/galaxy/datatypes/interval.py (modified) (16 diffs)
- lib/galaxy/datatypes/registry.py (modified) (2 diffs)
- lib/galaxy/datatypes/sequence.py (modified) (2 diffs)
- lib/galaxy/datatypes/tabular.py (modified) (5 diffs)
- lib/galaxy/interfaces/root.py (modified) (2 diffs)
- lib/galaxy/model/__init__.py (modified) (3 diffs)
- templates/history.tmpl (modified) (1 diff)
- templates/root/index.tmpl (modified) (1 diff)
- universe_wsgi.ini.sample (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lib/galaxy/datatypes/data.py
r400 r410 34 34 __metaclass__ = DataMeta 35 35 36 """Provide the set of display formats supported by this datatype """ 37 supported_display_apps = [] 38 39 def set_peek( self, dataset ): 40 dataset.peek = '' 41 dataset.blurb = 'data' 36 """Stores the set of display applications, and viewing methods, supported by this datatype """ 37 supported_display_apps = {} 38 39 def __init__(self, **kwd): 40 """Initialize the datatype""" 41 object.__init__(self, **kwd) 42 self.supported_display_apps = self.supported_display_apps.copy() 43 44 def write_from_stream(self, dataset, stream): 45 """Writes data from a stream""" 46 fd = open(dataset.file_name, 'wb') 47 while 1: 48 chunk = stream.read(1048576) 49 if not chunk: 50 break 51 os.write(fd, chunk) 52 os.close(fd) 53 54 def set_raw_data(self, dataset, data): 55 """Saves the data on the disc""" 56 fd = open(dataset.file_name, 'wb') 57 os.write(fd, data) 58 os.close(fd) 59 60 def get_raw_data( self, dataset ): 61 """Returns the full data. To stream it open the file_name and read/write as needed""" 62 try: 63 return file(datset.file_name, 'rb').read(-1) 64 except OSError, e: 65 log.exception('%s reading a file that does not exist %s' % (self.__class__.__name__, dataset.file_name)) 66 return '' 67 42 68 def init_meta( self, dataset, copy_from=None ): 43 69 # Metadata should be left mostly uninitialized. Dataset will … … 49 75 if copy_from: 50 76 dataset.metadata = copy_from.metadata 77 def set_meta( self, dataset ): 78 """Unimplemented method, allows guessing of metadata from contents of file""" 79 return True 51 80 def missing_meta( self, dataset): 81 """Unimplemented method, Returns True if metadata is missing""" 52 82 return False 53 def get_estimated_display_viewport( self, dataset ): 54 raise Exception( "'get_estimated_display_viewport' must be overridden in subclass." ) 55 def as_ucsc_display_file( self, dataset ): 56 raise Exception( "'as_ucsc_display_file' not supported for this datatype" ) 57 def as_gbrowse_display_file( self, dataset ): 58 raise Exception( "'as_gbrowse_display_file' not supported for this datatype" ) 83 def set_peek( self, dataset ): 84 """Set the peek and blurb text""" 85 dataset.peek = '' 86 dataset.blurb = 'data' 59 87 def display_peek(self, dataset): 88 """Returns formated html of peek""" 60 89 try: 61 90 return escape(dataset.peek) … … 63 92 return "peek unavailable" 64 93 def display_name(self, dataset): 94 """Returns formated html of dataset name""" 65 95 try: 66 96 return escape(dataset.name) … … 68 98 return "name unavailable" 69 99 def display_info(self, dataset): 100 """Returns formated html of dataset info""" 70 101 try: 71 102 return escape(dataset.info) 72 103 except: 73 104 return "info unavailable" 74 def get_ucsc_sites(self, dataset):75 return util.get_ucsc_by_build(dataset.dbkey)76 def get_gbrowse_sites(self, dataset):77 return util.get_gbrowse_sites_by_build(dataset.dbkey)78 105 def validate(self, dataset): 79 106 """Unimplemented validate, return no exceptions""" … … 82 109 """Unimplemented method, returns dict with method/option for repairing errors""" 83 110 return None 111 def get_mime(self): 112 """Returns the mime type of the datatype""" 113 return 'application/octet-stream' 114 def add_display_app (self, app_id, label, file_function, links_function ): 115 """ 116 Adds a display app to the datatype. 117 app_id is a unique id 118 label is the primary display label, ie display at 'UCSC' 119 file_function is a string containing the name of the function that returns a properly formated display 120 links_function is a string containing the name of the function that returns a list of (link_name,link) 121 """ 122 self.supported_display_apps = self.supported_display_apps.copy() 123 self.supported_display_apps[app_id] = {'label':label,'file_function':file_function,'links_function':links_function} 124 def remove_display_app (self, app_id): 125 """Removes a display app from the datatype""" 126 self.supported_display_apps = self.supported_display_apps.copy() 127 try: 128 del self.supported_display_apps[app_id] 129 except: 130 log.exception('Tried to remove display app %s from datatype %s, but this display app is not declared.' % ( type, self.__class__.__name__ ) ) 131 def get_display_types(self): 132 """Returns display types available""" 133 return self.supported_display_apps.keys() 134 def get_display_label(self, type): 135 """Returns primary label for display app""" 136 try: 137 return self.supported_display_apps[type]['label'] 138 except: 139 return 'unknown' 140 def as_display_type(self, dataset, type, **kwd): 141 """Returns modified file contents for a particular display type """ 142 try: 143 if type in self.get_display_types(): 144 return getattr (self, self.supported_display_apps[type]['file_function']) (dataset, **kwd) 145 except: 146 log.exception('Function %s is referred to in datatype %s for displaying as type %s, but is not accessible' % (self.supported_display_apps[type]['file_function'], self.__class__.__name__, type) ) 147 return "This display type (%s) is not implemented for this datatype (%s)." % ( type, dataset.ext) 148 149 def get_display_links(self, dataset, type, app, base_url, **kwd): 150 """Returns a list of tuples of (name, link) for a particular display type """ 151 try: 152 if type in self.get_display_types(): 153 return getattr (self, self.supported_display_apps[type]['links_function']) (dataset, type, app, base_url, **kwd) 154 except: 155 log.exception('Function %s is referred to in datatype %s for generating links for type %s, but is not accessible' % (self.supported_display_apps[type]['links_function'], self.__class__.__name__, type) ) 156 return [] 84 157 85 158 class Text( Data ): 86 159 87 """Provide the set of display formats supported by this datatype """ 88 supported_display_apps = [] 89 90 def write_from_stream(self, stream): 91 "Writes data from a stream" 160 def write_from_stream(self, dataset, stream): 161 """Writes data from a stream""" 92 162 # write it twice for now 93 163 fd, temp_name = tempfile.mkstemp() … … 100 170 101 171 # rewrite the file with unix newlines 102 fp = open( self.file_name, 'wt')172 fp = open(dataset.file_name, 'wt') 103 173 for line in file(temp_name, "U"): 104 174 line = line.strip() + '\n' … … 106 176 fp.close() 107 177 108 def set_raw_data(self, data ):178 def set_raw_data(self, dataset, data): 109 179 """Saves the data on the disc""" 110 180 fd, temp_name = tempfile.mkstemp() … … 113 183 114 184 # rewrite the file with unix newlines 115 fp = open( self.file_name, 'wt')185 fp = open(dataset.file_name, 'wt') 116 186 for line in file(temp_name, "U"): 117 187 line = line.strip() + '\n' … … 120 190 121 191 os.remove( temp_name ) 122 123 def delete(self): 124 """Remove the file that corresponds to this data""" 125 obj.DBObj.delete(self) 126 try: 127 os.remove(self.file_name) 128 except OSError, e: 129 log.critical('%s delete error %s' % (self.__class__.__name__, e)) 130 131 # Removed for now ... this should be handled specifically by the registry 132 ## def get_mime(self): 133 ## """Returns the mime type of the data""" 134 ## return galaxy.datatypes.registry.Registry().get_mimetype_by_extension( self.extension.lower() ) 192 193 def get_mime(self): 194 """Returns the mime type of the datatype""" 195 return 'text/plain' 135 196 136 197 def set_peek(self, dataset): … … 141 202 """Binary data""" 142 203 143 """Provide the set of display formats supported by this datatype """144 supported_display_apps = []145 146 204 def set_peek( self, dataset ): 205 """Set the peek and blurb text""" 147 206 dataset.peek = 'binary data' 148 207 dataset.blurb = 'data' lib/galaxy/datatypes/images.py
r1 r410 15 15 dataset.blurb = 'image' 16 16 17 17 18 class Gmaj( data.Data ): 18 19 """Class describing a GMAJ Applet""" … … 26 27 except: 27 28 return "peek unavailable" 28 29 def get_mime(self): 30 """Returns the mime type of the datatype""" 31 return 'application/zip' 32 33 29 34 class Laj( data.Text ): 30 35 """Class describing a LAJ Applet""" … … 46 51 dataset.blurb = data.nice_size( dataset.get_size() ) 47 52 48 def display_peek(self, dataset): 49 try: 50 return dataset.peek 51 except: 52 return "peek unavailable" 53 def get_mime(self): 54 """Returns the mime type of the datatype""" 55 return 'text/html' lib/galaxy/datatypes/interval.py
r408 r410 10 10 from galaxy import util 11 11 from cgi import escape 12 import urllib 12 13 from bx.intervals.io import * 13 14 from galaxy.datatypes.metadata import MetadataElement … … 36 37 """Tab delimited data containing interval information""" 37 38 38 """Provide the set of display formats supported by this datatype """39 supported_display_apps = ['ucsc']40 41 39 """Add metadata elements""" 42 40 MetadataElement( name="chromCol" ) … … 45 43 MetadataElement( name="strandCol" ) 46 44 45 46 def __init__(self, **kwd): 47 """Initialize interval datatype, by adding UCSC display apps""" 48 Tabular.__init__(self, **kwd) 49 self.add_display_app ( 'ucsc', 'display at UCSC', 'as_ucsc_display_file', 'ucsc_links' ) 50 47 51 def missing_meta( self, dataset ): 48 52 """Checks for empty meta values""" … … 53 57 return False 54 58 55 56 59 def init_meta( self, dataset, copy_from=None ): 57 60 Tabular.init_meta( self, dataset, copy_from=copy_from ) 58 61 for key in alias_spec: 59 62 setattr( dataset.metadata, key, '' ) 60 setattr( dataset.metadata, 'strandCol', '0' ) 63 setattr( dataset.metadata, 'strandCol', '0' ) 61 64 62 65 def set_peek( self, dataset ): 66 """Set the peek and blurb text""" 63 67 dataset.peek = data.get_file_peek( dataset.file_name ) 64 68 ## dataset.peek = self.make_html_table( dataset.peek ) 65 69 dataset.blurb = util.commaify( str( data.get_line_count( dataset.file_name ) ) ) + " regions" 70 #i don't think set_meta should not be called here, it should be called separately 66 71 self.set_meta( dataset ) 67 72 … … 86 91 del valid[lower] # removes lower priority keys 87 92 dataset.mark_metadata_changed() 88 93 89 94 def get_estimated_display_viewport( self, dataset ): 90 95 """Return a chrom, start, stop tuple for viewing a file.""" … … 108 113 stop = max( stop, int( p[e] ) ) 109 114 except Exception, exc: 110 log.error( 'Viewport generation error -> %s ' % str(exc) )115 #log.error( 'Viewport generation error -> %s ' % str(exc) ) 111 116 (chr, start, stop) = 'chr1', 1, 1000 112 117 return (chr, str( start ), str( stop )) … … 114 119 return ('', '', '') 115 120 116 def as_ucsc_display_file( self, dataset ):117 """Returns a file that containsonly the bed data"""121 def as_ucsc_display_file( self, dataset, **kwd ): 122 """Returns file contents with only the bed data""" 118 123 fd, temp_name = tempfile.mkstemp() 119 124 c, s, e, t = dataset.metadata.chromCol, dataset.metadata.startCol, dataset.metadata.endCol, dataset.metadata.strandCol … … 130 135 os.write(fd, '%s\n' % '\t'.join(tmp) ) 131 136 os.close(fd) 132 return temp_name 137 return open(temp_name) 138 139 def ucsc_links( self, dataset, type, app, base_url ): 140 ret_val = [] 141 if dataset.has_data: 142 viewport_tuple = self.get_estimated_display_viewport(dataset) 143 if viewport_tuple: 144 chrom = viewport_tuple[0] 145 start = viewport_tuple[1] 146 stop = viewport_tuple[2] 147 for site_name, site_url in util.get_ucsc_by_build(dataset.dbkey): 148 if site_name in app.config.ucsc_display_sites: 149 display_url = urllib.quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) ) 150 link = "%sdb=%s&position=%s:%s-%s&hgt.customText=%s" % (site_url, dataset.dbkey, chrom, start, stop, display_url ) 151 ret_val.append( (site_name, link) ) 152 return ret_val 133 153 134 154 def validate( self, dataset ): … … 161 181 """Tab delimited data in BED format""" 162 182 163 """Provide the set of display formats supported by this datatype """164 supported_display_apps = ['ucsc']165 166 167 183 """Add metadata elements""" 168 184 MetadataElement( name="chromCol", default=1 ) … … 177 193 def init_meta( self, dataset, copy_from=None ): 178 194 Interval.init_meta( self, dataset, copy_from=copy_from ) 179 195 180 196 def set_meta( self, dataset ): 181 197 """ … … 201 217 dataset.mark_metadata_changed() 202 218 203 def as_ucsc_display_file( self, dataset ):204 """Returns a file that containsonly the bed data. If bed 6+, treat as interval."""219 def as_ucsc_display_file( self, dataset, **kwd ): 220 """Returns file contents with only the bed data. If bed 6+, treat as interval.""" 205 221 for line in open(dataset.file_name): 206 222 line = line.strip() … … 233 249 break 234 250 235 try: return dataset.file_name251 try: return open(dataset.file_name) 236 252 except: return "This item contains no content" 237 238 def get_estimated_display_viewport( self, dataset ):239 #TODO: fix me...240 return Interval.get_estimated_display_viewport( self, dataset )241 253 242 254 class Gff( Tabular ): 243 255 """Tab delimited data in Gff format""" 244 256 245 """Provide the set of display formats supported by this datatype """ 246 supported_display_apps = ['gbrowse'] 247 248 def __init__(self, id=None): 249 data.Text.__init__(self, id=id) 257 def __init__(self, **kwd): 258 """Initialize datatype, by adding GBrowse display app""" 259 Tabular.__init__(self, **kwd) 260 self.add_display_app ('gbrowse', 'display in GBrowse', 'as_gbrowse_display_file', 'gbrowse_links' ) 250 261 251 262 def make_html_table(self, data): 252 263 return Tabular.make_html_table(self, data, skipchar='#') 253 264 254 def as_gbrowse_display_file( self, dataset ):255 '''Returns a file that can be displayed in GBrowse apps.'''265 def as_gbrowse_display_file( self, dataset, **kwd ): 266 """Returns file contents that can be displayed in GBrowse apps.""" 256 267 #TODO: fix me... 257 return dataset.file_name268 return open(dataset.file_name) 258 269 259 270 def get_estimated_display_viewport( self, dataset ): … … 290 301 stop = max( stop, int( p[stop_col] ) ) 291 302 except Exception, exc: 292 log.error( 'Viewport generation error -> %s ' % str(exc) )303 #log.error( 'Viewport generation error -> %s ' % str(exc) ) 293 304 seqid, start, stop = ('', '', '') 294 305 return (seqid, str( start ), str( stop )) … … 296 307 return ('', '', '') 297 308 309 def gbrowse_links( self, dataset, type, app, base_url ): 310 ret_val = [] 311 if dataset.has_data: 312 viewport_tuple = self.get_estimated_display_viewport(dataset) 313 if viewport_tuple: 314 chrom = viewport_tuple[0] 315 start = viewport_tuple[1] 316 stop = viewport_tuple[2] 317 for site_name, site_url in util.get_gbrowse_sites_by_build(dataset.dbkey): 318 if site_name in app.config.gbrowse_display_sites: 319 display_url = urllib.quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) ) 320 link = "%sname=%s&ref=%s:%s..%s&eurl=%s" % (site_url, dataset.dbkey, chrom, start, stop, display_url ) 321 ret_val.append( (site_name, link) ) 322 return ret_val 323 298 324 class Wiggle( Tabular ): 299 325 """Tab delimited data in wiggle format""" 300 301 """Provide the set of display formats supported by this datatype """302 supported_display_apps = []303 304 def __init__(self, id=None):305 data.Text.__init__(self, id=id)306 326 307 327 def make_html_table(self, data): 308 328 return Tabular.make_html_table(self, data, skipchar='#') 309 310 def get_estimated_display_viewport( self, dataset ):311 #TODO: fix me...312 return ('', '', '')313 329 314 330 #Extend Tabular type, since interval tools will fail on track def line (we should fix this) … … 316 332 class CustomTrack ( Tabular ): 317 333 """UCSC CustomTrack""" 318 319 """Provide the set of display formats supported by this datatype """ 320 supported_display_apps = ['ucsc'] 321 322 def __init__(self, id=None): 323 data.Text.__init__(self, id=id) 334 335 def __init__(self, **kwd): 336 """Initialize interval datatype, by adding UCSC display app""" 337 Tabular.__init__(self, **kwd) 338 self.add_display_app ( 'ucsc', 'display at UCSC', 'as_ucsc_display_file', 'ucsc_links' ) 324 339 325 340 def make_html_table(self, dataset): 326 341 return Tabular.make_html_table(self, dataset, skipchar='track') 327 328 342 def get_estimated_display_viewport( self, dataset ): 329 343 try: … … 345 359 346 360 def as_ucsc_display_file( self, dataset ): 347 return dataset.file_name 361 return open(dataset.file_name) 362 def ucsc_links( self, dataset, type, app, base_url ): 363 ret_val = [] 364 if dataset.has_data: 365 viewport_tuple = self.get_estimated_display_viewport(dataset) 366 if viewport_tuple: 367 chrom = viewport_tuple[0] 368 start = viewport_tuple[1] 369 stop = viewport_tuple[2] 370 for site_name, site_url in util.get_ucsc_by_build(dataset.dbkey): 371 if site_name in app.config.ucsc_display_sites: 372 display_url = urllib.quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) ) 373 link = "%sdb=%s&position=%s:%s-%s&hgt.customText=%s" % (site_url, dataset.dbkey, chrom, start, stop, display_url ) 374 ret_val.append( (site_name, link) ) 375 return ret_val 376 377 378 348 379 349 380 #Extend Tabular type, since interval tools will fail on track def line (we should fix this) 350 #This is a skeleton class for now, allows viewing at ucscand formatted peeking.381 #This is a skeleton class for now, allows viewing at GBrowse and formatted peeking. 351 382 class GBrowseTrack ( Tabular ): 352 383 353 """Provide the set of display formats supported by this datatype """354 supported_display_apps = ['gbrowse']355 356 def __init__(self, id=None):357 data.Text.__init__(self, id=id) 384 def __init__(self, **kwd): 385 """Initialize datatype, by adding GBrowse display app""" 386 Tabular.__init__(self, **kwd) 387 self.add_display_app ('gbrowse', 'display in GBrowse', 'as_gbrowse_display_file', 'gbrowse_links' ) 388 358 389 359 390 def make_html_table(self, dataset): 360 391 return Tabular.make_html_table(self, dataset, skipchar='track') 361 392 362 def display_formats_supported( self, dataset ):363 return set(['gbrowse track'])364 365 393 def get_estimated_display_viewport( self, dataset ): 366 394 #TODO: fix me... 367 395 return ('', '', '') 396 397 def gbrowse_links( self, dataset, type, app, base_url ): 398 ret_val = [] 399 if dataset.has_data: 400 viewport_tuple = self.get_estimated_display_viewport(dataset) 401 if viewport_tuple: 402 chrom = viewport_tuple[0] 403 start = viewport_tuple[1] 404 stop = viewport_tuple[2] 405 for site_name, site_url in util.get_gbrowse_sites_by_build(dataset.dbkey): 406 if site_name in app.config.gbrowse_display_sites: 407 display_url = urllib.quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) ) 408 link = "%sname=%s&ref=%s:%s..%s&eurl=%s" % (site_url, dataset.dbkey, chrom, start, stop, display_url ) 409 ret_val.append( (site_name, link) ) 410 return ret_val 411 412 def as_gbrowse_display_file( self, dataset, **kwd ): 413 """Returns file contents that can be displayed in GBrowse apps.""" 414 #TODO: fix me... 415 return open(dataset.file_name) 368 416 369 417 if __name__ == '__main__': 370 418 import doctest, sys 371 doctest.testmod(sys.modules[__name__]) 419 doctest.testmod(sys.modules[__name__]) lib/galaxy/datatypes/registry.py
r408 r410 12 12 for ext, kind in datatypes: 13 13 try: 14 mime_type = 'text/plain' #default type of plain text14 mime_type = None 15 15 fields = kind.split(",") 16 16 if len(fields)>1: … … 24 24 for mod in fields: module = getattr(module,mod) 25 25 self.datatypes_by_extension[ext] = getattr(module, datatype_class)() 26 if mime_type is None: 27 # Use default mime type as per datatype spec 28 mime_type = self.datatypes_by_extension[ext].get_mime() 26 29 self.mimetypes_by_extension[ext] = mime_type 27 30 except: lib/galaxy/datatypes/sequence.py
r365 r410 10 10 class Sequence( data.Text ): 11 11 """Class describing a sequence""" 12 pass 12 13 13 """Provide the set of display formats supported by this datatype """14 supported_display_apps = []15 14 16 15 class Fasta( Sequence ): 17 16 """Class representing a FASTA sequence""" 18 19 """Provide the set of display formats supported by this datatype """20 supported_display_apps = []21 17 22 18 def set_peek( self, dataset ): … … 34 30 dataset.blurb = '%d sequences' % count 35 31 36 def get_estimated_display_viewport( self, dataset ):37 #TODO: fix me...38 return ('', '', '')39 40 32 class Maf( Sequence ): 41 33 """Class describing a Maf alignment""" 42 43 """Provide the set of display formats supported by this datatype """ 44 supported_display_apps = [] 34 pass 45 35 46 36 class Axt( Sequence ): 47 37 """Class describing an axt alignment""" 48 49 """Provide the set of display formats supported by this datatype """ 50 supported_display_apps = [] 51 38 pass 39 52 40 class Lav( Sequence ): 53 41 """Class describing a LAV alignment""" 54 55 """Provide the set of display formats supported by this datatype """ 56 supported_display_apps = [] 42 pass lib/galaxy/datatypes/tabular.py
r408 r410 12 12 from galaxy.datatypes.metadata import MetadataElement 13 13 from galaxy.datatypes.metadata import MetadataAttributes 14 15 14 log = logging.getLogger(__name__) 16 15 … … 19 18 """Tab delimited data""" 20 19 21 """Provide the set of display formats supported by this datatype """22 supported_display_apps = []23 24 20 MetadataElement( name="columns", 25 21 default=0, … … 44 40 except: 45 41 pass 46 47 42 def missing_meta( self, dataset ): 48 43 """Checks for empty meta values""" … … 53 48 54 49 def make_html_table(self, data, skipchar=None): 50 """Create HTML table, used for displaying peek""" 55 51 out = ['<table cellspacing="0" cellpadding="3">'] 56 52 first = True … … 90 86 return out 91 87 92 def get_estimated_display_viewport( self, dataset ):93 #TODO: fix me...94 return ('', '', '')95 96 88 def display_peek( self, dataset ): 89 """Returns formated html of peek""" 97 90 m_peek = self.make_html_table( dataset.peek ) 98 91 return m_peek lib/galaxy/interfaces/root.py
r391 r410 109 109 if toext[0:1] != ".": 110 110 toext = "." + toext 111 trans.response.headers["Content-Disposition"] = "attachment; filename=GalaxyHistoryItem-%s%s" % (data.hid, toext) 111 valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 112 fname = data.name 113 fname = ''.join(c in valid_chars and c or '_' for c in fname)[0:150] 114 trans.response.headers["Content-Disposition"] = "attachment; filename=GalaxyHistoryItem-%s-[%s]%s" % (data.hid, fname, toext) 112 115 trans.log_event( "Display dataset id: %s" % str(id) ) 113 116 try: … … 119 122 120 123 @web.expose 121 def display_as( self, trans, id=None, display_app= "ucsc"):124 def display_as( self, trans, id=None, display_app=None, **kwd ): 122 125 """Returns a file in a format that can successfully be displayed in display_app""" 123 126 data = self.app.model.Dataset.get( id ) 124 127 if data: 125 if display_app == 'ucsc': 126 mime = trans.app.datatypes_registry.get_mimetype_by_extension( data.extension.lower() ) 127 trans.response.set_content_type(mime) 128 file_name = data.as_ucsc_display_file() 129 trans.log_event( "Formatted dataset id %s for display at UCSC" % str(id) ) 130 return open(file_name) 131 elif display_app == 'gbrowse': 132 mime = trans.app.datatypes_registry.get_mimetype_by_extension( data.extension.lower() ) 133 trans.response.set_content_type(mime) 134 file_name = data.as_gbrowse_display_file() 135 trans.log_event( "Formatted dataset id %s for display at GBrowse" % str(id) ) 136 return open(file_name) 137 else: 138 return "Dataset '%s' cannot be displayed at %s." %(data.name, display_app) 128 trans.response.set_content_type(data.get_mime()) 129 trans.log_event( "Formatted dataset id %s for display at %s" % ( str(id), display_app ) ) 130 return data.as_display_type(display_app, **kwd) 139 131 else: 140 132 return "No data with id=%d" % id lib/galaxy/model/__init__.py
r400 r410 211 211 def get_raw_data( self ): 212 212 """Returns the full data. To stream it open the file_name and read/write as needed""" 213 try: 214 return file(self.file_name, 'rb').read(-1) 215 except OSError, e: 216 log.exception('%s reading a file that does not exist %s' % (self.__class__.__name__)) 217 return '' 218 def write_from_stream(self, stream): 219 "Writes data from a stream" 220 # write it twice for now 221 fd, temp_name = tempfile.mkstemp() 222 while 1: 223 chunk = stream.read(1048576) 224 if not chunk: 225 break 226 os.write(fd, chunk) 227 os.close(fd) 228 # rewrite the file with unix newlines 229 fp = open(self.file_name, 'wt') 230 for line in file(temp_name, "U"): 231 line = line.strip() + '\n' 232 fp.write(line) 233 fp.close() 234 def set_raw_data(self, data): 213 return self.datatype.get_raw_data( self ) 214 def write_from_stream( self, stream ): 215 """Writes data from a stream""" 216 self.datatype.write_from_stream(self, stream) 217 def set_raw_data( self, data ): 235 218 """Saves the data on the disc""" 236 fd, temp_name = tempfile.mkstemp() 237 os.write(fd, data) 238 os.close(fd) 239 # rewrite the file with unix newlines 240 fp = open(self.file_name, 'wt') 241 for line in file(temp_name, "U"): 242 line = line.strip() + '\n' 243 fp.write(line) 244 fp.close() 245 os.remove( temp_name ) 246 def get_mime(self): 219 self.datatype.set_raw_data(self, data) 220 def get_mime( self ): 247 221 """Returns the mime type of the data""" 248 222 return datatypes_registry.get_mimetype_by_extension( self.extension.lower() ) … … 255 229 def missing_meta( self ): 256 230 return self.datatype.missing_meta( self ) 257 def get_estimated_display_viewport( self ): 258 return self.datatype.get_estimated_display_viewport( self ) 259 def as_ucsc_display_file( self ): 260 return self.datatype.as_ucsc_display_file( self ) 261 def as_gbrowse_display_file( self ): 262 return self.datatype.as_gbrowse_display_file( self ) 231 def as_display_type( self, type, **kwd ): 232 return self.datatype.as_display_type( self, type, **kwd ) 263 233 def display_peek( self ): 264 234 return self.datatype.display_peek( self ) … … 267 237 def display_info( self ): 268 238 return self.datatype.display_info( self ) 269 def get_ucsc_sites( self ):270 return self.datatype.get_ucsc_sites( self )271 def get_gbrowse_sites( self ):272 return self.datatype.get_gbrowse_sites( self )273 239 def get_child_by_designation(self, designation): 274 240 # if self.history: templates/history.tmpl
r403 r410 256 256 <div class="info">Info: $data.display_info </div> 257 257 <div> 258 #if $data. ext in [ "bed", "interval", "tabular", "txt", "text", "axt", "maf", "fasta", "gff", "gmaj.zip" ]:258 #if $data.has_data: 259 259 <a href="display?id=$data.id&tofile=yes&toext=$data.ext" target="_blank">save</a> 260 #end if 261 262 #if $data.has_data and "ucsc" in $data.datatype.supported_display_apps: 263 #set $viewport_tuple = $data.get_estimated_display_viewport() 264 #if $viewport_tuple 265 #set $chrom = $viewport_tuple[0] 266 #set $start = $viewport_tuple[1] 267 #set $stop = $viewport_tuple[2] 268 #set $displayed = "false" 269 #for $site_name,$site_url in $data.get_ucsc_sites: 270 #if $site_name in $app.config.ucsc_display_sites: 271 #if $displayed == "false": 272 | display at UCSC 273 #set $displayed = "true" 274 #end if 275 <a target="_blank" href="$[site_url]db=$data.dbkey&position=$chrom:$start-$stop&hgt.customText=$request.base/display_as?id=$data.id&display_app=ucsc">$site_name</a> 276 #end if 277 #end for 278 #end if 279 #end if 280 281 #if $data.has_data and "gbrowse" in $data.datatype.supported_display_apps: 282 #set $viewport_tuple = $data.get_estimated_display_viewport() 283 #if $viewport_tuple 284 #set $chrom = $viewport_tuple[0] 285 #set $start = $viewport_tuple[1] 286 #set $stop = $viewport_tuple[2] 287 #set $displayed = "false" 288 #for $site_name, $site_url in $data.get_gbrowse_sites: 289 #if $site_name in $app.config.gbrowse_display_sites: 290 #if $displayed == "false": 291 | display in GBrowse 292 #set $displayed = "true" 293 #end if 294 <a target="_blank" href="$[site_url]&name=$data.dbkey&ref=$chrom:$start..$stop&eurl=$request.base/display_as?id=$data.id&display_app=gbrowse">$site_name</a> 295 #end if 296 #end for 297 #end if 298 #end if 299 260 #for $display_app in $data.datatype.get_display_types(): 261 #set $display_links = $data.datatype.get_display_links($data, $display_app, $app, $request.base) 262 #if $len($display_links) > 0: 263 | $data.datatype.get_display_label($display_app) 264 #for $display_name, $display_link in display_links: 265 <a target="_blank" href="$display_link">$display_name</a> 266 #end for 267 #end if 268 #end for 269 #end if 300 270 </div> 301 271 #if $data.peek != "no peek" templates/root/index.tmpl
r399 r410 3 3 <html lang="en"> 4 4 <head> 5 <link rel="stylesheet" type="text/css" href="$h.url_for('/static/style/reset.css')"></link> 5 <title>Galaxy</title> 6 <link rel="stylesheet" type="text/css" href="$h.url_for('/static/style/reset.css')"></link> 6 7 <script type="text/javascript" src="$h.url_for('/static/scripts/jquery.js')"></script> 7 8 <script type="text/javascript" src="$h.url_for('/static/scripts/jquery.dimensions.js')"></script> universe_wsgi.ini.sample
r365 r410 130 130 customtrack = galaxy.datatypes.interval:CustomTrack 131 131 gbrowsetrack = galaxy.datatypes.interval:GBrowseTrack 132 #EMBOSS TOOLS 133 match = galaxy.datatypes.data:Text 134 genbank = galaxy.datatypes.data:Text 135 motif = galaxy.datatypes.data:Text 136 acedb = galaxy.datatypes.data:Text 137 nexus = galaxy.datatypes.data:Text 138 fitch = galaxy.datatypes.data:Text 139 meganon = galaxy.datatypes.data:Text 140 codata = galaxy.datatypes.data:Text 141 dbmotif = galaxy.datatypes.data:Text 142 table = galaxy.datatypes.data:Text 143 pir = galaxy.datatypes.data:Text 144 ig = galaxy.datatypes.data:Text 145 seqtable = galaxy.datatypes.data:Text 146 clustal = galaxy.datatypes.data:Text 147 gcg = galaxy.datatypes.data:Text 148 hennig86 = galaxy.datatypes.data:Text 149 excel = galaxy.datatypes.data:Text 150 asn1 = galaxy.datatypes.data:Text 151 regions = galaxy.datatypes.data:Text 152 simple = galaxy.datatypes.data:Text 153 score = galaxy.datatypes.data:Text 154 msf = galaxy.datatypes.data:Text 155 selex = galaxy.datatypes.data:Text 156 tagseq = galaxy.datatypes.data:Text 157 embl = galaxy.datatypes.data:Text 158 srspair = galaxy.datatypes.data:Text 159 staden = galaxy.datatypes.data:Text 160 strider = galaxy.datatypes.data:Text 161 markx10 = galaxy.datatypes.data:Text 162 pair = galaxy.datatypes.data:Text 163 markx1 = galaxy.datatypes.data:Text 164 markx0 = galaxy.datatypes.data:Text 165 markx3 = galaxy.datatypes.data:Text 166 markx2 = galaxy.datatypes.data:Text 167 jackknifer = galaxy.datatypes.data:Text 168 ncbi = galaxy.datatypes.data:Text 169 mega = galaxy.datatypes.data:Text 170 feattable = galaxy.datatypes.data:Text 171 phylip = galaxy.datatypes.data:Text 172 diffseq = galaxy.datatypes.data:Text 173 srs = galaxy.datatypes.data:Text 174 jackknifernon = galaxy.datatypes.data:Text 175 swiss = galaxy.datatypes.data:Text 176 phylipnon = galaxy.datatypes.data:Text 177 nexusnon = galaxy.datatypes.data:Text 178 nametable = galaxy.datatypes.data:Text