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 &gt; $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>
This commit is contained in:
Daniel Blankenberg
2010-03-09 13:54:30 -05:00
parent bb6dfe40f3
commit 994f2acdea
4 changed files with 20 additions and 6 deletions
+1
View File
@@ -523,6 +523,7 @@ class Tool:
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 )
+3 -1
View File
@@ -30,10 +30,12 @@ class ToolTestBuilder( object ):
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 ) )
+12 -4
View File
@@ -142,14 +142,22 @@ class TwillTestCase( unittest.TestCase ):
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:
+4 -1
View File
@@ -32,7 +32,10 @@ class ToolTestCase( TwillTestCase ):
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.