annotate primsfilters.py @ 28:b1015b9241cd

Added option for using retentionMean (micro minutes) for the time dimension
author pieter.lukasse@wur.nl
date Fri, 09 May 2014 17:07:58 +0200
parents cd4f13119afa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
1 import logging
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
2 log = logging.getLogger( __name__ )
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
3
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
4
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
5 def restrict_prims_metabolomics( context, tool ):
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
6 """
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
7 This tool filter will hide prims_metabolomics tools for non-metabolomics users.
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
8 This can be enabled by adding the following to the
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
9 ``app:main`` section of ``universe_wsgi.ini``::
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
10
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
11 tool_filters = primsfilters:restrict_prims_metabolomics
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
12
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
13 and by adding this file to the folder:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
14
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
15 <galaxy-dist>/lib/galaxy/tools/filters
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
16
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
17 This is optional and can be used in case some control is desired on whom
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
18 gets to see the prims_metabolomics tools. When not using this file and the
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
19 settings mentioned above, all prims_metabolomics tools will be visible to
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
20 all users.
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
21 """
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
22 # for debugging: import pydevd;pydevd.settrace("L0136815.wurnet.nl")
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
23 user = context.trans.user
22
cd4f13119afa Small fix in filters part and improvement in query_metexp time logging
pieter.lukasse@wur.nl
parents: 19
diff changeset
24 metabolomics_tools = [ "msclust2", "combine_output", "create_poly_model", "lookup_library",
cd4f13119afa Small fix in filters part and improvement in query_metexp time logging
pieter.lukasse@wur.nl
parents: 19
diff changeset
25 "NDIStext2tabular", "rankfilterGCMS_tabular", "filter_on_rank",
cd4f13119afa Small fix in filters part and improvement in query_metexp time logging
pieter.lukasse@wur.nl
parents: 19
diff changeset
26 "export_to_metexp_tabular", "query_metexp" ]
19
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
27 found_match = False
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
28 # iterate over the tool (partial)ids and look for a match (this is compatible with tool shed given ids):
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
29 for partial_id in metabolomics_tools:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
30 if tool.id.find("/"+ partial_id + "/") >= 0:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
31 found_match = True
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
32 break
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
33 # the second part of this if is compatible with the ids when NOT using tool shed:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
34 if found_match or tool.id in metabolomics_tools:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
35 # logging.warn( 'FILTER MATCHED: %s' %(tool.name))
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
36
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
37 for user_role in user.roles:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
38 if user_role.role.name == "PRIMS_METABOLOMICS":
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
39 return True
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
40 # not found to have the role, return false:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
41 return False
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
42 else:
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
43 # return true for any other tool
c068ed713eb9 fixes on <when> tags
pieter.lukasse@wur.nl
parents:
diff changeset
44 return True