Functions

bbcflib::common Namespace Reference

Functions

def unique_filename_in
def normalize_url
def cat
def track_header
def timer
def writecols
def readcols
def isnum
def unique
def gzipfile
def join_pdf
def coverageBed
def intersectBed
def track_convert
def gMiner_run
def merge_sql
def intersect_many_bed
def set_file_descr
def get_files

Detailed Description

======================
Module: bbcflib.common
======================

Utility functions common to several pipelines.

Function Documentation

def bbcflib::common::cat (   files,
  out = None,
  skip = 0 
)
Concatenates files.
def bbcflib::common::coverageBed (   file1,
  file2 
)
Binds ``coverageBed`` from the 'BedTools' suite.
def bbcflib::common::get_files (   id_or_key,
  minilims,
  by_type = True,
  select_param = None 
)
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.
def bbcflib::common::gzipfile (   files,
  args = None 
)
Runs gzip on files.
def bbcflib::common::intersect_many_bed (   ex,
  files,
  via = 'lsf' 
)
Runs ``intersectBed`` iteratively over a list of bed files.
def bbcflib::common::intersectBed (   file1,
  file2 
)
Binds ``intersectBed`` from the 'BedTools' suite.
def bbcflib::common::isnum (   s  ) 
Return True if string *s* represents a number, False otherwise
def bbcflib::common::join_pdf (   files  ) 
Uses 'ghostscript' to join several pdf files into one.
def bbcflib::common::merge_sql (   ex,
  sqls,
  outdir = None,
  datatype = 'quantitative',
  via = 'lsf' 
)
Run ``gMiner``'s 'merge_scores' function on a set of sql files
def bbcflib::common::normalize_url (   url  ) 
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'
def bbcflib::common::readcols (   filename,
  header = False,
  sep = "\t",
  skip = 0 
)
Read a *sep*-delimited text file *filename* and stores it
in a dictionary, which keys are column headers if present, and values
are the columns of the file.
If *header*=True, the first line is interpreted as the header.
If *header* is an array, its elements become the column headers.
One can skip the first *skip* lines of the file.
def bbcflib::common::set_file_descr (   filename,
  kwargs 
)
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]'

def bbcflib::common::timer (   function  ) 
A decorator that makes the decorated *function* return its execution time. 
def bbcflib::common::unique (   seq,
  fun = None 
)
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())
def bbcflib::common::unique_filename_in (   path = None  ) 
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.
def bbcflib::common::writecols (   file,
  cols,
  header = None,
  sep = "\t" 
)
Write a list of iterables *cols* as columns in a *sep*-delimited text file.
One can precise an array *header* to define column names.
The parameter *sep* defines the delimiter character between columns.
 All Classes Namespaces Functions