|
| 1 | +""" Functions at the root of the ``ontoweaver`` module are high-level functions useful to the end user. |
| 2 | +
|
| 3 | + .. note:: |
| 4 | + If you are looking to write your own code calling OntoWeaver, |
| 5 | + those functions are probably the only thing you will need. |
| 6 | +
|
| 7 | + If you want to understand how OntoWeaver works internally, you may start with |
| 8 | + the :func:`ontoweaver.weave` function, and follow the calls from there. |
| 9 | +""" |
| 10 | + |
1 | 11 | from typing import Tuple |
2 | 12 | from pathlib import Path |
3 | 13 | from abc import ABCMeta as ABSTRACT, abstractmethod |
@@ -356,11 +366,29 @@ def read_table_file(filename, **kwargs): |
356 | 366 |
|
357 | 367 |
|
358 | 368 | def extract_reconciliate_write(biocypher_config_path, schema_path, data_to_mapping, parallel_mapping = 0, reconciliate_sep = "|", affix = "none", type_affix_sep = ":", validate_output = False, sort_key = None, raise_errors = True, **kwargs): |
| 369 | + """Deprecated alias for ``weave`` (since version 1.2). |
| 370 | + """ |
359 | 371 | logger.warning("The `extract_reconciliate_write` function is deprecated and will be removed in the next version, use `weave` instead.") |
360 | 372 | return weave(biocypher_config_path, schema_path, data_to_mapping, parallel_mapping, reconciliate_sep, affix, type_affix_sep, validate_output, sort_key, raise_errors, **kwargs) |
361 | 373 |
|
362 | 374 |
|
363 | 375 | def load_extract(data, with_mapping, with_loader, parallel_mapping = 0, affix="none", type_affix_sep=":", validate_output = False, raise_errors = True, **kwargs) -> Tuple[list[Tuple], list[Tuple]]: |
| 376 | + """ Load the given data with the given loader, and apply the given mapping on it. |
| 377 | +
|
| 378 | + Args: |
| 379 | + data: whatever data item that the with_loader is able to load. |
| 380 | + with_mapping: the mapping dictionary |
| 381 | + with_loader: the loader with which to load data |
| 382 | + parallel_mapping: if > 0, will run in parallel mode |
| 383 | + affix: whether to add a type affix |
| 384 | + type_affix_sep: a string for separating the ID from the type affix |
| 385 | + validate_output: if True, calls the validate section of the mapping, if any |
| 386 | + raise_errors: if True, stop at the first error, if False, try to proceed anyway |
| 387 | + kwargs: arguments passed to the loader function |
| 388 | +
|
| 389 | + Returns: |
| 390 | + a pair of lists, the first one are nodes, the second one are egdes |
| 391 | + """ |
364 | 392 | logger.info(f"Use with_loader `{with_loader.__class__.__name__}` to load `{data}`") |
365 | 393 |
|
366 | 394 | assert with_loader.allows([data]), "This loader cannot handle this data" |
@@ -677,5 +705,11 @@ def validate_input_data_loaded(dataframe, validator, raise_errors = True) -> boo |
677 | 705 |
|
678 | 706 |
|
679 | 707 | def ow2bc(ow_elements): |
| 708 | + """ Convert OntoWeaver objects into BioCypher tuples |
| 709 | +
|
| 710 | + This is useful for converting whatever gets out of OntoWeaver's |
| 711 | + ``weave`` or ``extract*`` functions into tuples that can be |
| 712 | + fed to the fusion module or to BioCypher. |
| 713 | + """ |
680 | 714 | return [e.as_tuple() for e in ow_elements] |
681 | 715 |
|
0 commit comments