Documentation: bein.util

bein.util – Library of functions for bein

This module is a repository of assorted robust functions that have been developed for bein in day to day use. Much of it is focused on analysis of high throughput sequencing data, but if you have useful functions for a different domain, please contribute them.


bein.util.add_pickle(execution, val, description='', alias=None)[source]

Pickle val, and add it to the repository.

add_pickle lets you dump almost any Python value to a file in the MiniLIMS repository. It is useful to keep track of intermediate calculations. description will be set as the pickle file’s description.

bein.util.use_pickle(ex_or_lims, id_or_alias)[source]

Loads id_or_alias as a pickle file and returns the pickled objects.

ex_or_lims may be either an execution object or a MiniLIMS object.

bein.util.count_lines(execution, filename)[source]

Count the number of lines in filename (equivalent to wc -l).


Pause until the user hits Return.

bein.util.sleep(execution, n)[source]

Sleep for n seconds. Returns n.

bein.util.split_file(execution, filename, n_lines = 1000, prefix = None, suffix_length = 3)[source]

Equivalent to Unix command split.

filename is the file to split. Returns a list of the names of the new files created. n_lines is the number of lines to put in each file, prefix is the file prefix to use (which is set to a unique, randomly chosen string if not specified), and suffix_length is the number of positions to use after the prefix to label the files.

bein.util.touch(execution, filename = None)[source]

Equivalent to shell: touch filename

Returns filename. If filename is None, filename is set to a unique, random name.

bein.util.background(f, *args, **kwargs)[source]

Run a function, but return a Future object instead of blocking.

Instead of blocking, it starts the function in a separate thread, and returns an object which lets the user choose when to wait for the function by calling its wait() method. wait() blocks its current thread until the function returns, then wait returns the value returned by the function.

f = background(sqrt, 0) a = f.wait()

is exactly equivalent to

a = sqrt(0)

except that in the first case, sqrt is run in a separate thread.

The argument list after fun is exactly what you would pass to fun if you were calling it directly, including keyword arguments.

Table Of Contents

Previous topic

Documentation: bein

Next topic

Advanced techniques in bein

This Page

Other BBCF projects