annotate operation_filter.py @ 3:ffbd1de29c28 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
author devteam
date Wed, 11 Nov 2015 12:48:58 -0500
parents e56b47dce68a
children a10f49d9218a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
1 # runs after the job (and after the default post-filter)
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
2 from galaxy.tools.parameters import DataToolParameter
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
3
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
4 from galaxy.jobs.handler import JOB_ERROR
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
5
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
6 # Older py compatibility
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
7 try:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
8 set()
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
9 except:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
10 from sets import Set as set
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
11
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
12
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
13 def validate_input( trans, error_map, param_values, page_param_map ):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
14 dbkeys = set()
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
15 data_param_names = set()
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
16 data_params = 0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
17 for name, param in page_param_map.iteritems():
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
18 if isinstance( param, DataToolParameter ):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
19 # for each dataset parameter
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
20 if param_values.get(name, None) is not None:
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
21 dbkeys.add( param_values[name].dbkey )
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
22 data_params += 1
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
23 # check meta data
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
24 try:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
25 param = param_values[name]
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
26 if isinstance( param.datatype, trans.app.datatypes_registry.get_datatype_by_extension( 'gff' ).__class__ ):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
27 # TODO: currently cannot validate GFF inputs b/c they are not derived from interval.
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
28 pass
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
29 else: # Validate interval datatype.
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
30 int( param.metadata.startCol )
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
31 int( param.metadata.endCol )
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
32 int( param.metadata.chromCol )
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
33 if param.metadata.strandCol is not None:
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
34 int( param.metadata.strandCol )
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
35 except:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
36 error_msg = "The attributes of this dataset are not properly set. " + \
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
37 "Click the pencil icon in the history item to set the chrom, start, end and strand columns."
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
38 error_map[name] = error_msg
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
39 data_param_names.add( name )
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
40 if len( dbkeys ) > 1:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
41 for name in data_param_names:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
42 error_map[name] = "All datasets must belong to same genomic build, " \
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
43 "this dataset is linked to build '%s'" % param_values[name].dbkey
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
44 if data_params != len(data_param_names):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
45 for name in data_param_names:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
46 error_map[name] = "A dataset of the appropriate type is required"
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
47
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
48
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
49 # Commented out by INS, 5/30/2007. What is the PURPOSE of this?
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
50 def exec_after_process(app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
51 """Verify the output data after each run"""
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
52 for data in out_data.values():
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
53 try:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
54 if stderr and len( stderr ) > 0:
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
55 raise Exception( stderr )
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
56
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
57 except Exception:
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
58 data.blurb = JOB_ERROR
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
59 data.state = JOB_ERROR
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
60
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
61
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
62 def exec_after_merge(app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
63 exec_after_process(
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
64 app, inp_data, out_data, param_dict, tool=tool, stdout=stdout, stderr=stderr)
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
65
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
66 # strip strand column if clusters were merged
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
67 for data in out_data.values():
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
68 if param_dict['returntype'] is True:
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
69 data.metadata.chromCol = 1
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
70 data.metadata.startCol = 2
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
71 data.metadata.endCol = 3
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
72 # merge always clobbers strand
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
73 data.metadata.strandCol = None
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
74
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
75
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
76 def exec_after_cluster(app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None):
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
77 exec_after_process(
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
78 app, inp_data, out_data, param_dict, tool=tool, stdout=stdout, stderr=stderr)
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
79
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
80 # strip strand column if clusters were merged
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
81 if param_dict["returntype"] == '1':
3
ffbd1de29c28 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
82 for data in out_data.values():
0
e56b47dce68a Imported from capsule None
devteam
parents:
diff changeset
83 data.metadata.strandCol = None