|
| 1 | +import subprocess |
| 2 | +import os |
| 3 | +import glob |
| 4 | +import shutil |
| 5 | +import sys |
| 6 | + |
| 7 | +def run(cmd: str) -> None: |
| 8 | + subprocess.run(cmd, shell=True, check=True, stdout=sys.stdout) |
| 9 | + |
| 10 | +cohorts = ['SKCM', 'GBM', 'READ', 'ESCA', 'PAAD', 'SARC', |
| 11 | + 'OV', 'KIRP', 'CESC', 'KIRC', 'LIHC', 'STAD', 'BLCA', |
| 12 | + 'COAD', 'LUSC', 'HNSC', 'LGG', 'LUAD', 'UCEC', 'BRCA']] |
| 13 | + |
| 14 | +for cohort in cohorts: |
| 15 | + os.makedirs(f'{cohort}/samples', exist_ok=True) |
| 16 | + os.makedirs(f'{cohort}/compare_junctions/hist', exist_ok=True) |
| 17 | + bed_files = glob.glob(f'{cohort}*modified.bed') |
| 18 | + for bed_file in bed_files: |
| 19 | + shutil.copy(bed_file, f'{cohort}/{bed_file}') |
| 20 | + os.chdir(f'{cohort}/samples') |
| 21 | + run(f'aws s3 cp s3://regtools-results-unstranded/{cohort}/ . --recursive') |
| 22 | + tar_files = glob.glob('*.tar.gz') |
| 23 | + for tar_file in tar_files: |
| 24 | + run(f'tar xzf {tar_file}') |
| 25 | + os.remove(tar_file) |
| 26 | + run('rm -rf all*; rm -rf compare_junctions*') |
| 27 | + os.chdir('..') |
| 28 | + run('ls samples/ > dir_names.tsv') |
| 29 | + bed_files = glob.glob(f'*modified.bed') |
| 30 | + for bed_file in bed_files: |
| 31 | + tag = bed_file.split('_')[1] |
| 32 | + os.rename(bed_file, f'all_splicing_variants_{tag}.bed') |
| 33 | + run(f'python3 /home/ec2-user/workspace/regtools/scripts/stats_wrapper.py {tag}') |
| 34 | + run(f'Rscript --vanilla /home/ec2-user/workspace/regtools/scripts/filter_and_BH.R {tag}') |
| 35 | + run(f'aws s3 cp compare_junctions/ s3://regtools-results-unstranded/{cohort}/compare_junctions3/ --recursive)') |
| 36 | + os.chdir('..') |
| 37 | + shutil.rmtree(cohort) |
0 commit comments