Mercurial > repos > greg > validate_affy_metadata
comparison validate_affy_metadata.py @ 3:7f95329251f0 draft
Uploaded
author | greg |
---|---|
date | Fri, 20 Sep 2019 08:42:33 -0400 |
parents | 72e79ed7ca41 |
children | 9d5a14c913b1 |
comparison
equal
deleted
inserted
replaced
2:72e79ed7ca41 | 3:7f95329251f0 |
---|---|
61 elif len(email) > EMAIL_MAX_LEN: | 61 elif len(email) > EMAIL_MAX_LEN: |
62 return add_error_msg(accumulated_msgs, "Line %d contains an email address (%) that is longer than the maximum length, %d characters." % (line_no, email)) | 62 return add_error_msg(accumulated_msgs, "Line %d contains an email address (%) that is longer than the maximum length, %d characters." % (line_no, email)) |
63 return accumulated_msgs | 63 return accumulated_msgs |
64 | 64 |
65 | 65 |
66 def validate_integer(line_no, integer_string, column, accumulated_msgs): | |
67 try: | |
68 integer_string.isdigit() | |
69 return accumulated_msgs | |
70 except Exception: | |
71 return add_error_msg(accumulated_msgs, "Line %d contains an incorrect integer value (%s) for column %s." % (line_no, integer_string, column)) | |
72 | |
73 | |
74 accumulated_msgs = "" | 66 accumulated_msgs = "" |
75 # Parse the input file, skipping the header, and validating | 67 # Parse the input file, skipping the header, and validating |
76 # that each data line consists of 31 comma-separated items. | 68 # that each data line consists of 31 comma-separated items. |
77 with open(args.input, "r") as ih: | 69 with open(args.input, "r") as ih: |
78 for i, line in enumerate(ih): | 70 for i, line in enumerate(ih): |
114 # Optional. | 106 # Optional. |
115 geographic_origin = items[8] | 107 geographic_origin = items[8] |
116 # Optional. | 108 # Optional. |
117 colony_location = items[9] | 109 colony_location = items[9] |
118 depth = items[10] | 110 depth = items[10] |
119 # If depth has a value, then it must be integer. | 111 # If depth has a value, then it must be a decimal. |
120 if len(depth) > 0: | 112 if len(depth) > 0: |
121 accumulated_msgs = validate_integer(line_no, depth, "depth", accumulated_msgs) | 113 accumulated_msgs = validate_decimal(line_no, depth, "depth", accumulated_msgs) |
122 # Optional. | 114 # Optional. |
123 disease_resist = items[11] | 115 disease_resist = items[11] |
124 # Optional. | 116 # Optional. |
125 bleach_resist = items[12] | 117 bleach_resist = items[12] |
126 # Optional. | 118 # Optional. |