Skip to content

Commit 6f516ed

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

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
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: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from os import close, remove, path
1515
from os.path import join
1616
from tempfile import mkstemp, gettempdir
17-
from shutil import rmtree
1817
from unittest import TestCase, main
1918
from xml.dom import minidom
2019
from xml.etree import ElementTree as ET
@@ -577,10 +576,6 @@ def test_generate_curl_command(self):
577576
<TAG>library_construction_protocol</TAG>
578577
<VALUE>library protocol</VALUE>
579578
</EXPERIMENT_ATTRIBUTE>
580-
<EXPERIMENT_ATTRIBUTE>
581-
<TAG>md5</TAG>
582-
<VALUE>506d31c82999a2cbcda138a369955e7d</VALUE>
583-
</EXPERIMENT_ATTRIBUTE>
584579
<EXPERIMENT_ATTRIBUTE>
585580
<TAG>platform</TAG>
586581
<VALUE>ILLUMINA</VALUE>
@@ -594,7 +589,8 @@ def test_generate_curl_command(self):
594589
<?xml version="1.0" encoding="UTF-8"?>
595590
<RUN_SET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:no\
596591
NamespaceSchemaLocation="ftp://ftp.sra.ebi.ac.uk/meta/xsd/sra_1_3/SRA.run.xsd">
597-
<RUN alias="%(study_alias)s_sample1.fastq.gz_run" center_name="CCME-COLORADO">
592+
<RUN alias="%(study_alias)s_sample1.fastq.gz_run" \
593+
center_name="CCME-COLORADO">
598594
<EXPERIMENT_REF refname="%(organization_prefix)s_ppdid_001:test1"/>
599595
<DATA_BLOCK>
600596
<FILES>

0 commit comments

Comments
 (0)