commit/galaxy-central: dannon: Refactor set_peek to a single method in class Text. Should also fix bug introduced in 5236 that prevented setting of some metadata.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/41a416e61021/ changeset: r5283:41a416e61021 user: dannon date: 2011-03-30 13:14:20 summary: Refactor set_peek to a single method in class Text. Should also fix bug introduced in 5236 that prevented setting of some metadata. affected #: 3 files (2.1 KB) --- a/lib/galaxy/datatypes/data.py Tue Mar 29 16:27:35 2011 -0400 +++ b/lib/galaxy/datatypes/data.py Wed Mar 30 07:14:20 2011 -0400 @@ -354,6 +354,7 @@ class Text( Data ): file_ext = 'txt' + line_class = 'line' """Add metadata elements""" MetadataElement( name="data_lines", default=0, desc="Number of data lines", readonly=True, optional=True, visible=False, no_value=0 ) @@ -417,26 +418,30 @@ data_lines += 1 return data_lines def set_peek( self, dataset, line_count=None, is_multi_byte=False ): + """ + Set the peek. This method is used by various subclasses of Text. + """ if not dataset.dataset.purged: # The file must exist on disk for the get_file_peek() method dataset.peek = get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) if line_count is None: # See if line_count is stored in the metadata - if dataset.metadata.data_lines is not None: - dataset.blurb = "%s %s" % ( util.commaify( str(dataset.metadata.data_lines) ), inflector.cond_plural(dataset.metadata.data_lines, "line") ) + if dataset.metadata.data_lines: + dataset.blurb = "%s %s" % ( util.commaify( str(dataset.metadata.data_lines) ), inflector.cond_plural(dataset.metadata.data_lines, self.line_class) ) else: # Number of lines is not known ( this should not happen ), and auto-detect is # needed to set metadata # This can happen when the file is larger than max_optional_metadata_filesize. if int(dataset.get_size()) <= 1048576: #Small dataset, recount all lines and reset peek afterward. - dataset.metadata.data_lines = self.count_data_lines(dataset) - self.set_peek(dataset) + lc = self.count_data_lines(dataset) + dataset.metadata.data_lines = lc + dataset.blurb = "%s %s" % util.commaify( str(lc) ), inflector.cond_plural(lc, self.line_class) else: est_lines = self.estimate_file_lines(dataset) - dataset.blurb = "~%s %s" % ( util.commaify(util.roundify(str(est_lines))), inflector.cond_plural(est_lines, "line") ) + dataset.blurb = "~%s %s" % ( util.commaify(util.roundify(str(est_lines))), inflector.cond_plural(est_lines, self.line_class) ) else: - dataset.blurb = "%s %s" % util.commaify( str(line_count) ), inflector.cond_plural(line_count, "line") + dataset.blurb = "%s %s" % util.commaify( str(line_count) ), inflector.cond_plural(line_count, self.line_class) else: dataset.peek = 'file does not exist' dataset.blurb = 'file purged from disk' --- a/lib/galaxy/datatypes/interval.py Tue Mar 29 16:27:35 2011 -0400 +++ b/lib/galaxy/datatypes/interval.py Wed Mar 30 07:14:20 2011 -0400 @@ -45,6 +45,7 @@ class Interval( Tabular ): """Tab delimited data containing interval information""" file_ext = "interval" + line_class = "region" """Add metadata elements""" MetadataElement( name="chromCol", default=1, desc="Chrom column", param=metadata.ColumnParameter ) @@ -60,23 +61,6 @@ self.add_display_app ( 'ucsc', 'display at UCSC', 'as_ucsc_display_file', 'ucsc_links' ) def init_meta( self, dataset, copy_from=None ): Tabular.init_meta( self, dataset, copy_from=copy_from ) - def set_peek( self, dataset, line_count=None, is_multi_byte=False ): - """Set the peek and blurb text""" - if not dataset.dataset.purged: - dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) - if line_count is None: - # See if line_count is stored in the metadata - if dataset.metadata.data_lines is not None: - dataset.blurb = "%s regions" % util.commaify( str( dataset.metadata.data_lines ) ) - else: - # Number of lines is not known ( this should not happen ), and auto-detect is - # needed to set metadata - dataset.blurb = "~%s regions" % util.commaify(util.roundify(str(self.estimate_file_lines(dataset)))) - else: - dataset.blurb = "%s regions" % util.commaify( str( line_count ) ) - else: - dataset.peek = 'file does not exist' - dataset.blurb = 'file purged from disk' def set_meta( self, dataset, overwrite = True, first_line_is_header = False, **kwd ): """Tries to guess from the line the location number of the column for the chromosome, region start-end and strand""" Tabular.set_meta( self, dataset, overwrite = overwrite, skip = 0 ) --- a/lib/galaxy/datatypes/tabular.py Tue Mar 29 16:27:35 2011 -0400 +++ b/lib/galaxy/datatypes/tabular.py Wed Mar 30 07:14:20 2011 -0400 @@ -223,8 +223,9 @@ out.append( '<tr><td>' ) out.append( '%s</td></tr>' % escape( comments.pop(0) ) ) return "".join( out ) - def set_peek( self, dataset, line_count=None, is_multi_byte=False ): - data.Text.set_peek( self, dataset, line_count=line_count, is_multi_byte=is_multi_byte ) + def set_peek( self, dataset, line_count=None, is_multi_byte=False): + print line_count + super(Tabular, self).set_peek( dataset, line_count=line_count, is_multi_byte=is_multi_byte) if dataset.metadata.comment_lines: dataset.blurb = "%s, %s comments" % ( dataset.blurb, util.commaify( str( dataset.metadata.comment_lines ) ) ) def display_peek( self, dataset ): @@ -383,6 +384,7 @@ class Pileup( Tabular ): """Tab delimited data in pileup (6- or 10-column) format""" file_ext = "pileup" + line_class = "genomic coordinate" """Add metadata elements""" MetadataElement( name="chromCol", default=1, desc="Chrom column", param=metadata.ColumnParameter ) @@ -392,24 +394,6 @@ def init_meta( self, dataset, copy_from=None ): Tabular.init_meta( self, dataset, copy_from=copy_from ) - def set_peek( self, dataset, line_count=None, is_multi_byte=False ): - """Set the peek and blurb text""" - if not dataset.dataset.purged: - dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) - if line_count is None: - # See if line_count is stored in the metadata - if dataset.metadata.data_lines is not None: - dataset.blurb = "%s genomic coordinates" % util.commaify( str( dataset.metadata.data_lines ) ) - else: - # Number of lines is not known ( this should not happen ), and auto-detect is - # needed to set metadata - dataset.blurb = "? genomic coordinates" - else: - dataset.blurb = "%s genomic coordinates" % util.commaify( str( line_count ) ) - else: - dataset.peek = 'file does not exist' - dataset.blurb = 'file purged from disk' - def make_html_table( self, dataset, skipchars=[] ): """Create HTML table, used for displaying peek""" out = ['<table cellspacing="0" cellpadding="3">'] Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket