Skip to content

Commit

Permalink
Merge pull request #6 from jmchilton/edam_api
Browse files Browse the repository at this point in the history
Add EDAM Info to Tool's API.
  • Loading branch information
hexylena committed May 20, 2015
2 parents 6c69602 + 7f12d33 commit 03906fd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class GenericAsn1Binary( Binary ):
@dataproviders.decorators.has_dataproviders
class Bam( Binary ):
"""Class describing a BAM binary file"""
edam_format = "format_2572"
file_ext = "bam"
track_type = "ReadTrack"
data_sources = { "data": "bai", "index": "bigwig" }
Expand Down
10 changes: 9 additions & 1 deletion lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ def __getitem__( self, index ):
def __iter__( self ):
return iter( ( self.format, self.metadata_source, self.parent ) )

def to_dict( self, view='collection', value_mapper=None, app=None ):
as_dict = super( ToolOutput, self ).to_dict( view=view, value_mapper=value_mapper )
format = self.format
if format and format != "input" and app:
edam_format = app.datatypes_registry.edam_formats.get(self.format)
as_dict["edam_format"] = edam_format
return as_dict


class ToolOutputCollection( ToolOutputBase ):
"""
Expand Down Expand Up @@ -2212,7 +2220,7 @@ def to_dict( self, trans, link_details=False, io_details=False ):
# Add input and output details.
if io_details:
tool_dict[ 'inputs' ] = [ input.to_dict( trans ) for input in self.inputs.values() ]
tool_dict[ 'outputs' ] = [ output.to_dict() for output in self.outputs.values() ]
tool_dict[ 'outputs' ] = [ output.to_dict( app=trans.app ) for output in self.outputs.values() ]

tool_dict[ 'panel_section_id' ], tool_dict[ 'panel_section_name' ] = self.get_panel_section()

Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,12 @@ def _options_filter_attribute( self, value ):
def to_dict( self, trans, view='collection', value_mapper=None, other_values=None ):
# create dictionary and fill default parameters
d = super( DataToolParameter, self ).to_dict( trans )
d['extensions'] = self.extensions
extensions = self.extensions
all_edam_formats = self._datatypes_registery( trans, self.tool ).edam_formats
edam_formats = map(lambda ext: all_edam_formats.get(ext, None),
extensions)
d['extensions'] = extensions
d['edam_formats'] = edam_formats
d['multiple'] = self.multiple
d['options'] = {'hda': [], 'hdca': []}

Expand Down
4 changes: 4 additions & 0 deletions lib/galaxy/webapps/galaxy/api/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def converters( self, trans, **kwd ):

return converters

@expose_api_anonymous_and_sessionless
def edam_formats( self, trans, **kwds ):
return self._datatypes_registry.edam_formats

@property
def _datatypes_registry( self ):
return self.app.datatypes_registry
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/buildapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def populate_api_routes( webapp, app ):
webapp.mapper.resource( 'datatype',
'datatypes',
path_prefix='/api',
collection={ 'sniffers': 'GET', 'mapping': 'GET', 'converters': 'GET' },
collection={ 'sniffers': 'GET', 'mapping': 'GET', 'converters': 'GET', 'edam_formats': 'GET' },
parent_resources=dict( member_name='datatype', collection_name='datatypes' ) )
webapp.mapper.resource( 'search', 'search', path_prefix='/api' )
webapp.mapper.resource( 'page', 'pages', path_prefix="/api")
Expand Down

0 comments on commit 03906fd

Please sign in to comment.