commit/galaxy-central: dan: Better determination in tests if a provided input is a DataToolParameter to better handle .gz and .zip uploads and allowing uploads from a sub-directory of test-data/.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/4d2d7c952d87/ changeset: r5142:4d2d7c952d87 user: dan date: 2011-02-28 18:16:28 summary: Better determination in tests if a provided input is a DataToolParameter to better handle .gz and .zip uploads and allowing uploads from a sub-directory of test-data/. affected #: 16 files (2.5 KB) --- a/lib/galaxy/tools/test.py Mon Feb 28 09:59:30 2011 -0500 +++ b/lib/galaxy/tools/test.py Mon Feb 28 12:16:28 2011 -0500 @@ -1,4 +1,5 @@ import new, sys +import os.path import galaxy.util import parameters from parameters import basic @@ -12,7 +13,7 @@ """ Encapsulates information about a tool test, and allows creation of a dynamic TestCase class (the unittest framework is very class oriented, - doing dynamic tests in this was allows better integration) + doing dynamic tests in this way allows better integration) """ def __init__( self, tool, name, maxseconds ): self.tool = tool @@ -26,19 +27,17 @@ def add_param( self, name, value, extra ): try: if name not in self.tool.inputs: + found_parameter = False for input_name, input_value in self.tool.inputs.items(): - if isinstance( input_value, grouping.Conditional ) or isinstance( input_value, grouping.Repeat ): - self.__expand_grouping_for_data_input(name, value, extra, input_name, input_value) - elif isinstance( self.tool.inputs[name], parameters.DataToolParameter ) and ( value, extra ) not in self.required_files: - name_change = [ att for att in extra.get( 'edit_attributes', [] ) if att.get( 'type' ) == 'name' ] - if name_change: - name_change = name_change[-1].get( 'value' ) #only the last name change really matters - if value is None and not name_change: - assert self.tool.inputs[name].optional, '%s is not optional. You must provide a valid filename.' % name - else: - self.required_files.append( ( value, extra ) ) #these files will be uploaded - if name_change: - value = name_change #change value for select to renamed uploaded file for e.g. composite dataset + if isinstance( input_value, grouping.Group ): + found_parameter, new_value = self.__expand_grouping_for_data_input(name, value, extra, input_name, input_value) + if found_parameter: + value = new_value + break + if not found_parameter: + raise ValueError( "Unable to determine parameter type of test input '%s'. Ensure that the parameter exists and that any container groups are defined first." % name ) + elif isinstance( self.tool.inputs[name], basic.DataToolParameter ): + value = self.__add_uploaded_dataset( name, value, extra, self.tool.inputs[name] ) except Exception, e: log.debug( "Error in add_param for %s: %s" % ( name, e ) ) self.inputs.append( ( name, value, extra ) ) @@ -47,27 +46,65 @@ def __expand_grouping_for_data_input( self, name, value, extra, grouping_name, grouping_value ): # Currently handles grouping.Conditional and grouping.Repeat if isinstance( grouping_value, grouping.Conditional ): - if name != grouping_value.test_param.name: - for case in grouping_value.cases: - for case_input_name, case_input_value in case.inputs.items(): - if case_input_name == name and isinstance( case_input_value, basic.DataToolParameter ) and ( value, extra ) not in self.required_files: - if value is None: - assert case_input_value.optional, '%s is not optional. You must provide a valid filename.' % name - else: - self.required_files.append( ( value, extra ) ) - return True - elif isinstance( case_input_value, grouping.Conditional ): - self.__expand_grouping_for_data_input(name, value, extra, case_input_name, case_input_value) + if name == grouping_value.test_param.name: + return True, value + case_test_param_value = None + for input in self.inputs: + if input[0] == grouping_value.test_param.name: + case_test_param_value = input[1] + break + if case_test_param_value is None: + #case for this group has not been set yet + return False, value + for case in grouping_value.cases: + if case.value == case_test_param_value: + break + if case.value != case_test_param_value: + return False, value + #assert case.value == case_test_param_value, "Current case could not be determined for parameter '%s'. Provided value '%s' could not be found in '%s'." % ( grouping_value.name, value, grouping_value.test_param.name ) + if name in case.inputs: + if isinstance( case.inputs[name], basic.DataToolParameter ): + return True, self.__add_uploaded_dataset( name, value, extra, case.inputs[name] ) + else: + return True, value + else: + for input_name, input_parameter in case.inputs.iteritems(): + if isinstance( input_parameter, grouping.Group ): + found_parameter, new_value = self.__expand_grouping_for_data_input( name, value, extra, input_name, input_parameter ) + if found_parameter: + return True, new_value elif isinstance( grouping_value, grouping.Repeat ): # FIXME: grouping.Repeat can only handle 1 repeat param element since the param name # is something like "input2" and the expanded page display is something like "queries_0|input2". # The problem is that the only param name on the page is "input2", and adding more test input params - # with the same name ( "input2" ) is not yet supported in our test code ( the lat one added is the only - # one used ). - for input_name, input_value in grouping_value.inputs.items(): - if input_name == name and isinstance( input_value, basic.DataToolParameter ) and ( value, extra ) not in self.required_files: - if value is None: - assert input_value.optional, '%s is not optional. You must provide a valid filename.' % name - else: - self.required_files.append( ( value, extra ) ) - return True + # with the same name ( "input2" ) is not yet supported in our test code ( the last one added is the only + # one used ). + if name in grouping_value.inputs: + if isinstance( grouping_value.inputs[name], basic.DataToolParameter ): + return True, self.__add_uploaded_dataset( name, value, extra, grouping_value.inputs[name] ) + else: + return True, value + else: + for input_name, input_parameter in grouping_value.inputs.iteritems(): + if isinstance( input_parameter, grouping.Group ): + found_parameter, new_value = self.__expand_grouping_for_data_input( name, value, extra, input_name, input_parameter ) + if found_parameter: + return True, new_value + return False, value + def __add_uploaded_dataset( self, name, value, extra, input_parameter ): + if value is None: + assert input_parameter.optional, '%s is not optional. You must provide a valid filename.' % name + return value + if ( value, extra ) not in self.required_files: + self.required_files.append( ( value, extra ) ) #these files will be uploaded + name_change = [ att for att in extra.get( 'edit_attributes', [] ) if att.get( 'type' ) == 'name' ] + if name_change: + name_change = name_change[-1].get( 'value' ) #only the last name change really matters + value = name_change #change value for select to renamed uploaded file for e.g. composite dataset + else: + for end in [ '.zip', '.gz' ]: + if value.endswith( end ): + value = value[ :-len( end ) ] + break + value = os.path.basename( value ) #if uploading a file in a path other than root of test-data + return value --- a/test/functional/test_toolbox.py Mon Feb 28 09:59:30 2011 -0500 +++ b/test/functional/test_toolbox.py Mon Feb 28 12:16:28 2011 -0500 @@ -1,5 +1,4 @@ import sys, new -import os.path from galaxy.tools.parameters import grouping from galaxy.tools.parameters import basic from base.twilltestcase import TwillTestCase @@ -56,12 +55,6 @@ # tool will have uncompressed it on the fly. all_inputs = {} for name, value, _ in testdef.inputs: - if value: - for end in [ '.zip', '.gz' ]: - if value.endswith( end ): - value = value[ :-len( end ) ] - break - value = os.path.basename( value ) #if uploading a file in a path other than root of test-data all_inputs[ name ] = value # See if we have a grouping.Repeat element repeat_name = None --- a/tools/human_genome_variation/ldtools.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/human_genome_variation/ldtools.xml Mon Feb 28 12:16:28 2011 -0500 @@ -24,7 +24,7 @@ <param name="input" value="ldInput1.txt" /><param name="rsquare" value="0.64" /><param name="freq" value="0.00" /> - <param name="output" file="ldOutput1.txt" /> + <output name="output" file="ldOutput1.txt" /></test></tests> --- a/tools/maf/maf_to_fasta.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/maf/maf_to_fasta.xml Mon Feb 28 12:16:28 2011 -0500 @@ -38,15 +38,15 @@ <tests><test><param name="input1" value="3.maf" ftype="maf"/> + <param name="fasta_type" value="concatenated"/><param name="species" value="canFam1"/> - <param name="fasta_type" value="concatenated"/><output name="out_file1" file="cf_maf2fasta_concat.dat" ftype="fasta"/></test><test><param name="input1" value="4.maf" ftype="maf"/> + <param name="fasta_type" value="multiple"/><param name="species" value="hg17,panTro1,rheMac2,rn3,mm7,canFam2,bosTau2,dasNov1"/><param name="complete_blocks" value="partial_allowed"/> - <param name="fasta_type" value="multiple"/><output name="out_file1" file="cf_maf2fasta_new.dat" ftype="fasta"/></test></tests> --- a/tools/new_operations/intersect.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/new_operations/intersect.xml Mon Feb 28 12:16:28 2011 -0500 @@ -38,7 +38,6 @@ <code file="operation_filter.py"/><tests><test> - <param name="type" value="Interval"/><param name="input1" value="1.bed" /><param name="input2" value="2.bed" /><param name="min" value="1" /> @@ -46,7 +45,6 @@ <output name="output" file="gops_intersect_out.bed" /></test><test> - <param name="type" value="Interval"/><param name="input1" value="1.bed" /><param name="input2" value="2_mod.bed" ftype="interval"/><param name="min" value="1" /> --- a/tools/next_gen_conversion/solid2fastq.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/next_gen_conversion/solid2fastq.xml Mon Feb 28 12:16:28 2011 -0500 @@ -54,9 +54,9 @@ <test><param name="input1" value="fr.csfasta" ftype="csfasta"/><param name="input2" value="fr.qualsolid" ftype="qualsolid" /> + <param name="paired" value="yes"/><param name="input3" value="rr.csfasta" ftype="csfasta"/><param name="input4" value="rr.qualsolid" ftype="qualsolid" /> - <param name="paired" value="yes"/><param name="qual" value="0" /><param name="trim_first_base" value="No" /><param name="trim_name" value="Yes" /> --- a/tools/peak_calling/macs_wrapper.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/peak_calling/macs_wrapper.xml Mon Feb 28 12:16:28 2011 -0500 @@ -140,10 +140,10 @@ </configfiles><tests><test> + <param name="input_type_selector" value="single_end" /><param name="input_chipseq_file1" value="chipseq_enriched.bed.gz" ftype="bed" /><param name="input_control_file1" value="chipseq_input.bed.gz" ftype="bed" /><param name="experiment_name" value="Galaxy Test Run" /> - <param name="input_type_selector" value="single_end" /><param name="tsize" value="36" /><param name="mfold" value="13" /><param name="gsize" value="2.7e+9" /> @@ -166,10 +166,10 @@ </output></test><test> + <param name="input_type_selector" value="single_end" /><param name="input_chipseq_file1" value="chipseq_enriched.bed.gz" ftype="bed" /><param name="input_control_file1" value="chipseq_input.bed.gz" ftype="bed" /><param name="experiment_name" value="Galaxy Test Run" /> - <param name="input_type_selector" value="single_end" /><param name="tsize" value="36" /><param name="mfold" value="13" /><param name="gsize" value="2.7e+9" /> @@ -190,10 +190,10 @@ </output></test><!-- <test> + <param name="input_type_selector" value="single_end" /><param name="input_chipseq_file1" value="chipseq_enriched.bed.gz" ftype="bed" /><param name="input_control_file1" value="chipseq_input.bed.gz" ftype="bed" /><param name="experiment_name" value="Galaxy Test Run" /> - <param name="input_type_selector" value="single_end" /><param name="tsize" value="36" /><param name="mfold" value="13" /><param name="gsize" value="2.7e+9" /> --- a/tools/regVariation/maf_cpg_filter.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/regVariation/maf_cpg_filter.xml Mon Feb 28 12:16:28 2011 -0500 @@ -56,7 +56,6 @@ <param name="input" value="6.maf"/><param name="mask_char" value="0"/><param name="type" value="nonCpG" /> - <param name="definition" value="NA" /><output name="out_file1" file="6_mask_noncpg.maf"/></test></tests> --- a/tools/regVariation/microsatellite_birthdeath.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/regVariation/microsatellite_birthdeath.xml Mon Feb 28 12:16:28 2011 -0500 @@ -41,7 +41,6 @@ <param name="alignment" value="chr22_5sp.maf"/><param name="orthfile" value="chr22_5sp.microraw.tabular"/><param name="thresholds" value="9,10,12,12"/> - <param name="species" value="hg18,panTro2,ponAbe2,rheMac2,calJac1"/><param name="tree_definition" value="((((hg18, panTro2), ponAbe2), rheMac2), calJac1)"/><param name="separation" value="40"/><param name="simthresh" value="80"/> --- a/tools/regVariation/quality_filter.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/regVariation/quality_filter.xml Mon Feb 28 12:16:28 2011 -0500 @@ -74,7 +74,6 @@ <param name="score" value="50"/><param name="mask_char" value="0"/><param name="region" value="0" /> - <param name="length" value="1" /><output name="out_file1" file="6_quality_filter.maf"/></test></tests> --- a/tools/rgenetics/rgPedSub.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/rgenetics/rgPedSub.xml Mon Feb 28 12:16:28 2011 -0500 @@ -76,10 +76,10 @@ <edit_attributes type='name' value='tinywga' /></param><param name='title' value='rgPedSubtest1' /> + <param name="mtype" value="grslist" /><param name="region" value="" /><param name="rslist" value="rs2283802Xrs2267000Xrs16997606Xrs4820537Xrs3788347Xrs756632Xrs4820539Xrs2283804Xrs2267006Xrs4822363X" /><param name="relfilter" value="all" /> - <param name="mtype" value="grslist" /><output name='output1' file='rgtestouts/rgPedSub/rgPedSubtest1.lped' ftype='lped' linesDiff='7'/></test></tests> --- a/tools/samtools/bam_to_sam.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/samtools/bam_to_sam.xml Mon Feb 28 12:16:28 2011 -0500 @@ -29,7 +29,7 @@ samtools view -o bam_to_sam_out2.sam test-data/1.bam --><param name="input1" value="3.bam" ftype="bam" /> - <param name="output1" file="bam_to_sam_out2.sam" sorted="True" /> + <output name="output1" file="bam_to_sam_out2.sam" sorted="True" /></test></tests><help> --- a/tools/samtools/sam2interval.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/samtools/sam2interval.xml Mon Feb 28 12:16:28 2011 -0500 @@ -15,13 +15,11 @@ <tests><test><param name="input1" value="sam_bioinf_example.sam" ftype="sam"/> - <param name="flags" value="Read is mapped in a proper pair"/><param name="print_all" value="Yes"/><output name="out_file1" file="sam2interval_printAll.dat" ftype="interval"/></test><test><param name="input1" value="sam_bioinf_example.sam" ftype="sam"/> - <param name="flags" value="Read is mapped in a proper pair"/><param name="print_all" value="No"/><output name="out_file1" file="sam2interval_noprintAll.dat" ftype="interval"/></test> --- a/tools/samtools/sam_to_bam.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/samtools/sam_to_bam.xml Mon Feb 28 12:16:28 2011 -0500 @@ -60,7 +60,7 @@ --><param name="index_source" value="cached" /><param name="input1" value="3.sam" ftype="sam" dbkey="equCab2" /> - <param name="output1" file="sam_to_bam_out2.bam" /> + <output name="output1" file="sam_to_bam_out2.bam" /></test></tests><help> --- a/tools/samtools/samtools_flagstat.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/samtools/samtools_flagstat.xml Mon Feb 28 12:16:28 2011 -0500 @@ -14,7 +14,7 @@ <tests><test><param name="input1" value="3.bam" ftype="bam" /> - <param name="output1" file="samtools_flagstat_out1.txt" /> + <output name="output1" file="samtools_flagstat_out1.txt" /></test></tests><help> --- a/tools/sr_mapping/bfast_wrapper.xml Mon Feb 28 09:59:30 2011 -0500 +++ b/tools/sr_mapping/bfast_wrapper.xml Mon Feb 28 12:16:28 2011 -0500 @@ -368,8 +368,6 @@ <param name="indices" value="phiX_nt_50" /><param name="source_select" value="pre_set" /><param name="suppressHeader" value="False" /> - <param name="indexing_repeatmasker" value="" /> - <param name="indexing_option_selector" value="default" /><output name="output" ftype="sam" file="bfast_out3.sam" lines_diff="2" /><!-- MD:Z:11T38 instead of MD:Z:50 on one line--></test></tests> 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