changeset 2:72e79ed7ca41 draft

Uploaded
author greg
date Tue, 17 Sep 2019 12:45:57 -0400
parents b5f5c3d0f349
children 7f95329251f0
files validate_affy_metadata.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/validate_affy_metadata.py	Fri Sep 13 13:55:24 2019 -0400
+++ b/validate_affy_metadata.py	Tue Sep 17 12:45:57 2019 -0400
@@ -63,6 +63,14 @@
     return accumulated_msgs
 
 
+def validate_integer(line_no, integer_string, column, accumulated_msgs):
+    try:
+        integer_string.isdigit()
+        return accumulated_msgs
+    except Exception:
+        return add_error_msg(accumulated_msgs, "Line %d contains an incorrect integer value (%s) for column %s." % (line_no, integer_string, column))
+
+
 accumulated_msgs = ""
 # Parse the input file, skipping the header, and validating
 # that each data line consists of 31 comma-separated items.
@@ -107,8 +115,10 @@
         geographic_origin = items[8]
         # Optional.
         colony_location = items[9]
-        # Optional.
         depth = items[10]
+        # If depth has a value, then it must be integer.
+        if len(depth) > 0:
+            accumulated_msgs = validate_integer(line_no, depth, "depth", accumulated_msgs)
         # Optional.
         disease_resist = items[11]
         # Optional.