util¶
-
class
anadama2.util.
SerializableMixin
[source]¶ Mixin that defines a few methods to simplify serializing objects
-
serializable_attrs
= []¶
-
-
anadama2.util.
deserialize_map_file
(file_handle)[source]¶ Returns a list of namedtuples according to the contents of the file_handle according to the customs of QIIME
-
anadama2.util.
dichotomize
(it, tf_func)[source]¶ Split an iterable into two lists by use of a function that returns True or False.
Parameters: - it – The items to split
- tf_func – A function that returns True or False
Returns: 2-Tuple of lists: the items for which the function returned True, and the items for which the function returned False
-
anadama2.util.
dict_to_cmd_opts_iter
(opts_dict, shortsep=' ', longsep='=', shortdash='-', longdash='--')[source]¶ sep separates long options and their values, singlesep separates short options and their values e.g. –long=foobar vs -M 2
-
anadama2.util.
filter_compressed
(fname_list)[source]¶ Return only files that are known to be compressed and in a recognized compression format
-
anadama2.util.
find_on_path
(*args, **kwargs)[source]¶ Finds an executable living on the shells PATH variable. :param bin_str: String; executable to find
Returns: Absolute path to bin_str or False if not found Return type: str
-
anadama2.util.
get_name
(t)[source]¶ Get the name of a tracked object
Parameters: t (objects implementing the anadama2.tracked.Base
interface) – The tracked object
-
anadama2.util.
kebab
(s)[source]¶ Kebab-case a string. Intra-string whitespace is converted to
-
and unfriendly characters are dropped.
-
anadama2.util.
keepkeys
(d, keys)[source]¶ Drop all keys from dictionary
d
except those inkeys
. Modifies the dictionary in place!Parameters: - d (dict) – The dictionary to modify
- keys (iterable) – The keys to keep
-
anadama2.util.
keyrename
(d, mapping)[source]¶ Change all keys in dictionary
d
according tomapping
. Modifiesd
in place!Parameters: - d (dict) – The dictionary to change
- mapping (iterable of 2-tuples) – The keys to change and to what to change them
-
anadama2.util.
sugar_list
(x)[source]¶ Turns just a single thing into a list containing that single thing.