- Fixed the MetadataMissingValidator and added a new UnspecifiedBuildValidator.

- Added the UnspecifiedBuildValidator to several tools.
- Added is_dynamic and get_dependencies() to DataToolParameter.
This commit is contained in:
Greg Von Kuster
2008-02-27 22:16:56 +00:00
parent 841a8e2ed5
commit 72bfcf8281
13 changed files with 75 additions and 20 deletions
+1 -1
View File
@@ -769,7 +769,7 @@ class Tool:
errors[ input.name ] = old_errors[ input.name ]
else:
incoming_value = incoming.get( key, None )
if ( incoming_value == 'None' or incoming_value == '?' ) and isinstance( input, SelectToolParameter ) and input.is_dynamic:
if ( incoming_value == 'None' or incoming_value == '?' ) and ( isinstance( input, SelectToolParameter ) or isinstance( input, DataToolParameter ) ) and input.is_dynamic:
# FIXME: This is a HACK, but is necessary because the
# values in incoming are not yet set by the user when
# the select list is dynamically generated.
+18 -9
View File
@@ -746,7 +746,8 @@ class DataToolParameter( ToolParameter ):
if options is None:
self.options = None
else:
self.options = dynamic_options.DynamicOptions( options, parameter_type = type( self ) )
self.options = dynamic_options.DynamicOptions( options, parameter_type=type( self ) )
self.is_dynamic = self.options is not None
def get_html_field( self, trans=None, value=None, other_values={} ):
filter_key = filter_value = None
@@ -756,7 +757,8 @@ class DataToolParameter( ToolParameter ):
history = trans.history
assert history is not None, "DataToolParameter requires a history"
if value is not None:
if type( value ) != list: value = [ value ]
if type( value ) != list:
value = [ value ]
field = form_builder.SelectField( self.name, self.multiple, None, self.refresh_on_change )
# CRUCIAL: the dataset_collector function needs to be local to DataToolParameter.get_html_field()
def dataset_collector( datasets, parent_hid ):
@@ -775,13 +777,11 @@ class DataToolParameter( ToolParameter ):
dataset_collector( history.datasets, None )
some_data = bool( field.options )
if some_data:
if value is None:
if value is None or len( field.options ) == 1:
# Ensure that the last item is always selected
a, b, c = field.options[-1]; field.options[-1] = a, b, True
else:
# HACK: we should just disable the form or something
field.add_option( "no data has the proper type", '' )
if self.optional == True:
a, b, c = field.options[-1]
field.options[-1] = a, b, True
elif self.optional:
field.add_option( "Selection is Optional", 'None', True )
return field
@@ -823,7 +823,7 @@ class DataToolParameter( ToolParameter ):
if trans.workflow_building_mode:
return None
if not value:
raise ValueError( "A data of the appropriate type is required" )
raise ValueError( "History does not include a dataset of the required format / build" )
if value in [None, "None"]:
temp_data = trans.app.model.Dataset( extension = 'data' )
temp_data.state = temp_data.states.OK
@@ -864,6 +864,15 @@ class DataToolParameter( ToolParameter ):
else:
return "No dataset"
def get_dependencies( self ):
"""
Get the *names* of the other params this param depends on.
"""
if self.options:
return self.options.get_dependency_names()
else:
return []
# class RawToolParameter( ToolParameter ):
# """
# Completely nondescript parameter, HTML representation is provided as text
+28 -1
View File
@@ -146,9 +146,35 @@ class MetadataValidator( Validator ):
"""
Validator that checks for missing metadata
"""
def __init__( self, message=None ):
self.message = message
@classmethod
def from_element( cls, elem ):
return cls( elem.get( 'message', None ) )
def validate( self, value, history=None ):
if value and value.missing_meta():
raise ValueError( "Metadata missing, click the pencil icon in the history item to edit / save the metadata attributes" )
if self.message is None:
self.message = "Metadata missing, click the pencil icon in the history item to edit / save the metadata attributes"
raise ValueError( self.message )
class UnspecifiedBuildValidator( Validator ):
"""
Validator that checks for missing metadata
"""
def __init__( self, message=None ):
self.message = message
@classmethod
def from_element( cls, elem ):
return cls( elem.get( 'message', None ) )
def validate( self, value, history=None ):
if value:
dbkey = value.metadata.dbkey
if isinstance( dbkey, list ):
dbkey = dbkey[0]
if dbkey == '?':
if self.message is None:
self.message = "Unspecified genome build, click the pencil icon in the history item to set the genome build"
raise ValueError( self.message )
class MetadataInFileColumnValidator( Validator ):
"""
@@ -185,6 +211,7 @@ validator_types = dict( expression=ExpressionValidator,
in_range=InRangeValidator,
length=LengthValidator,
metadata=MetadataValidator,
unspecified_build=UnspecifiedBuildValidator,
dataset_metadata_in_file=MetadataInFileColumnValidator )
def get_suite():
@@ -2,7 +2,9 @@
<description>create a random set of intervals</description>
<command interpreter="python2.4">random_intervals_no_bits.py $regions $input2 $input1 $out_file1 $input2_chromCol $input2_startCol $input2_endCol $input1_chromCol $input1_startCol $input1_endCol $input1_strandCol $use_mask $strand_overlaps</command>
<inputs>
<param name="input1" type="data" format="interval" label="File to Mimick"/>
<param name="input1" type="data" format="interval" label="File to Mimick">
<validator type="unspecified_build" message="Unspecified build, this tool works with data from genome builds hg16 or hg17. Click the pencil icon in your history item to set the genome build."/>
</param>
<param name="input2" type="data" format="interval" label="Intervals to Mask"/>
<param name="use_mask" type="select" label="Use mask">
<option value="no_mask">No</option>
@@ -4,6 +4,7 @@
<inputs>
<param format="interval" name="input" type="data" label="Between regions of Query"/>
<param name="species" type="select" label="and one of these genomes">
<validator type="unspecified_build" />
<options from_file="/depot/data2/galaxy/alignseq.loc" >
<filter type="data_meta" data_ref="input" key="build" />
<filter type="column" name="build_col" value="0" />
@@ -2,7 +2,9 @@
<description> between assemblies and genomes</description>
<command interpreter="python">liftOver_wrapper.py $input "$out_file1" "$out_file2" $dbkey $to_dbkey</command>
<inputs>
<param format="bed" name="input" type="data" label="Convert co-ordinates of" />
<param format="bed" name="input" type="data" label="Convert co-ordinates of">
<validator type="unspecified_build" />
</param>
<param name="to_dbkey" type="select" label="To">
<options from_file="/depot/data2/galaxy/liftOver.loc">
<filter type="data_meta" data_ref="input" key="build" />
@@ -2,7 +2,9 @@
<description>for each interval</description>
<command interpreter="python2.4">get_scores_galaxy.py $per_col ${score_file}.h5 ${score_file}.mapping.bed $input $output $input_chromCol $input_startCol $input_endCol</command>
<inputs>
<param format="interval" name="input" type="data" label="Interval file"/>
<param format="interval" name="input" type="data" label="Interval file">
<validator type="unspecified_build" message="Unspecified build, this tool works with data from genome builds hg17. Click the pencil icon in your history item to set the genome build."/>
</param>
<param name="score_file" type="select" label="Available datasets">
<options from_file="/depot/data2/galaxy/phastOdds.loc" >
<filter type="data_meta" data_ref="input" key="build" />
@@ -5,7 +5,9 @@
#end if
</command>
<inputs>
<param name="input1" type="data" format="bed" label="Gene BED File"/>
<param name="input1" type="data" format="bed" label="Gene BED File">
<validator type="unspecified_build" />
</param>
<conditional name="maf_source_type">
<param name="maf_source" type="select" label="MAF Source">
<option value="cached" selected="true">Locally Cached Alignments</option>
@@ -6,7 +6,9 @@
#end if
</command>
<inputs>
<param format="interval" name="input1" type="data" label="Choose intervals"/>
<param format="interval" name="input1" type="data" label="Choose intervals">
<validator type="unspecified_build" />
</param>
<conditional name="maf_source_type">
<param name="maf_source" type="select" label="MAF Source">
<option value="cached" selected="true">Locally Cached Alignments</option>
@@ -2,7 +2,9 @@
<description>given a set of genomic intervals</description>
<command interpreter="python2.4">interval2maf.py --dbkey=$input1_dbkey --chromCol=$input1_chromCol --startCol=$input1_startCol --endCol=$input1_endCol --strandCol=$input1_strandCol --mafType=$mafType --interval_file=$input1 --output_file=$out_file1 --indexLocation=/depot/data2/galaxy/maf_pairwise.loc</command>
<inputs>
<param name="input1" type="data" format="interval" label="Interval File"/>
<param name="input1" type="data" format="interval" label="Interval File">
<validator type="unspecified_build" />
</param>
<param name="mafType" type="select" label="Choose MAF source">
<options from_file="/depot/data2/galaxy/maf_pairwise.loc">
<filter type="data_meta" data_ref="input1" key="build" />
@@ -6,7 +6,9 @@
</command>
<inputs>
<page>
<param format="interval" name="input1" type="data" label="Choose intervals"/>
<param format="interval" name="input1" type="data" label="Choose intervals">
<validator type="unspecified_build" />
</param>
<conditional name="maf_source_type">
<param name="maf_source" type="select" label="MAF Source">
<option value="cached" selected="true">Locally Cached Alignments</option>
+3 -1
View File
@@ -9,7 +9,9 @@
#end if
</command>
<inputs>
<param format="interval" name="input1" label="Interval File" type="data"/>
<param format="interval" name="input1" label="Interval File" type="data">
<validator type="unspecified_build" />
</param>
<conditional name="maf_source_type">
<param name="maf_source" type="select" label="MAF Source">
<option value="cached" selected="true">Locally Cached Alignments</option>
@@ -6,7 +6,9 @@
#end if
</command>
<inputs>
<param format="interval" name="input1" type="data" label="Interval file"/>
<param format="interval" name="input1" type="data" label="Interval file">
<validator type="unspecified_build" message="Unspecified build, this tool works with data from genome builds hg16, hg17 or hg18. Click the pencil icon in your history item to set the genome build."/>
</param>
<conditional name="score_source_type">
<param name="score_source" type="select" label="Score Source">
<option value="cached" selected="true">Locally Cached Scores</option>