mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
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.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -57,6 +57,8 @@ class Data( object ):
|
||||
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 @@ class Data( object ):
|
||||
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:
|
||||
|
||||
@@ -63,6 +63,13 @@ class QualityScoreSOLiD ( QualityScore ):
|
||||
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 ):
|
||||
"""
|
||||
|
||||
@@ -64,6 +64,8 @@ class Registry( object ):
|
||||
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.
|
||||
|
||||
@@ -148,6 +148,11 @@ class csFasta( Sequence ):
|
||||
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 @@ class Fastq ( Sequence ):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user