Mercurial > repos > pieterlukasse > prims_metabolomics2
view primsfilters.py @ 19:1cfe2b57d7f4
moved match_library
author | linda.bakker@wur.nl <linda.bakker@wur.nl> |
---|---|
date | Fri, 17 Apr 2015 17:08:48 +0200 |
parents | dffc38727496 |
children |
line wrap: on
line source
import logging log = logging.getLogger( __name__ ) def restrict_prims_metabolomics( context, tool ): """ This tool filter will hide prims_metabolomics tools for non-metabolomics users. This can be enabled by adding the following to the ``app:main`` section of ``universe_wsgi.ini``:: tool_filters = primsfilters:restrict_prims_metabolomics and by adding this file to the folder: <galaxy-dist>/lib/galaxy/tools/filters This is optional and can be used in case some control is desired on whom gets to see the prims_metabolomics tools. When not using this file and the settings mentioned above, all prims_metabolomics tools will be visible to all users. """ # for debugging: import pydevd;pydevd.settrace("L0136815.wurnet.nl") user = context.trans.user metabolomics_tools = [ "msclust2", "combine_output", "create_poly_model", "lookup_library", "NDIStext2tabular", "rankfilterGCMS_tabular", "filter_on_rank", "export_to_metexp_tabular", "query_metexp" ] found_match = False # iterate over the tool (partial)ids and look for a match (this is compatible with tool shed given ids): for partial_id in metabolomics_tools: if tool.id.find("/"+ partial_id + "/") >= 0: found_match = True break # the second part of this if is compatible with the ids when NOT using tool shed: if found_match or tool.id in metabolomics_tools: # logging.warn( 'FILTER MATCHED: %s' %(tool.name)) for user_role in user.roles: if user_role.role.name == "PRIMS_METABOLOMICS": return True # not found to have the role, return false: return False else: # return true for any other tool return True