comparison validate_affy_metadata.py @ 2:72e79ed7ca41 draft

Uploaded
author greg
date Tue, 17 Sep 2019 12:45:57 -0400
parents b5f5c3d0f349
children 7f95329251f0
comparison
equal deleted inserted replaced
1:b5f5c3d0f349 2:72e79ed7ca41
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
66 accumulated_msgs = "" 74 accumulated_msgs = ""
67 # Parse the input file, skipping the header, and validating 75 # Parse the input file, skipping the header, and validating
68 # that each data line consists of 31 comma-separated items. 76 # that each data line consists of 31 comma-separated items.
69 with open(args.input, "r") as ih: 77 with open(args.input, "r") as ih:
70 for i, line in enumerate(ih): 78 for i, line in enumerate(ih):
105 accumulated_msgs = validate_decimal(line_no, longitude, "longitude", accumulated_msgs) 113 accumulated_msgs = validate_decimal(line_no, longitude, "longitude", accumulated_msgs)
106 # Optional. 114 # Optional.
107 geographic_origin = items[8] 115 geographic_origin = items[8]
108 # Optional. 116 # Optional.
109 colony_location = items[9] 117 colony_location = items[9]
110 # Optional.
111 depth = items[10] 118 depth = items[10]
119 # If depth has a value, then it must be integer.
120 if len(depth) > 0:
121 accumulated_msgs = validate_integer(line_no, depth, "depth", accumulated_msgs)
112 # Optional. 122 # Optional.
113 disease_resist = items[11] 123 disease_resist = items[11]
114 # Optional. 124 # Optional.
115 bleach_resist = items[12] 125 bleach_resist = items[12]
116 # Optional. 126 # Optional.