Exemplo n.º 1
0
def _func(job, key, WORKDIR, chipseq_targets_peaks):
    fig, axs = plt.subplots(2, 2, figsize=[12, 12])
    axs = axs.ravel()

    with pyext.getPathStack([WORKDIR, key], force=1):
        GSIZE = "/home/feng/ref/ATH-TAIR10/genome.sizes"
        peakFile = chipseq_targets_peaks['LAST_FILE']
        featFile = sutil.bed__leftSummit(
            "/home/feng/ref/ATH-TAIR10/annotation/genes.gtf.cds", GSIZE=GSIZE)
        pyext.file__link(peakFile, "PEAK_FILE.bed", force=1)
        pyext.file__link(featFile, "FEAT_FILE.bed", force=1)
        res = synotil.qcplots.qc_summitDist(
            #             chipseq_targets_genes_peaks,
            peakFile,
            featFile,
            GSIZE=GSIZE,
            axs=axs,
            CUTOFF=500,
        )
        df = res[0]
        #         pyext.readData(peakFile,header=None).set_index(3,drop=0).reindex(df['acc'])
        #         df =  df.set_index('acc',drop=0).reindex(pyext.readData(peakFile,header=None).set_index(3))
        df.to_csv("PEAK_DIST.csv", index=0)

        lst = df.dropna()['feat_acc'].drop_duplicates().values.tolist()
        with pyext.getPathStack([WORKDIR, key], force=1) as stack:
            pyext.printlines(lst, "OUT.it")

    return dict(LAST_DIR=WORKDIR / key)
Exemplo n.º 2
0
def get_soft_text():
#     OUTPUT_FILE = WORKDIR() / _fkey() ("get_soft_text.tar.gz")
#     dfc = meta_df_rnaseq()
    BUFFER_ALL = BUFFER_RNASEQ() + BUFFER_CHIPSEQ()

    FORCE = 1

    OUTDIR = WORKDIR()/_fkey()
    shell.real__dir(dirname= OUTDIR)
    
    if not FORCE and shell.file__notEmpty(OUTDIR + '.tar.gz'):
        pass
    else:
        df_figureRegistry().to_csv(OUTDIR / 'figureRegistry.csv',index=0)
        def _worker(sample):
            sample = attrdict.AttrDict(sample)
            sample.title = "_".join([sample[k] for k in "data_acc,age,tissue,genotype,ztime,temperature".split(",")])
            res  = res= pyext.jf2( template_common())
            res = '\n'.join([x.strip() for x in res.splitlines()])
            sample.soft_text = res        
            pyext.printlines([sample.soft_text], OUTDIR / pyext.f("{sample.data_acc}.soft.txt"))
#             %sample.data_acc)

            
        [_worker(sample) for sample in pyext.df__iterdict( meta_df_rnaseq().fillna("NA"))]
        [_worker(sample) for sample in pyext.df__iterdict( meta_df_chipseq().fillna("NA"))]
        with pyext.TempDirScope(getTempDirName=lambda: OUTDIR/'_temp',
                                force=1) as tdir:
            tdir = tdir.d
#         tdir = OUTDIR / '_temp'
            shell.real__dir(dirname= tdir)
#             shell.shellexec(' '.join(["tar" ,"-C",tdir,"-xvzf", INPUTDIR()/"./src/polyq-0830.get_soft_text_jaehoon.tar.gz",]))
#             shell.shellexec(' '.join(["tar" ,"-C",tdir,"-xvzf", INPUTDIR()/"./src/polyq-0905.get_soft_text_Jaehoon0906.tar.gz",]))
    
#             shell.shellexec(' '.join(["tar" ,"-C",tdir,"-xvzf", INPUTDIR()/"./src/polyq-0907.katja.get_soft_text.tar.gz",]))
    
            shell.shellexec(' '.join(["unzip","-d",tdir, "-o",INPUTDIR()/"./src/polyq-0907-jaehoon.get_soft_text.zip", ]))
            for fname in tdir.glob('*.soft.txt'):
                DATA_ACC = fname.basename().replace('.soft.txt','',1)
    #             in df_figureRegistry()['DATA_ACC'].tolist()
                assert DATA_ACC in df_figureRegistry()['DATA_ACC'].tolist(),(DATA_ACC,  "JH0905")
                print('[JH0906]',fname.basename(),)
                pyext.file__link(fname, OUTDIR/fname.basename(),force=1)

            
        CMD = [
            "cd",OUTDIR,
            "&&tar","-cvzf",OUTDIR.realpath()+'.tar.gz',"*",
        ]
        CMD = ' '.join(pyext.stringList__flatten(CMD))
        res = shell.shellexec(CMD)
Exemplo n.º 3
0
        "cd",
        OUTDIR,
        "&&cat",
        "SERIES.soft.txt",
        "*autofill*",
        "|grep",
        "-v",
        "^#",
        "|grep",
        "-v",
        "^$",
        "|sed",
        u"'s/^\xEF\xBB\xBF//g'",
        ">" + OUTDIR / OFNAME,
        #                           "|tee","0830-polyq-submit.soft",
    ]),
    silent=1)
pyext.file__link(OUTDIR / OFNAME, WORKDIR() / "ftp" / OFNAME, force=1)

CMD = [
    "cd",
    OUTDIR,
    "&&tar",
    "-cvzf",
    OUTDIR.realpath() + '.tar.gz',
    "*",
]
CMD = ' '.join(pyext.stringList__flatten(CMD))
res = shell.shellexec(CMD)
# pyext.printlines([pyext.jf2(template)], WORKDIR()/ 'get_soft_text' / '0829-polyq.SERIES.soft.txt')
#     break