annotate operation_filter.py @ 3:32e1c8dac438 draft

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