示例#1
0
def figpath(filename = 'plot.pdf', delete = False):
    called_name = inspect.stack()[1][3]
    stack = inspect.stack()[1]
    call_path = os.path.abspath(stack[1])
    path = cfg.relPath(call_path)
    figpath = cfg.dataPath(os.path.join('figs',path,called_name,filename))
    if delete:
        if os.path.isfile(figpath):
            os.remove(figpath)
    return figpath
示例#2
0
 def save(self):
     savepath = cfg.dataPath('figs/tmp/tmp_fig_{0}.pdf').format(self.num)
     self.f.savefig(savepath)
示例#3
0
import everySNAKE.config as cfg, everySNAKE.utils.memo as mem
import track
from numpy import *
import os
import numpy as np

#bedfile storing annotations (genes, promoters...)
bedfile = cfg.dataPath('silvana/mouse_genes.bed')
#peakfile storing dnase narrowpeaks.
peakfile = cfg.dataPath('silvana/dhs.narrowPeak')


def getTrackChrPromoters(**kwargs):
    '''
Get all of the forward promoter from a bed file
on a given chromosome.

kwargs
num:   chromosome number 
fname: bedfile path (uses global bedfile as the default)

returns
a list of the coordinates of each forward promoter.
'''
    def setTrackChrPromoters(**kwargs):
        fname = kwargs.get('fname', bedfile)
        num = kwargs.get('num', 1)
        t = track.load(fname);
        chromosome_data = t.read('chr{0}'.format(num))
        rows = [dict(zip(r.keys(),r.data)) for r in iter(chromosome_data)]
        fwd_genes = [e for e in rows if e['strand'] == 1]