bioprov package

Subpackages

Submodules

bioprov.bioprov module

BioProv command-line application. This module holds the main executable.

class bioprov.bioprov.CommandOptionsParser

Bases: object

__init__()
classmethod clear_db()
classmethod create_provstore()
classmethod list()
classmethod show_config()
classmethod show_db()
classmethod show_provstore()
classmethod version()
bioprov.bioprov.main(args=None)

Main function to run the BioProv command-line application. Calls the subparsers defined in the Workflows module.

Parameters

args – args to call the function with. Usually is None and args are automatically extracted from the command line. Passing args is used for testing only.

bioprov.utils module

Helper functions.

class bioprov.utils.Warnings

Bases: object

Class to handle warnings.

__init__()
bioprov.utils.assert_tax_rank(tax_rank)

Tests if a string is a valid taxonomic rank. :param tax_rank: String to be evaluated. :return: True or False.

bioprov.utils.build_prov_attributes(dictionary, namespace)

Inserting attributes into a Provenance object can be tricky. We need a NameSpace for said object, and attributes must be named correctly. This helper function builds a dictionary of attributes properly formatted to be inserted into a namespace.

Parameters
  • dictionary – dict with object attributes.

  • namespace – instance of Namespace.

Returns

List of tuples (QualifiedName, value)

bioprov.utils.convert_bytes(num)

Helper function to convert bytes into KB, MB, etc. From https://stackoverflow.com/questions/2104080/how-can-i-check-file-size-in-python

Parameters

num – Number of bytes.

bioprov.utils.create_logger(log_level=20, log_file=None, tag=None)
bioprov.utils.dict_to_sha256(dictionary)

Get sha256 hexdigest from a dictionary :param dictionary: dict :return: hexdigest

bioprov.utils.dict_to_string(dictionary)

Converts a dictionary to string for pretty printing :param dictionary: dict :return: str

bioprov.utils.file_to_sha256(path)

Get the sha256 of file. Returns None if it does not exist. :param path: A valid file path. :return: sha256 digest or None.

bioprov.utils.get_size(path, convert=True)

Calculate size of a given file. :param path: Valid _path of a file. :param convert: Whether to convert the values to bytes, KB, etc. :return: Size with converted values. 0 if file does not exist.

bioprov.utils.has_serializer(object_)
bioprov.utils.is_serializable_type(type_)
bioprov.utils.parser_help(parser)

Shows help if no arguments are passed for parser. :param parser: An instance of argparse.ArgumentParser :return:

bioprov.utils.pattern_replacer(pattern, iterable_of_olds, new)

Replaces a list of old terms from a given pattern for a new term.

Used for switching file paths in the ‘bioprov.src.main.from_json’ module.

Parameters
  • pattern – pattern to replace.

  • iterable_of_olds – old terms.

  • new – new term.

Returns

bioprov.utils.serializer(object_)

Helper function to serialize objects into JSON compatible dictionaries. :param object_: A BioProv class instance. :return: JSON compatible dictionary.

bioprov.utils.serializer_filter(_object, keys)

Filters keys from _object.__dict__ to make custom serializers.

Parameters
  • _object – A bioprov object

  • keys – keys to be filtered.

Returns

dict

Module contents

Init module for package bioprov.

Inherits objects from the src/ package.