constrain.utils

A script that provides utility functions

Functions

counting_occurences(data_with_occurences)

Count the occurences of each key in the input dict and returns the percentage of each key in the total values

location_to_start_end_strand(dictionary)

Convert "location" as Bio.SeqFeature.CompoundLocation to "start", "end", "strand" key-value pairs.

mean(lst)

Get mean from a list.

nest_dict(dictionary, key_for_nested_dict[, ...])

"

rename_dict_keys(dictionary, trans_dictionary)

rename the keys of a dictionary using another dictionary Parameters: ----------- dictionary : Dict[K, V] The input dictionary trans_dictionary : Dict[K, K] The dictionary containing the keys to be replaced as keys and the new keys as values

split_based_on_keys(dictionary, key_list)

Split a dictionary into two based on a list of keys. Parameters: ----------- dictionary : Dict[Any, Any] The input dictionary key_list : List[str] The list of keys to split the dictionary on.

start_end_to_location(dictionary, length)

Start and End Key Value pair to Compound Location Key Value pair.

unnest_dict(dictionary, key_unnest_dict)

Unnest a dictionary by merging the values of a nested dictionary with the original dictionary, and renaming the key "label" to "name"