details: http://www.bx.psu.edu/hg/galaxy/rev/5f7ace3195b7 changeset: 3496:5f7ace3195b7 user: Dan Blankenberg dan@bx.psu.edu date: Tue Mar 09 13:54:30 2010 -0500 description: Allow uploading and use of composite files in toolbox tests. Along with setting each component of a composite datatype, metadata attributes (e.g. basename in Rgenetics datatypes) can be set.
Example Tool:
<tool id='temp' name='temp test'> <description>test</description> <command>cat ${i.extra_files_path}/${i.metadata.base_name}.fam > $out_file1</command> <inputs> <param name="i" type="data" label="RGenetics genotype data from your current history" format="pbed" /> </inputs> <outputs> <data format="text" name="out_file1" /> </outputs> <tests> <test> <param name='i' ftype='pbed'> <metadata name='base_name' value='rgenetics_CHANGED' /> <composite_data value='temp/somefile1' /> <composite_data value='temp/somefile2' /> <composite_data value='temp/somefile3' /> </param> <output name='out_file1' file='temp/somefile3' /> </test> </tests> </tool>
diffstat:
lib/galaxy/tools/__init__.py | 1 + lib/galaxy/tools/test.py | 4 +++- test/base/twilltestcase.py | 16 ++++++++++++---- test/functional/test_toolbox.py | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-)
diffs (73 lines):
diff -r 3b1be99d1f62 -r 5f7ace3195b7 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Tue Mar 09 11:28:21 2010 -0500 +++ b/lib/galaxy/tools/__init__.py Tue Mar 09 13:54:30 2010 -0500 @@ -523,6 +523,7 @@ value = attrib['value'] else: value = None + attrib['children'] = list( param_elem.getchildren() ) test.add_param( attrib.pop( 'name' ), value, attrib ) for output_elem in test_elem.findall( "output" ): attrib = dict( output_elem.attrib ) diff -r 3b1be99d1f62 -r 5f7ace3195b7 lib/galaxy/tools/test.py --- a/lib/galaxy/tools/test.py Tue Mar 09 11:28:21 2010 -0500 +++ b/lib/galaxy/tools/test.py Tue Mar 09 13:54:30 2010 -0500 @@ -30,10 +30,12 @@ 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: - if value is None: + if value is None and len( [ child for child in extra.get( 'children', [] ) if child.tag == 'composite_data' ] ) == 0: assert self.tool.inputs[name].optional, '%s is not optional. You must provide a valid filename.' % name else: self.required_files.append( ( value, extra ) ) + if value is None and len( [ child for child in extra.get( 'children', [] ) if child.tag == 'composite_data' ] ) > 0: + value = extra.get( 'ftype' ) except Exception, e: log.debug( "Error in add_param for %s: %s" % ( name, e ) ) self.inputs.append( ( name, value, extra ) ) diff -r 3b1be99d1f62 -r 5f7ace3195b7 test/base/twilltestcase.py --- a/test/base/twilltestcase.py Tue Mar 09 11:28:21 2010 -0500 +++ b/test/base/twilltestcase.py Tue Mar 09 13:54:30 2010 -0500 @@ -142,14 +142,22 @@ filename = os.path.join( *path ) file(filename, 'wt').write(buffer.getvalue())
- def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)' ): + def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', metadata = None, composite_data = None ): """Uploads a file""" - filename = self.get_filename(filename) self.visit_url( "%s/tool_runner?tool_id=upload1" % self.url ) try: - tc.fv("1","file_type", ftype) + self.refresh_form( "file_type", ftype ) #Refresh, to support composite files tc.fv("1","dbkey", dbkey) - tc.formfile("1","file_data", filename) + if metadata: + for elem in metadata: + tc.fv( "1", "files_metadata|%s" % elem.get( 'name' ), elem.get( 'value' ) ) + if composite_data: + for i, composite_file in enumerate( composite_data ): + filename = self.get_filename( composite_file.get( 'value' ) ) + tc.formfile( "1", "files_%i|file_data" % i, filename ) + else: + filename = self.get_filename( filename ) + tc.formfile( "1", "file_data", filename ) tc.submit("runtool_btn") self.home() except AssertionError, err: diff -r 3b1be99d1f62 -r 5f7ace3195b7 test/functional/test_toolbox.py --- a/test/functional/test_toolbox.py Tue Mar 09 11:28:21 2010 -0500 +++ b/test/functional/test_toolbox.py Tue Mar 09 13:54:30 2010 -0500 @@ -32,7 +32,10 @@ raise AssertionError("ToolTestCase.do_it failed") # Upload any needed files for fname, extra in testdef.required_files: - self.upload_file( fname, ftype=extra.get( 'ftype', 'auto' ), dbkey=extra.get( 'dbkey', 'hg17' ) ) + children = extra.get( 'children', [] ) + metadata = [ child for child in children if child.tag == 'metadata' ] + composite_data = [ child for child in children if child.tag == 'composite_data' ] + self.upload_file( fname, ftype=extra.get( 'ftype', 'auto' ), dbkey=extra.get( 'dbkey', 'hg17' ), metadata = metadata, composite_data = composite_data ) print "Uploaded file: ", fname, ", ftype: ", extra.get( 'ftype', 'auto' ), ", extra: ", extra # We need to handle the case where we've uploaded a valid compressed file since the upload # tool will have uncompressed it on the fly.
galaxy-dev@lists.galaxyproject.org