コード例 #1
0
    def _run(self):
        kw = self._data
        BIGWIG_PAIRS = kw['BIGWIG_PAIRS']
        BIGWIG_FILES = kw['BIGWIG_FILES']
        BIGWIG_NAMES = kw['BIGWIG_NAMES']
        PARAMS = kw['PARAMS']
        FORCE = kw['FORCE']
        NCORE = kw['NCORE']
        #         PARAMS['NCORE'] = kw['NCORE']
        #         kw['LAST_FILE'] = kw['OFNAME'] = OFNAME = kw['OFNAME'].realpath()
        #         kw['LAST_DIR'] = OFNAME.dirname()
        kw['PEAK_FILE'] = PEAK_FILE = kw['PEAK_FILE'].realpath()
        assert kw['OUTDIR']
        kw['OUTDIR'] = OUTDIR = kw['OUTDIR'].realpath()
        AXIS_DICTS = kw['AXIS_DICTS']

        if BIGWIG_PAIRS:
            assert not BIGWIG_NAMES and not BIGWIG_FILES, (
                'conflict arguments')
            BIGWIG_FILES, BIGWIG_NAMES = zip(BIGWIG_PAIRS)
            pass
        else:
            assert BIGWIG_FILES
            if not BIGWIG_NAMES:
                BIGWIG_NAMES = map(pyext.getBname, BIGWIG_FILES)

        with pyext.getPathStack([OUTDIR], force=1):
            OFNAME = 'DONE'
            #         OFNAME =
            if not FORCE and pyext.file__notEmpty(OFNAME):
                pass
            else:
                figs, (bwTable, bwAvg) = sjob.figs__peakBW(
                    peakFile=PEAK_FILE,
                    bwFiles=BIGWIG_FILES,
                    outIndex=None if not len(BIGWIG_NAMES) else BIGWIG_NAMES,
                    NCORE=NCORE,
                    **PARAMS)
                fig = figs.values()[0]
                for (axis, d_ax) in zip(fig.axes, AXIS_DICTS):
                    pyext.obj__dict__call(axis, d_ax)

                for OFNAME in ['MAIN.png', 'MAIN.svg']:
                    plotters.fig__save(fig, OFNAME)
                bwTable.to_pickle('bwTable.pk')
                bwAvg.to_pickle('bwAvg.pk')
                pyext.printlines([pyext.dppJson(kw)], "DATA.json")
                pyext.printlines(['DONE'], 'DONE')


#         if not OFNAME:
#         if not OFNAME
#     "outerRadius":500,
#     "NCORE":4,
#     "peakFile":'/home/feng/static/lists/1112__ELF3__chipTarg.narrowPeak',
#     "bwFiles":lambda self,key,DATA_ACC_LIST,chipseq_db:
#         map(chipseq_db['get__chipseq__bwfile'],DATA_ACC_LIST)
#     "OFNAME":

#     return
コード例 #2
0
def dump_peak_quality(sample):
    if not pyext.file__notEmpty(sample['npkfile']):
        print (sample['data_acc'],sample['npkfile'])
        template= '''
        sample_accession={sample.data_acc}
        number_of_peaks_below_5%FDR=NA
        number_of_peaks_above_5fold_enrichment=NA
        '''.strip().replace('\t','').replace(' ','')
    else:
        df = _readData(sample['npkfile'],columns=pyext.columns.bed,header=None)

        template= '''
        sample_accession={sample.data_acc}
        number_of_peaks_below_5%FDR={((df['neglogQval'] > -pyext.np.log10(0.05) )).sum()}
        number_of_peaks_above_5fold_enrichment={(df['FC'] > 5 ).sum()}
        '''.strip().replace('\t','').replace(' ','')
    
    return pyext.template__format(template,sample)
コード例 #3
0
def sample_get_depth(sample,
                     OUTPUT_FILE,
                     FORCE=0):
    if not FORCE and pyext.file__notEmpty(OUTPUT_FILE):
        pass
    else:
        d = pyext._DICT_CLASS()
        d['DATA_ACC']=sample['data_acc']
        CMD = ["gzip","-d<",sample['rawfile_files_orig'][0],'|wc','-l']
        res = pyext.shellexec(' '.join(CMD))
        d['READ_COUNT_RAW'] = int(res.strip())//4
        CMD = ["cat",sample["file_bam_orig"],
               "|samtools","view","-F0x4","-F0x100","-c",
              ]
        res = pyext.shellexec(' '.join(CMD))        
        d['READ_COUNT_UNIQ_MAPPED'] = int(res.strip())
        with open(OUTPUT_FILE,'w') as f:
            pyext.json.dump(d, f,indent=4)
    return pyext.readData(OUTPUT_FILE)
コード例 #4
0
import synotil.util as sutil
import pymisca.util as pyutil

from lazydict import LazyDictionary
template = job = LazyDictionary()
__FILE__ = path.Path(__file__)
DEPENDS = {
    'meta_chip': (pyext.readData, '/home/feng/meta/meta_chip.tsv'),
    'fig_meta': (pyext.readData, __FILE__.dirname() / '0726-figure-meta.tsv'),
    'chipseq_targets_peaks_file':
    (None, '/home/feng/static/lists/1112__ELF3__chipTarg.narrowPeak'),
}

for k in DEPENDS:
    v = DEPENDS[k]
    assert pyext.file__notEmpty(v[1]), (v[1], )
    if v[0] is not None:
        job[k] = v[0](v[1])
    else:
        job[k] = v[1]


@pyext.setItem(job, "chipseq_targets_peaks")
def _func(
    self,
    key,
):

    pass