Mercurial > repos > peterjc > mira4_assembler
comparison tools/mira4_0/mira4_validator.py @ 4:1713289d9908 draft default tip
v0.0.11 tweak for use with bioconda dependencies
author | peterjc |
---|---|
date | Thu, 10 Aug 2017 11:09:10 -0400 |
parents | 4eb32a3d67d1 |
children |
comparison
equal
deleted
inserted
replaced
3:a4f602cc3aa9 | 4:1713289d9908 |
---|---|
1 #Called from the Galaxy Tool XML file | 1 # Called from the Galaxy Tool XML file |
2 #import sys | 2 # import sys |
3 | |
3 | 4 |
4 def validate_input(trans, error_map, param_values, page_param_map): | 5 def validate_input(trans, error_map, param_values, page_param_map): |
5 """Validates the min_size/max_size user input, before execution.""" | 6 """Validates the min_size/max_size user input, before execution.""" |
6 err_list = [] | 7 err_list = [] |
7 for read_group in param_values["read_group"]: | 8 for read_group in param_values["read_group"]: |
11 err_list.append(dict()) | 12 err_list.append(dict()) |
12 continue | 13 continue |
13 | 14 |
14 min_size = str(segments["min_size"]).strip() | 15 min_size = str(segments["min_size"]).strip() |
15 max_size = str(segments["max_size"]).strip() | 16 max_size = str(segments["max_size"]).strip() |
16 #sys.stderr.write("DEBUG min_size=%r, max_size=%r\n" % (min_size, max_size)) | 17 # sys.stderr.write("DEBUG min_size=%r, max_size=%r\n" % (min_size, max_size)) |
17 | 18 |
18 #Somehow Galaxy seems to turn an empty field into string "None"... | 19 # Somehow Galaxy seems to turn an empty field into string "None"... |
19 if min_size=="None": | 20 if min_size == "None": |
20 min_size = "" | 21 min_size = "" |
21 if max_size=="None": | 22 if max_size == "None": |
22 max_size = "" | 23 max_size = "" |
23 | 24 |
24 if min_size=="" and max_size=="": | 25 if min_size == "" and max_size == "": |
25 #Both missing is good | 26 # Both missing is good |
26 pass | 27 pass |
27 elif min_size=="": | 28 elif min_size == "": |
28 err["min_size"] = "Minimum size required if maximum size given" | 29 err["min_size"] = "Minimum size required if maximum size given" |
29 elif max_size=="": | 30 elif max_size == "": |
30 err["max_size"] = "Maximum size required if minimum size given" | 31 err["max_size"] = "Maximum size required if minimum size given" |
31 | 32 |
32 if min_size: | 33 if min_size: |
33 try: | 34 try: |
34 min_size_int = int(min_size) | 35 min_size_int = int(min_size) |
35 if min_size_int < 0: | 36 if min_size_int < 0: |
36 err["min_size"] = "Minumum size must not be negative (%i)" % min_size_int | 37 err["min_size"] = "Minumum size must not be negative (%i)" % min_size_int |
37 min_size = None # Avoid doing comparison below | 38 min_size = None # Avoid doing comparison below |
38 except ValueError: | 39 except ValueError: |
39 err["min_size"] = "Minimum size is not an integer (%s)" % min_size | 40 err["min_size"] = "Minimum size is not an integer (%s)" % min_size |
40 min_size = None # Avoid doing comparison below | 41 min_size = None # Avoid doing comparison below |
41 | 42 |
42 if max_size: | 43 if max_size: |
43 try: | 44 try: |
44 max_size_int = int(max_size) | 45 max_size_int = int(max_size) |
45 if max_size_int< 0: | 46 if max_size_int < 0: |
46 err["max_size"] = "Maximum size must not be negative (%i)" % max_size_int | 47 err["max_size"] = "Maximum size must not be negative (%i)" % max_size_int |
47 max_size = None # Avoid doing comparison below | 48 max_size = None # Avoid doing comparison below |
48 except ValueError: | 49 except ValueError: |
49 err["max_size"] = "Maximum size is not an integer (%s)" % max_size | 50 err["max_size"] = "Maximum size is not an integer (%s)" % max_size |
50 max_size = None # Avoid doing comparison below | 51 max_size = None # Avoid doing comparison below |
51 | 52 |
52 if min_size and max_size and min_size_int > max_size_int: | 53 if min_size and max_size and min_size_int > max_size_int: |
53 msg = "Minimum size must be less than maximum size (%i vs %i)" % (min_size_int, max_size_int) | 54 msg = "Minimum size must be less than maximum size (%i vs %i)" % (min_size_int, max_size_int) |
54 err["min_size"] = msg | 55 err["min_size"] = msg |
55 err["max_size"] = msg | 56 err["max_size"] = msg |
56 | 57 |
57 if err: | 58 if err: |
58 err_list.append({"segments":err}) | 59 err_list.append({"segments": err}) |
59 else: | 60 else: |
60 err_list.append(dict()) | 61 err_list.append(dict()) |
61 | 62 |
62 if any(err_list): | 63 if any(err_list): |
63 #Return an error map only if any readgroup gave errors | 64 # Return an error map only if any readgroup gave errors |
64 error_map["read_group"] = err_list | 65 error_map["read_group"] = err_list |