Skip to content

Commit 25ba29c

Browse files
committed
doc: remaining undocumented functions in init module
1 parent 64809c4 commit 25ba29c

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/ontoweaver/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
from typing import Tuple
212
from pathlib import Path
313
from abc import ABCMeta as ABSTRACT, abstractmethod
@@ -356,11 +366,29 @@ def read_table_file(filename, **kwargs):
356366

357367

358368
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+
"""
359371
logger.warning("The `extract_reconciliate_write` function is deprecated and will be removed in the next version, use `weave` instead.")
360372
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)
361373

362374

363375
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+
"""
364392
logger.info(f"Use with_loader `{with_loader.__class__.__name__}` to load `{data}`")
365393

366394
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
677705

678706

679707
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+
"""
680714
return [e.as_tuple() for e in ow_elements]
681715

0 commit comments

Comments
 (0)