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)
def main(): temp = template_common() samples = meta_df_rnaseq() df = samples.fillna('NA') samples = pyext.df__iterdict( df) samples = list(samples) samples = [AttrDict(x) for x in samples] # Samples from pprint import pprint # pprint(samples) # print(samples[0]) for sample in samples: sample['rawfile_detail'] = sample_get_rawfile_detail(sample) sample['processing_protocol'] = sample_rnaseq_processing_protocol(sample) # processing_rnaseq_brachy(), # for sample in samples: pprint(sample) # pprint(samples) res = Template(temp, undefined=StrictUndefined).render(**locals()) res = Template(res, undefined=StrictUndefined).render(**locals()) # res = Template(res, undefined=StrictUndefined).render(**locals()) # res = pyext.jf2(temp) # break # res = pyext.jf2(res) res = clean(res) fn = (WORKDIR()+'.soft_files').makedirs_p()/sample['data_acc']+'.soft.txt' with io.open( fn,'w',encoding='utf8') as f: f.write(res) # print(res) # break # print(template_common()) pass
def sample_init_full(): its = [ pyext.df__iterdict( meta_df_chipseq().fillna("NA")), pyext.df__iterdict( meta_df_rnaseq().fillna("NA")), ] it = sum(map(list,its),[]) # # it = pyext.df__iterdict( meta_df_rnaseq().fillna("NA")) # it =( list(pyext.df__iterdict( meta_df_chipseq().fillna("NA"))) # + list(pyext.df__iterdict( meta_df_rnaseq().fillna("NA")) )) def _worker(sample): sample = attrdict.AttrDict(sample) sample.title = "_".join([sample[k] for k in "data_acc,age,tissue,genotype,ztime,temperature".split(",")]) return sample return map(_worker, it)