[hg] galaxy 3812: First pass at implementing a method for allowi...
details: http://www.bx.psu.edu/hg/galaxy/rev/663b2fd4a44c changeset: 3812:663b2fd4a44c user: Dan Blankenberg <dan@bx.psu.edu> date: Mon May 24 14:15:02 2010 -0400 description: First pass at implementing a method for allowing a maximum file size cutoff for setting optional metadata (e.g. line and sequence counts). Currently csFasta, qualsolid, and fastq make use of this option. diffstat: datatypes_conf.xml.sample | 2 +- lib/galaxy/datatypes/data.py | 14 ++++++++++++++ lib/galaxy/datatypes/qualityscore.py | 7 +++++++ lib/galaxy/datatypes/registry.py | 2 ++ lib/galaxy/datatypes/sequence.py | 7 +++++++ 5 files changed, 31 insertions(+), 1 deletions(-) diffs (96 lines): diff -r 7faa12ac9746 -r 663b2fd4a44c datatypes_conf.xml.sample --- a/datatypes_conf.xml.sample Mon May 24 11:22:12 2010 -0400 +++ b/datatypes_conf.xml.sample Mon May 24 14:15:02 2010 -0400 @@ -33,7 +33,7 @@ </datatype> <datatype extension="customtrack" type="galaxy.datatypes.interval:CustomTrack"/> <datatype extension="csfasta" type="galaxy.datatypes.sequence:csFasta" display_in_upload="true"/> - <datatype extension="data" type="galaxy.datatypes.data:Data" mimetype="application/octet-stream"/> + <datatype extension="data" type="galaxy.datatypes.data:Data" mimetype="application/octet-stream" max_optional_metadata_filesize="1048576" /> <datatype extension="fasta" type="galaxy.datatypes.sequence:Fasta" display_in_upload="true"> <converter file="fasta_to_tabular_converter.xml" target_datatype="tabular"/> </datatype> diff -r 7faa12ac9746 -r 663b2fd4a44c lib/galaxy/datatypes/data.py --- a/lib/galaxy/datatypes/data.py Mon May 24 11:22:12 2010 -0400 +++ b/lib/galaxy/datatypes/data.py Mon May 24 14:15:02 2010 -0400 @@ -57,6 +57,8 @@ composite_type = None composite_files = odict() primary_file_name = 'index' + #A per datatype setting (inherited): max file size (in bytes) for setting optional metadata + _max_optional_metadata_filesize = None def __init__(self, **kwd): """Initialize the datatype""" @@ -116,6 +118,18 @@ if not value: return True return False + def set_max_optional_metadata_filesize( self, max_value ): + try: + max_value = int( max_value ) + except: + return + self.__class__._max_optional_metadata_filesize = max_value + def get_max_optional_metadata_filesize( self ): + rval = self.__class__._max_optional_metadata_filesize + if rval is None: + return -1 + return rval + max_optional_metadata_filesize = property( get_max_optional_metadata_filesize, set_max_optional_metadata_filesize ) def set_peek( self, dataset, is_multi_byte=False ): """Set the peek and blurb text""" if not dataset.dataset.purged: diff -r 7faa12ac9746 -r 663b2fd4a44c lib/galaxy/datatypes/qualityscore.py --- a/lib/galaxy/datatypes/qualityscore.py Mon May 24 11:22:12 2010 -0400 +++ b/lib/galaxy/datatypes/qualityscore.py Mon May 24 14:15:02 2010 -0400 @@ -63,6 +63,13 @@ except: pass return False + + def set_meta( self, dataset, **kwd ): + if self.max_optional_metadata_filesize >= 0 and dataset.get_size() > self.max_optional_metadata_filesize: + return + return QualityScore.set_meta( self, dataset, **kwd ) + + class QualityScore454 ( QualityScore ): """ diff -r 7faa12ac9746 -r 663b2fd4a44c lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py Mon May 24 11:22:12 2010 -0400 +++ b/lib/galaxy/datatypes/registry.py Mon May 24 14:15:02 2010 -0400 @@ -64,6 +64,8 @@ self.available_tracks.append( extension ) if display_in_upload: self.upload_file_formats.append( extension ) + #max file size cut off for setting optional metadata + self.datatypes_by_extension[extension].max_optional_metadata_filesize = elem.get( 'max_optional_metadata_filesize', None ) for converter in elem.findall( 'converter' ): # Build the list of datatype converters which will later be loaded # into the calling app's toolbox. diff -r 7faa12ac9746 -r 663b2fd4a44c lib/galaxy/datatypes/sequence.py --- a/lib/galaxy/datatypes/sequence.py Mon May 24 11:22:12 2010 -0400 +++ b/lib/galaxy/datatypes/sequence.py Mon May 24 14:15:02 2010 -0400 @@ -148,6 +148,11 @@ except: pass return False + + def set_meta( self, dataset, **kwd ): + if self.max_optional_metadata_filesize >= 0 and dataset.get_size() > self.max_optional_metadata_filesize: + return + return Sequence.set_meta( self, dataset, **kwd ) class Fastq ( Sequence ): """Class representing a generic FASTQ sequence""" @@ -158,6 +163,8 @@ Set the number of sequences and the number of data lines in dataset. """ + if self.max_optional_metadata_filesize >= 0 and dataset.get_size() > self.max_optional_metadata_filesize: + return data_lines = 0 sequences = 0 seq_counter = 0 # blocks should be 4 lines long
participants (1)
-
Nate Coraor