Commit 1b963ec
fix: Handle dilutions, replicate measurements, and mmol/l unit in Roche Cedex Bio HT (#1244)
## Summary
A V6/V7 Roche Cedex Bio HT export failed to parse. Three distinct issues
surfaced, each fixed here:
1. **Dilutions treated as duplicates.** The same analyte can be measured
at multiple dilutions within one sample (e.g. IgG human undiluted
`3.933` and at `1/5` → `6.174`, a minute apart). The dilution factor
lived in the previously-discarded `col8`. It's now named `dilution
factor`, threaded through `RawMeasurement`, and included in the analyte
grouping key so the two measurements no longer collide. The factor is
also preserved in the analyte custom information document.
2. **Genuine replicate measurements raised an error.** The same analyte
can be re-measured (a second round) inside the 1-hour grouping window
(e.g. glucose `15.17` then `15.43` ~43 min later). Instead of raising
`Duplicate measurement`, we now split the later measurement into a new
group keyed by its own time — realizing the improvement the previous
code's comment explicitly anticipated.
3. **Lowercase `mmol/l` unit.** A handful of rows report the unit as
`mmol/l`; it's now normalized to `mmol/L` via `UNIT_CONVERSIONS`.
## Changes
- `constants.py`: rename `col8` → `dilution factor` in
`DATA_HEADER_V6_V7`; add `mmol/l` → `mmol/L` to `UNIT_CONVERSIONS`.
- `roche_cedex_bioht_structure.py`: add `dilution_factor` to
`RawMeasurement`, include it in the grouping key and custom info; split
on duplicate instead of raising (removes now-unused
`AllotropyParserError`).
- Updated affected unit tests; added
`test_create_measurements_same_analyte_different_dilution` and reworked
the duplicate test to assert the split behavior.
- Added trimmed regression file
`roche_cedex_bioht_v7_dilution_and_replicates.txt` (+ expected JSON)
covering all three cases.
## Testing
- Full 2.4MB source export now parses (5864 groups).
- All 22 `roche_cedex_bioht` tests pass; `hatch run lint` (ruff, black,
mypy) clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent e705eb6 commit 1b963ec
6 files changed
Lines changed: 495 additions & 33 deletions
File tree
- src/allotropy/parsers/roche_cedex_bioht
- tests/parsers/roche_cedex_bioht
- testdata
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| 97 | + | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| |||
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
| 107 | + | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| |||
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
| |||
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
162 | | - | |
163 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
Lines changed: 110 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
117 | 123 | | |
118 | | - | |
| 124 | + | |
119 | 125 | | |
120 | 126 | | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
125 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
126 | 138 | | |
127 | | - | |
| 139 | + | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
134 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
135 | 153 | | |
136 | 154 | | |
137 | 155 | | |
| |||
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
158 | | - | |
| 176 | + | |
159 | 177 | | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
163 | 181 | | |
164 | 182 | | |
165 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
166 | 190 | | |
167 | | - | |
| 191 | + | |
168 | 192 | | |
169 | 193 | | |
170 | 194 | | |
171 | 195 | | |
172 | 196 | | |
173 | 197 | | |
174 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
175 | 205 | | |
176 | 206 | | |
177 | 207 | | |
178 | | - | |
| 208 | + | |
179 | 209 | | |
180 | 210 | | |
181 | 211 | | |
182 | 212 | | |
183 | 213 | | |
184 | 214 | | |
185 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
186 | 222 | | |
187 | 223 | | |
188 | 224 | | |
189 | 225 | | |
190 | 226 | | |
191 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
192 | 231 | | |
193 | 232 | | |
194 | 233 | | |
| |||
202 | 241 | | |
203 | 242 | | |
204 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
205 | 262 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
211 | 286 | | |
212 | 287 | | |
213 | 288 | | |
| |||
235 | 310 | | |
236 | 311 | | |
237 | 312 | | |
238 | | - | |
| 313 | + | |
239 | 314 | | |
240 | 315 | | |
241 | 316 | | |
242 | 317 | | |
243 | 318 | | |
244 | 319 | | |
245 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
246 | 327 | | |
247 | | - | |
| 328 | + | |
248 | 329 | | |
249 | 330 | | |
250 | 331 | | |
251 | 332 | | |
252 | 333 | | |
253 | 334 | | |
254 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
255 | 342 | | |
256 | 343 | | |
257 | 344 | | |
0 commit comments