Skip to content

Commit 224053e

Browse files
Merge pull request #45 from antgonza/update-qiita_db.artifacts
adding support for new /qiita_db/artifacts
2 parents a693498 + 5a802dd commit 224053e

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

qtp_sequencing/summary.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ def generate_html_summary(qclient, job_id, parameters, out_dir):
8888
"""
8989
# Step 1: gather file information from qiita using REST api
9090
artifact_id = parameters['input_data']
91+
# we are going to use the "raw" code for retrieving artifact_info vs. the
92+
# qiita_client.artifact_and_preparation_files method because fqtools
93+
# returns 0 (vs. failing, which is nice) on an empty file
94+
# $ touch x.fastq
95+
# $ gzip x.fastq
96+
# $ fqtools count x.fastq.gz
97+
# 0
9198
qclient_url = "/qiita_db/artifacts/%s/" % artifact_id
9299
artifact_info = qclient.get(qclient_url)
93100

94101
# 1a. getting the file paths
95-
filepaths = artifact_info['files']
102+
filepaths = {k: [vv['filepath'] for vv in v]
103+
for k, v in artifact_info['files'].items()}
96104
# 1.b get the artifact type_info
97105
artifact_type = artifact_info['type']
98106

qtp_sequencing/tests/test_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def test_plugin_summary(self):
5454
files = self.qclient.get(
5555
'/qiita_db/artifacts/%s/' % artifact_id)['files']
5656

57-
bcds_fp = files['raw_barcodes'][0]
57+
bcds_fp = files['raw_barcodes'][0]['filepath']
5858
self._clean_up_files.append(bcds_fp)
5959
with GzipFile(bcds_fp, mode='w', mtime=1) as fh:
6060
fh.write(BARCODES.encode())
61-
fwd_fp = files['raw_forward_seqs'][0]
61+
fwd_fp = files['raw_forward_seqs'][0]['filepath']
6262
self._clean_up_files.append(fwd_fp)
6363
with GzipFile(fwd_fp, mode='w', mtime=1) as fh:
6464
fh.write(READS.encode())

qtp_sequencing/tests/test_summary.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def test_generate_html_summary_no_demux(self):
5151
files = self.qclient.get(
5252
'/qiita_db/artifacts/%s/' % artifact_id)['files']
5353

54-
bcds_fp = files['raw_barcodes'][0]
54+
bcds_fp = files['raw_barcodes'][0]['filepath']
5555
self._clean_up_files.append(bcds_fp)
5656
with GzipFile(bcds_fp, mode='w', mtime=1) as fh:
5757
fh.write(BARCODES.encode())
58-
fwd_fp = files['raw_forward_seqs'][0]
58+
fwd_fp = files['raw_forward_seqs'][0]['filepath']
5959
self._clean_up_files.append(fwd_fp)
6060
with GzipFile(fwd_fp, mode='w', mtime=1) as fh:
6161
fh.write(READS.encode())
@@ -71,7 +71,7 @@ def test_generate_html_summary_no_demux(self):
7171

7272
# asserting content of html
7373
res = self.qclient.get("/qiita_db/artifacts/%s/" % artifact_id)
74-
html_fp = res['files']['html_summary'][0]
74+
html_fp = res['files']['html_summary'][0]['filepath']
7575
self._clean_up_files.append(html_fp)
7676
with open(html_fp) as html_f:
7777
html = html_f.read()
@@ -92,7 +92,7 @@ def test_generate_html_summary_demux(self):
9292
# files fo not exist create them
9393
files = self.qclient.get(
9494
'/qiita_db/artifacts/%s/' % artifact_id)['files']
95-
demux_fp = files['preprocessed_demux'][0]
95+
demux_fp = files['preprocessed_demux'][0]['filepath']
9696
copyfile(join(dirname(__file__), 'test_data', '101_seqs.demux'),
9797
demux_fp)
9898
self._clean_up_files.append(demux_fp)
@@ -107,7 +107,7 @@ def test_generate_html_summary_demux(self):
107107

108108
# asserting content of html
109109
res = self.qclient.get("/qiita_db/artifacts/%s/" % artifact_id)
110-
html_fp = res['files']['html_summary'][0]
110+
html_fp = res['files']['html_summary'][0]['filepath']
111111
self._clean_up_files.append(html_fp)
112112

113113
with open(html_fp) as html_f:

0 commit comments

Comments
 (0)