Skip to content

Commit e391d5a

Browse files
committed
minor fix
1 parent e6a3114 commit e391d5a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

scripts/stats_wrapper.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
tag = args.tag
1818
cwd = os.getcwd()
1919

20-
lines_per_file = 50000
20+
lines_per_file = 25000
2121
smallfile = None
2222
num_small_file = 0
2323
with open(f'all_splicing_variants_{tag}.bed', 'r') as bigfile:
@@ -35,18 +35,23 @@
3535
#get chunks
3636
files = glob.glob('small_file_*')
3737
files.sort()
38+
number_of_in_files = len(files)
3839
for file in files:
3940
subprocess.run(f'Rscript --vanilla /home/ec2-user/workspace/regtools/scripts/compare_junctions_hist_v2.R {tag} {file}', shell=True, check=True)
4041
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")
5055
files = glob.glob('small_file_*')
5156
for file in files:
5257
os.remove(file)

0 commit comments

Comments
 (0)