Esempio n. 1
0
# Copyright (C) 2015 by Per Unneberg
import os
import snakemakelib.bio.ngs.db
from snakemakelib.log import LoggerManager

smllogger = LoggerManager().getLogger(__name__)

def annotation(db_config, annotation="ref-transcripts.gtf", ignore_extra_ref=False, fmt="gtf"):
    """Return the annotation as a string"""
    if os.path.isabs(annotation):
        if not annotation.endswith(fmt):
            (root, ext) = os.path.splitext(annotation)
            annotation = "{root}.{ext}".format(root=root, ext=fmt)
        return annotation
    if db_config['ref']:
        smllogger.debug("reference set: assuming index locations are organized according to cloudbiolinux conventions")
        if db_config['extra_ref'] and not ignore_extra_ref:
            smllogger.debug("extra references set: renaming annotation file")
            annotation = "ref-transcripts-" + "-".join([os.path.splitext(os.path.basename(x))[0] for x in db_config['extra_ref']]) + "." + fmt
        annotation = os.path.join(os.path.dirname(db_config['ref']), os.pardir, 'rnaseq', annotation)
        return annotation

def ref(ref, db_config):
    """Return the fasta reference sequence as a string
    
    Args:
      db_config: configuration object for section bio.ngs.settings.db

    Returns:
      seq: A <string> representing the reference fasta sequence
    """
Esempio n. 2
0
Author: Per Unneberg
Created: Tue Dec  1 08:59:21 2015

NOTE: the functions in this module allow for plotting of multiple
columns of a data frame. If ggplot conventions are to be followed, the
data frame should first be stacked. I keep these here for now as I'm
uncertain what is the best way forward.

'''

from bokeh.models import ColumnDataSource
from snakemakelib.graphics.geom import lines
from snakemakelib.log import LoggerManager

smllogger = LoggerManager.getLogger(__name__)

__all__ = ['mlines']


def mlines(fig, x, y, df, **kwargs):
    """mlines: add lines to a figure

    Args:
      fig (:py:class:`~bokeh.plotting.Plot`): bokeh Plot object
      x (str): string for x component
      y (str): string for y component
      df (:py:class:`~pandas.DataFrame`): pandas DataFram
      color (bool): set color
      legend (bool): set legend
      kwargs: keyword arguments to pass to fig.line