comparison validate_affy_metadata.py @ 18:38166b76f47a draft

Uploaded
author greg
date Tue, 22 Jan 2019 11:05:08 -0500
parents 17db886fbfad
children 90688364136c
comparison
equal deleted inserted replaced
17:17db886fbfad 18:38166b76f47a
74 line = line.rstrip("\r\n") 74 line = line.rstrip("\r\n")
75 if i > 97: 75 if i > 97:
76 accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 97 lines (must be 1 header line and no more than 96 data lines).") 76 accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 97 lines (must be 1 header line and no more than 96 data lines).")
77 stop_error(accumulated_msgs) 77 stop_error(accumulated_msgs)
78 items = line.split("\t") 78 items = line.split("\t")
79 if len(items) != 29: 79 if len(items) != 28:
80 accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains %s columns, (must be 29)." % (i, len(items))) 80 accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains %s columns, (must be 28)." % (i, len(items)))
81 stop_error(accumulated_msgs) 81 stop_error(accumulated_msgs)
82 # Required and validated. 82 # Required and validated.
83 date_entered_db = items[0]
84 accumulated_msgs = validate_date_string(i, date_entered_db, accumulated_msgs)
85 # Required. 83 # Required.
86 user_specimen_id = items[1] 84 user_specimen_id = items[0]
87 if len(user_specimen_id) == 0: 85 if len(user_specimen_id) == 0:
88 accumulated_msgs = empty_value(i, "user_specimen_id", accumulated_msgs) 86 accumulated_msgs = empty_value(i, "user_specimen_id", accumulated_msgs)
89 # Optional. 87 # Optional.
90 field_call = items[2] 88 field_call = items[1]
91 # Optional. 89 # Optional.
92 bcoral_genet_id = items[3] 90 bcoral_genet_id = items[2]
93 # Optional. 91 # Optional.
94 bsym_genet_id = items[4] 92 bsym_genet_id = items[3]
95 # Required. 93 # Required.
96 reef = items[5] 94 reef = items[4]
97 if len(reef) == 0: 95 if len(reef) == 0:
98 accumulated_msgs = empty_value(i, "reef", accumulated_msgs) 96 accumulated_msgs = empty_value(i, "reef", accumulated_msgs)
99 # Required. 97 # Required.
100 region = items[6] 98 region = items[5]
101 if len(region) == 0: 99 if len(region) == 0:
102 accumulated_msgs = empty_value(i, "region", accumulated_msgs) 100 accumulated_msgs = empty_value(i, "region", accumulated_msgs)
103 # Required and validated. 101 # Required and validated.
104 latitude = items[7] 102 latitude = items[6]
105 accumulated_msgs = validate_decimal(i, latitude, accumulated_msgs) 103 accumulated_msgs = validate_decimal(i, latitude, accumulated_msgs)
106 # Required and validated. 104 # Required and validated.
107 longitude = items[8] 105 longitude = items[7]
108 accumulated_msgs = validate_decimal(i, longitude, accumulated_msgs) 106 accumulated_msgs = validate_decimal(i, longitude, accumulated_msgs)
109 # Optional. 107 # Optional.
110 geographic_origin = items[9] 108 geographic_origin = items[8]
111 # Optional. 109 # Optional.
112 sample_location = items[10] 110 sample_location = items[9]
113 # Optional. 111 # Optional.
114 latitude_outplant = items[11] 112 latitude_outplant = items[10]
115 # Optional. 113 # Optional.
116 longitude_outplant = items[12] 114 longitude_outplant = items[11]
117 # Optional. 115 # Optional.
118 depth = items[13] 116 depth = items[12]
119 # Optional. 117 # Optional.
120 dist_shore = items[14] 118 dist_shore = items[13]
121 # Optional. 119 # Optional.
122 disease_resist = items[15] 120 disease_resist = items[14]
123 # Optional. 121 # Optional.
124 bleach_resist = items[16] 122 bleach_resist = items[15]
125 # Optional. 123 # Optional.
126 mortality = items[17] 124 mortality = items[16]
127 # Optional. 125 # Optional.
128 tle = items[18] 126 tle = items[17]
129 # Optional. 127 # Optional.
130 spawning = string_as_boolean_string(items[19]) 128 spawning = string_as_boolean_string(items[18])
131 # Required. 129 # Required.
132 collector_last_name = items[20] 130 collector_last_name = items[19]
133 if len(collector_last_name) == 0: 131 if len(collector_last_name) == 0:
134 accumulated_msgs = empty_value(i, "collector_last_name", accumulated_msgs) 132 accumulated_msgs = empty_value(i, "collector_last_name", accumulated_msgs)
135 # Required. 133 # Required.
136 collector_first_name = items[21] 134 collector_first_name = items[20]
137 if len(collector_first_name) == 0: 135 if len(collector_first_name) == 0:
138 accumulated_msgs = empty_value(i, "collector_first_name", accumulated_msgs) 136 accumulated_msgs = empty_value(i, "collector_first_name", accumulated_msgs)
139 # Required. 137 # Required.
140 org = items[22] 138 org = items[21]
141 if len(org) == 0: 139 if len(org) == 0:
142 accumulated_msgs = empty_value(i, "org", accumulated_msgs) 140 accumulated_msgs = empty_value(i, "org", accumulated_msgs)
143 # Required and validated. 141 # Required and validated.
144 collection_date = items[23] 142 collection_date = items[22]
145 accumulated_msgs = validate_date_string(i, date_entered_db, accumulated_msgs) 143 accumulated_msgs = validate_date_string(i, collection_date, accumulated_msgs)
146 # Required and validated. 144 # Required and validated.
147 contact_email = items[24] 145 contact_email = items[23]
148 accumulated_msgs = validate_email(i, contact_email, accumulated_msgs) 146 accumulated_msgs = validate_email(i, contact_email, accumulated_msgs)
149 # Required. 147 # Required.
150 seq_facility = items[25] 148 seq_facility = items[24]
151 if len(seq_facility) == 0: 149 if len(seq_facility) == 0:
152 accumulated_msgs = empty_value(i, "seq_facility", accumulated_msgs) 150 accumulated_msgs = empty_value(i, "seq_facility", accumulated_msgs)
153 # Optional. 151 # Optional.
154 array_version = items[26] 152 array_version = items[25]
155 # Optional. 153 # Optional.
156 public = string_as_boolean_string(items[27]) 154 public = string_as_boolean_string(items[26])
157 # Optional. 155 # Optional.
158 public_after_date = items[28] 156 public_after_date = items[27]
159 accumulated_msga = validate_date_string(i, public_after_date, accumulated_msgs) 157 accumulated_msga = validate_date_string(i, public_after_date, accumulated_msgs)
160 158
161 if len(accumulated_msgs) > 0: 159 if len(accumulated_msgs) > 0:
162 stop_error(accumulated_msgs) 160 stop_error(accumulated_msgs)
163 161