util

class anadama2.util.Bag[source]
class anadama2.util.Directory(name)[source]
create()[source]
exists()[source]
files(pattern=None)[source]
class anadama2.util.HasNoEqual[source]
class anadama2.util.SerializableMixin[source]

Mixin that defines a few methods to simplify serializing objects

serializable_attrs = []
exception anadama2.util.SerializationError[source]
exception anadama2.util.ShellException[source]
exception anadama2.util.SparseMetadataException[source]
anadama2.util.capture(*args, **kwds)[source]
anadama2.util.deserialize(s=None, from_fp=None)[source]
anadama2.util.deserialize_csv(file_handle)[source]
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(*args, **kwds)[source]
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.first(iterable)[source]
anadama2.util.generator_flatten(gen)[source]
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.guess_seq_filetype(guess_from)[source]
anadama2.util.intatleast1(n)[source]
anadama2.util.is_compressed(fname)[source]
anadama2.util.islambda(func)[source]
anadama2.util.isnottask(x)[source]
anadama2.util.istask(x)[source]
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 in keys. 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 to mapping. Modifies d 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.memoized(func)[source]
anadama2.util.mkdirp(path)[source]
anadama2.util.noop(*args, **kwargs)[source]
anadama2.util.partition(it, binsize, pad=None)[source]
anadama2.util.serialize(obj, to_fp=None)[source]
anadama2.util.serialize_map_file(namedtuples, output_fname)[source]
anadama2.util.sh(cmd, **kwargs)[source]
anadama2.util.sugar_list(x)[source]

Turns just a single thing into a list containing that single thing.

anadama2.util.take(raw_seq_files, index_list)[source]
anadama2.util.underscore(s, repl='[\\s/:@\\, *?]+')[source]

Remove all whitespace and replace with underscores

anadama2.util.which_compressed_idxs(fname_mtx)[source]