diff --git a/qtp_sequencing/summary.py b/qtp_sequencing/summary.py index 73f6b86..e66aab1 100644 --- a/qtp_sequencing/summary.py +++ b/qtp_sequencing/summary.py @@ -88,11 +88,19 @@ def generate_html_summary(qclient, job_id, parameters, out_dir): """ # Step 1: gather file information from qiita using REST api artifact_id = parameters['input_data'] + # we are going to use the "raw" code for retrieving artifact_info vs. the + # qiita_client.artifact_and_preparation_files method because fqtools + # returns 0 (vs. failing, which is nice) on an empty file + # $ touch x.fastq + # $ gzip x.fastq + # $ fqtools count x.fastq.gz + # 0 qclient_url = "/qiita_db/artifacts/%s/" % artifact_id artifact_info = qclient.get(qclient_url) # 1a. getting the file paths - filepaths = artifact_info['files'] + filepaths = {k: [vv['filepath'] for vv in v] + for k, v in artifact_info['files'].items()} # 1.b get the artifact type_info artifact_type = artifact_info['type'] diff --git a/qtp_sequencing/tests/test_plugin.py b/qtp_sequencing/tests/test_plugin.py index fc0adf7..322352e 100644 --- a/qtp_sequencing/tests/test_plugin.py +++ b/qtp_sequencing/tests/test_plugin.py @@ -54,11 +54,11 @@ def test_plugin_summary(self): files = self.qclient.get( '/qiita_db/artifacts/%s/' % artifact_id)['files'] - bcds_fp = files['raw_barcodes'][0] + bcds_fp = files['raw_barcodes'][0]['filepath'] self._clean_up_files.append(bcds_fp) with GzipFile(bcds_fp, mode='w', mtime=1) as fh: fh.write(BARCODES.encode()) - fwd_fp = files['raw_forward_seqs'][0] + fwd_fp = files['raw_forward_seqs'][0]['filepath'] self._clean_up_files.append(fwd_fp) with GzipFile(fwd_fp, mode='w', mtime=1) as fh: fh.write(READS.encode()) diff --git a/qtp_sequencing/tests/test_summary.py b/qtp_sequencing/tests/test_summary.py index 4553de9..e169c05 100644 --- a/qtp_sequencing/tests/test_summary.py +++ b/qtp_sequencing/tests/test_summary.py @@ -51,11 +51,11 @@ def test_generate_html_summary_no_demux(self): files = self.qclient.get( '/qiita_db/artifacts/%s/' % artifact_id)['files'] - bcds_fp = files['raw_barcodes'][0] + bcds_fp = files['raw_barcodes'][0]['filepath'] self._clean_up_files.append(bcds_fp) with GzipFile(bcds_fp, mode='w', mtime=1) as fh: fh.write(BARCODES.encode()) - fwd_fp = files['raw_forward_seqs'][0] + fwd_fp = files['raw_forward_seqs'][0]['filepath'] self._clean_up_files.append(fwd_fp) with GzipFile(fwd_fp, mode='w', mtime=1) as fh: fh.write(READS.encode()) @@ -71,7 +71,7 @@ def test_generate_html_summary_no_demux(self): # asserting content of html res = self.qclient.get("/qiita_db/artifacts/%s/" % artifact_id) - html_fp = res['files']['html_summary'][0] + html_fp = res['files']['html_summary'][0]['filepath'] self._clean_up_files.append(html_fp) with open(html_fp) as html_f: html = html_f.read() @@ -92,7 +92,7 @@ def test_generate_html_summary_demux(self): # files fo not exist create them files = self.qclient.get( '/qiita_db/artifacts/%s/' % artifact_id)['files'] - demux_fp = files['preprocessed_demux'][0] + demux_fp = files['preprocessed_demux'][0]['filepath'] copyfile(join(dirname(__file__), 'test_data', '101_seqs.demux'), demux_fp) self._clean_up_files.append(demux_fp) @@ -107,7 +107,7 @@ def test_generate_html_summary_demux(self): # asserting content of html res = self.qclient.get("/qiita_db/artifacts/%s/" % artifact_id) - html_fp = res['files']['html_summary'][0] + html_fp = res['files']['html_summary'][0]['filepath'] self._clean_up_files.append(html_fp) with open(html_fp) as html_f: