DENOFO Utils
The DENOFO Utils module provides utility functions for working with the DENOFO annotation format and other related tasks distributed over three submodules:
denofo.utils.constants: Constants used in the DENOFO toolkit.denofo.utils.helpers: Helper functions for working with the DENOFO annotation format.denofo.utils.ncbiTaxDBcheck: Functions for checking and updating the NCBI Taxonomy Database.
Constants
- class denofo.utils.constants.GoQBack
Class to return if the user wants to go back to the previous question.
Helpers
- denofo.utils.helpers.add_extension(file_path: Path, extension: str = 'dngf') Path
Add an extension to a file path if it does not already have one.
- Parameters:
file_path (Path) – The file path.
extension (str) – The extension to add.
- Returns:
The file path with the extension added.
- Return type:
Path
- denofo.utils.helpers.compare_two_models(dngf1: BaseModel, dngf2: BaseModel, mode: str = 'differences') list[tuple]
Compare two BaseModel objects.
- Parameters:
dngf1 (BaseModel) – The first BaseModel object.
dngf2 (BaseModel) – The second BaseModel object.
mode (str) – The mode of comparison. Options: ‘differences’ (default) or ‘similarities’.
name1 (str) – The name of the first BaseModel object in output.
name2 (str) – The name of the second BaseModel object in output.
- Returns:
The comparison result.
- Return type:
list[tuple[str]]
- denofo.utils.helpers.diff_two_lists(list1: list, list2: list, model_name: str, field_name: str, mode: str = 'differences') list
Compare two lists.
- Parameters:
list1 (list) – The first list.
list2 (list) – The second list.
- Returns:
The comparison result.
- Return type:
list
- denofo.utils.helpers.different_answers(answer: any, prev_answer: any) bool
Check if new answer differs from previously given answer.
- Parameters:
answer (any) – The answer.
prev_answer (any) – The previous answer.
- Returns:
True if the answers are different, False otherwise.
- Return type:
bool
- denofo.utils.helpers.get_model_from_qstack_dict(qstack_dict: dict, model: BaseModel) BaseModel
Get a BaseModel object from a qstack dictionary (which can contain field names and values from other models as well).
- Parameters:
qstack_dict (dict) – The qstack dictionary. keys = model field names, values = model field values.
model (BaseModel) – The BaseModel object.
- Returns:
The BaseModel object with respective field values.
- Return type:
BaseModel
- denofo.utils.helpers.get_model_from_short_repr(short_repr: str, model: BaseModel) BaseModel
Get a BaseModel object from a short representation string.
- Parameters:
short_repr (str) – The short representation string.
model (BaseModel) – The BaseModel object.
- Returns:
The BaseModel object.
- Return type:
BaseModel
- denofo.utils.helpers.get_short_repr(orig_model: BaseModel) str
Get a short representation string of a BaseModel object.
- Parameters:
orig_model (BaseModel) – The BaseModel object.
- Returns:
The short representation of the BaseModel object.
- Return type:
str
- denofo.utils.helpers.infer_format_from_extension(file_path: Path) str
Infer the format of a file based on its extension.
- Parameters:
file_path (Path) – The file path.
- Returns:
The inferred format.
- Return type:
str
NCBI Taxonomy Database Check
- exception denofo.utils.ncbiTaxDBcheck.NCBITAXDBWarning
Warning raised when NCBI Taxonomy Database is newly built or updated
- denofo.utils.ncbiTaxDBcheck.check_NCBI_taxDB() NCBITaxa
Check if NCBI Taxonomy Database exists and is valid or build it if not
- Returns:
NCBI Taxonomy Database object
- Return type:
NCBITaxa
- denofo.utils.ncbiTaxDBcheck.update_NCBI_taxDB()
Update NCBI Taxonomy Database