Skip to content

Commit

Permalink
Add hda agent generation to dynamic options
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Aug 1, 2016
1 parent b34757b commit bccf3d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 11 additions & 3 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3299,9 +3299,17 @@ def type_id( cls ):
return (( type_coerce( cls.content_type, types.Unicode ) + u'-' +
type_coerce( cls.id, types.Unicode ) ).label( 'type_id' ))

def to_hda_agent( self ):
if len( self.collection.dataset_elements ) > 0:
return self.collection.dataset_elements[ 0 ].dataset_instance
def to_hda_agent( self, multiple=False ):
rval = []
for dataset in self.collection.dataset_elements:
rval.append( dataset.dataset_instance )
if multiple is False:
break
if len( rval ) > 0:
if multiple:
return rval
else:
return rval[ 0 ]

def to_dict( self, view='collection' ):
dict_value = dict(
Expand Down
10 changes: 7 additions & 3 deletions lib/galaxy/tools/parameters/dynamic_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import validation
from galaxy.util import string_as_bool
from galaxy.model import User
from galaxy.model import User, HistoryDatasetAssociation, HistoryDatasetCollectionAssociation
import galaxy.tools

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -125,10 +125,12 @@ def compare_meta_value( file_value, dataset_value ):
return dataset_value in file_value.split( self.separator )
return file_value == dataset_value
ref = other_values.get( self.ref_name, None )
if isinstance( ref, HistoryDatasetCollectionAssociation ):
ref = ref.to_hda_agent( self.multiple )
is_data = isinstance( ref, galaxy.tools.wrappers.DatasetFilenameWrapper )
is_data_list = isinstance( ref, galaxy.tools.wrappers.DatasetListWrapper ) or isinstance( ref, list )
is_data_or_data_list = is_data or is_data_list
if not isinstance( ref, self.dynamic_option.tool_param.tool.app.model.HistoryDatasetAssociation ) and not is_data_or_data_list:
if not isinstance( ref, HistoryDatasetAssociation ) and not is_data_or_data_list:
return [] # not a valid dataset

if is_data_list:
Expand Down Expand Up @@ -398,7 +400,9 @@ def compare_value( option_value, filter_value ):
value = other_values.get( self.ref_name )
else:
data_ref = other_values.get( self.meta_ref )
if not isinstance( data_ref, self.dynamic_option.tool_param.tool.app.model.HistoryDatasetAssociation ) and not isinstance( data_ref, galaxy.tools.wrappers.DatasetFilenameWrapper ):
if isinstance( data_ref, HistoryDatasetCollectionAssociation ):
data_ref = data_ref.to_hda_agent()
if not isinstance( data_ref, HistoryDatasetAssociation ) and not isinstance( data_ref, galaxy.tools.wrappers.DatasetFilenameWrapper ):
return options # cannot modify options
value = data_ref.metadata.get( self.metadata_key, None )
return [ ( disp_name, optval, selected ) for disp_name, optval, selected in options if not compare_value( optval, value ) ]
Expand Down

0 comments on commit bccf3d5

Please sign in to comment.