|
17 | 17 | tag = args.tag
|
18 | 18 | cwd = os.getcwd()
|
19 | 19 |
|
20 |
| -lines_per_file = 50000 |
| 20 | +lines_per_file = 25000 |
21 | 21 | smallfile = None
|
22 | 22 | num_small_file = 0
|
23 | 23 | with open(f'all_splicing_variants_{tag}.bed', 'r') as bigfile:
|
|
35 | 35 | #get chunks
|
36 | 36 | files = glob.glob('small_file_*')
|
37 | 37 | files.sort()
|
| 38 | +number_of_in_files = len(files) |
38 | 39 | for file in files:
|
39 | 40 | subprocess.run(f'Rscript --vanilla /home/ec2-user/workspace/regtools/scripts/compare_junctions_hist_v2.R {tag} {file}', shell=True, check=True)
|
40 | 41 | output_files = glob.glob("*_out.tsv")
|
41 |
| -output_files.sort() # glob lacks reliable ordering, so impose your own if output order matters |
42 |
| -with open(f'compare_junctions/hist/junction_pvalues_{tag}.tsv', 'wb') as outfile: |
43 |
| - for i, fname in enumerate(output_files): |
44 |
| - with open(fname, 'rb') as infile: |
45 |
| - if i != 0: |
46 |
| - infile.readline() # Throw away header on all but first file |
47 |
| - # Block copy rest of file from input to output without parsing |
48 |
| - shutil.copyfileobj(infile, outfile) |
49 |
| - print(fname + " has been imported.") |
| 42 | +output_files.sort()# glob lacks reliable ordering, so impose your own if output order matters |
| 43 | +number_of_out_files = len(output_files) |
| 44 | +if number_of_in_files == number_of_out_files: |
| 45 | + with open(f'compare_junctions/hist/junction_pvalues_{tag}.tsv', 'wb') as outfile: |
| 46 | + for i, fname in enumerate(output_files): |
| 47 | + with open(fname, 'rb') as infile: |
| 48 | + if i != 0: |
| 49 | + infile.readline() # Throw away header on all but first file |
| 50 | + # Block copy rest of file from input to output without parsing |
| 51 | + shutil.copyfileobj(infile, outfile) |
| 52 | + print(fname + " has been imported.") |
| 53 | +else: |
| 54 | + print("Number of output files doesn't match the number of input files that should have been processed") |
50 | 55 | files = glob.glob('small_file_*')
|
51 | 56 | for file in files:
|
52 | 57 | os.remove(file)
|
|
0 commit comments