Commit 427f6e8
authored
Automatically propagate/condense slots when parsing/writing. (#629)
* Enable automatic propagation and condensation.
Add a `propagate` parameter to all `parse_*` functions. When that
parameter is true, the parsing function will automatically propagate all
condensed slots in the parsed mapping set, prior to returning a
MappingSetDataFrame.
For the `parse_obographs_json` function, the parameter does not actually
make much sense (a mapping set extracted from a OBOGraph-JSON document
cannot be in a condensed state), but having all parsing functions accept
the same `propagate` parameter allows to keep using the
`get_parsing_function` logic without having to make a special case for
the functions that would not accept a `propagate` parameter. Likewise
for the `parse_alignment_xml` function.
The `propagate` parameter defaults to True -- this is the behaviour
recommended by the SSSOM specification --, except for the aforementioned
`parse_obographs_json` and `parse_alignment_xml` functions.
Propagation is normally performed by calling the
`MappingSetDataFrame#propagate()` method, but in the case of the
`parse_sssom_table()` function this cannot work, because propagation
needs to be performed before we can get a MappingSetDataFrame instance
(otherwise we could fail to construct a MappingSetDataFrame if the
mapping set contains literal mappings and the `subject_type` or
`object_type` slot is condensed). So we use a new
`propagate_condensed_slots()` method instead, which does not require a
MappingSetDataFrame object.
Conversely, we also add a `condense` parameter to all the `write_*`
functions, to perform the opposite operation prior to writing a set. The
parameter defaults to True for all writing functions, except `write_rdf`
since writing condensed slots in RDF is most likely not wanted.
* Update tests for the new behaviour of parsing functions.
Now that (most) parsing functions default to propagate condensed slots,
some tests need to be updated. Parsing-time propagation must be disabled
for:
* some tests that are performed on "half-condensed" test files and do
not expect the structure of the set to be modified;
* the tests for the actual propagation/condensation feature (can't
properly test propagation if the parser already did it for us).
In addition, we add a test to check that parsing-time condensation does
allow to successfully read a set containing literal mappings when the
object_type slot is condensed (#606).
* Add --[no-]propagate and --[no-]condense options.
Now that parsing and writing functions default to automatically
propagate and condense (respectively) sets, we add `--no-propagate`
and `--no-condense` options to some commands to alter the default
behaviour.
Specifically, we add such options to:
* `sssom convert`,
* `sssom parse`,
* `sssom validate`,
* and `sssom merge`.
It is currently not deemed useful (by me at least) to add those options
to every single command.1 parent 8e2f8b7 commit 427f6e8
File tree
9 files changed
+180
-45
lines changed- src/sssom
- tests
- data
9 files changed
+180
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
| |||
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
151 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
152 | 163 | | |
153 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
154 | 171 | | |
155 | 172 | | |
156 | 173 | | |
| |||
193 | 210 | | |
194 | 211 | | |
195 | 212 | | |
| 213 | + | |
| 214 | + | |
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
| |||
203 | 222 | | |
204 | 223 | | |
205 | 224 | | |
| 225 | + | |
| 226 | + | |
206 | 227 | | |
207 | 228 | | |
208 | 229 | | |
| |||
215 | 236 | | |
216 | 237 | | |
217 | 238 | | |
| 239 | + | |
| 240 | + | |
218 | 241 | | |
219 | 242 | | |
220 | 243 | | |
| |||
227 | 250 | | |
228 | 251 | | |
229 | 252 | | |
230 | | - | |
| 253 | + | |
| 254 | + | |
231 | 255 | | |
232 | 256 | | |
233 | | - | |
| 257 | + | |
234 | 258 | | |
235 | 259 | | |
236 | 260 | | |
| |||
522 | 546 | | |
523 | 547 | | |
524 | 548 | | |
525 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
526 | 554 | | |
527 | | - | |
| 555 | + | |
528 | 556 | | |
529 | | - | |
| 557 | + | |
530 | 558 | | |
531 | 559 | | |
532 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | | - | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
| |||
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| 95 | + | |
| 96 | + | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
| |||
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
108 | 117 | | |
109 | | - | |
| 118 | + | |
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
122 | 132 | | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
129 | | - | |
| 140 | + | |
130 | 141 | | |
131 | 142 | | |
132 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| 308 | + | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
| |||
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
| 320 | + | |
318 | 321 | | |
319 | 322 | | |
320 | 323 | | |
| |||
358 | 361 | | |
359 | 362 | | |
360 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
361 | 367 | | |
362 | 368 | | |
363 | 369 | | |
| |||
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
| 388 | + | |
382 | 389 | | |
383 | 390 | | |
384 | 391 | | |
| |||
406 | 413 | | |
407 | 414 | | |
408 | 415 | | |
| 416 | + | |
| 417 | + | |
409 | 418 | | |
410 | 419 | | |
411 | 420 | | |
| |||
416 | 425 | | |
417 | 426 | | |
418 | 427 | | |
| 428 | + | |
419 | 429 | | |
420 | 430 | | |
421 | 431 | | |
| |||
443 | 453 | | |
444 | 454 | | |
445 | 455 | | |
| 456 | + | |
| 457 | + | |
446 | 458 | | |
447 | 459 | | |
448 | 460 | | |
| |||
454 | 466 | | |
455 | 467 | | |
456 | 468 | | |
| 469 | + | |
457 | 470 | | |
458 | 471 | | |
459 | 472 | | |
460 | 473 | | |
461 | 474 | | |
462 | 475 | | |
463 | 476 | | |
| 477 | + | |
464 | 478 | | |
465 | 479 | | |
466 | 480 | | |
| |||
471 | 485 | | |
472 | 486 | | |
473 | 487 | | |
474 | | - | |
| 488 | + | |
475 | 489 | | |
476 | 490 | | |
477 | 491 | | |
478 | 492 | | |
479 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
480 | 497 | | |
481 | 498 | | |
482 | 499 | | |
| |||
539 | 556 | | |
540 | 557 | | |
541 | 558 | | |
| 559 | + | |
542 | 560 | | |
543 | 561 | | |
544 | 562 | | |
| |||
552 | 570 | | |
553 | 571 | | |
554 | 572 | | |
| 573 | + | |
| 574 | + | |
555 | 575 | | |
556 | 576 | | |
557 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 345 | + | |
370 | 346 | | |
371 | 347 | | |
372 | 348 | | |
| |||
1306 | 1282 | | |
1307 | 1283 | | |
1308 | 1284 | | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1309 | 1330 | | |
1310 | 1331 | | |
1311 | 1332 | | |
| |||
0 commit comments