Skip to content

Commit 971fb3d

Browse files
author
Adam Robbins-Pianka
committed
Do not write empty per-sample fastq files
1 parent 432bf76 commit 971fb3d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

qiita_ware/commands.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# -----------------------------------------------------------------------------
88

99
from os.path import join, isdir
10-
from os import makedirs
10+
from os import makedirs, remove
1111
from functools import partial
1212
from tempfile import mkdtemp
1313
from gzip import open as gzopen
@@ -43,6 +43,11 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None):
4343
True to actually send the files
4444
fastq_dir_fp : str, optional
4545
The fastq filepath
46+
47+
Notes
48+
-----
49+
If fastq_dir_fp is passed, it must not contain any empty files, or
50+
gzipped empty files
4651
"""
4752
preprocessed_data = PreprocessedData(preprocessed_data_id)
4853
preprocessed_data_id_str = str(preprocessed_data_id)
@@ -99,9 +104,14 @@ def submit_EBI(preprocessed_data_id, action, send, fastq_dir_fp=None):
99104
list(sample_template)):
100105
demux_samples.add(samp)
101106
sample_fp = join(fastq_dir_fp, "%s.fastq.gz" % samp)
107+
wrote_sequences = False
102108
with gzopen(sample_fp, 'w') as fh:
103109
for record in iterator:
104110
fh.write(record)
111+
wrote_sequences = True
112+
113+
if not wrote_sequences:
114+
remove(sample_fp)
105115

106116
output_dir = fastq_dir_fp + '_submission'
107117

qiita_ware/test/test_ebi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,6 @@ def test_generate_curl_command(self):
577577
<TAG>library_construction_protocol</TAG>
578578
<VALUE>library protocol</VALUE>
579579
</EXPERIMENT_ATTRIBUTE>
580-
<EXPERIMENT_ATTRIBUTE>
581-
<TAG>md5</TAG>
582-
<VALUE>506d31c82999a2cbcda138a369955e7d</VALUE>
583-
</EXPERIMENT_ATTRIBUTE>
584580
<EXPERIMENT_ATTRIBUTE>
585581
<TAG>platform</TAG>
586582
<VALUE>ILLUMINA</VALUE>

0 commit comments

Comments
 (0)