Module: bbcflib.common

Utility functions common to several pipelines.

bbcflib.common.cat(files, out=None, skip=0)[source]

Concatenates files.

Parameters:
  • files – (list of str) list of file names of the files to concatenate.
  • out – (str) name of the output file. By default it is a 20-chars random string. If this output file is not empty, files are appended to it.
  • skip – (int) number of lines to skip at the beginning of each file (common header). [0]
bbcflib.common.get_files(id_or_key, minilims, by_type=True, select_param=None)[source]

Retrieves a dictionary of files created by an htsstation job identified by its key or bein id in a MiniLIMS.

The dictionary keys are the file types (e.g. ‘pdf’, ‘bam’, ‘py’ for python objects), the values are dictionaries with keys repository file names and values actual file descriptions (names to provide in the user interface).

‘select_param’ can be used to select a subset of files: if it is a string or a list of strings, then only files containing these parameters will be returned, and if it is a dictionary, only files with parameters matching the key/value pairs will be returned.

bbcflib.common.intersect_many_bed(ex, files, via='lsf')[source]

Runs intersectBed iteratively over a list of bed files.

bbcflib.common.isnum(s)[source]

Return True if string s represents a number, False otherwise

bbcflib.common.merge_sql(ex, sqls, outdir=None, datatype='quantitative', via='lsf')[source]

Run gfminer‘s ‘merge_scores’ function on a set of sql files

bbcflib.common.normalize_url(url)[source]

Produce a fixed form for an HTTP URL.

Make sure the URL begins with http:// and does not end with a /.

>>> normalize_url('http://bbcf.epfl.ch')
'http://bbcf.epfl.ch'
>>> normalize_url('http://bbcf.epfl.ch/')
'http://bbcf.epfl.ch'
>>> normalize_url('bbcf.epfl.ch/')
'http://bbcf.epfl.ch'
bbcflib.common.pause()[source]

Pause until the user hits Return.

bbcflib.common.program_exists(program)[source]

Check if program exists in local $PATH.

bbcflib.common.set_file_descr(filename, **kwargs)[source]

Implements file naming compatible with the ‘get_files’ function:

>>> set_file_descr("toto",**{'tag':'pdf','step':1,'type':'doc','comment':'ahaha'})
'pdf:toto[step:1,type:doc] (ahaha)'

If ‘tag’ and/or comment are ommitted:

>>> set_file_descr("toto",step=1,type='doc')
'toto[step:1,type:doc]'
Parameters:filename – (str) name to be given to the file in the web interface.
Return type:str

Possible keys to kwargs:

  • ‘tag’: (str) added in front of the file name: ‘tag:filename[others]’. Usually the file extension.
  • ‘group’: (str) sample name.
  • ‘step’: (str or int) step in the analysis.
  • ‘type’: (str) type of file, file extension (‘doc’,’txt’,’bam’,...).
  • ‘view’: (1 or 0) whether it is visible in the web interface for non-administrator user. [1]
  • ‘ucsc’: (1 or 0) whether to link with the “View in UCSC” URL in the web interface. [0]
  • ‘gdv’: (1 or 0) whether to link with the “View in GDV” URL in the web interface. [0]
  • ‘comment’: (str) whatever. Added in parentheses after all the rest.
bbcflib.common.timer(function)[source]

A decorator that makes the decorated function return its execution time.

bbcflib.common.unique(seq, fun=None)[source]

Return all unique elements in seq, preserving order - unlike list(set(seq)), and almost as fast. Permits this sort of filter: unique(seq, lambda x: x.lower())

bbcflib.common.unique_filename_in(path=None)[source]

Return a random filename unique in the given path.

The filename returned is twenty alphanumeric characters which are not already serving as a filename in path. If path is omitted, it defaults to the current working directory.

Previous topic

Description

Next topic

Module: bbcflib.daflims

This Page

Websites