Skip to content

Commit

Permalink
BUG: handle single end of reverse reads in summarize (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Bolyen <ebolyen@gmail.com>
  • Loading branch information
Oddant1 and ebolyen committed Aug 20, 2020
1 parent b43b925 commit 1dcf460
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions q2_demux/_summarize/_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def summarize(output_dir: str, data: _PlotQualView, n: int = 10000) -> None:

manifest = data.manifest.view(pd.DataFrame)

directions = ['forward', 'reverse'] if paired else ['forward']
columns = list(manifest.columns)

directions = columns
file_records = {'forward': [], 'reverse': []}
per_sample_fastq_counts = {'forward': {}, 'reverse': {}}
subsample_size = {'forward': n, 'reverse': n}
Expand All @@ -132,7 +134,7 @@ def summarize(output_dir: str, data: _PlotQualView, n: int = 10000) -> None:
# If we have an empty direction for a sample that will be a nan in
# the manifest. Skip that nan
if type(filename) != str:
if np.isnan(filename):
if filename is None or np.isnan(filename):
continue

for seq in _read_fastq_seqs(filename):
Expand Down
8 changes: 2 additions & 6 deletions q2_demux/_summarize/assets/overview.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{% extends "tab-child.html" %}

{% block content %}
{% if paired %}
{% set directions = ['forward', 'reverse'] %}
{% else %}
{% set directions = ['forward'] %}
{% endif %}
{% set directions = ['forward', 'reverse'] %}

<div class="row">
<div class="col-lg-12">
Expand All @@ -29,7 +25,7 @@ <h3>{{ direction|capitalize }} Reads Frequency Histogram</h3>
{% endif %}
</div>
</div>
{% endfor %}
{% endfor %}
</div>

<div class="row">
Expand Down
2 changes: 2 additions & 0 deletions q2_demux/tests/data/reverse_only/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sample-id,filename,direction
sample2,sample2_2_L001_R2_001.fastq.gz,reverse
2 changes: 2 additions & 0 deletions q2_demux/tests/data/reverse_only/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
phred-offset: 33

Binary file not shown.
8 changes: 8 additions & 0 deletions q2_demux/tests/test_demux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,14 @@ def test_warnings_per_direction(self):
self.assertIn('greater than the amount of sequences across all'
' samples for the reverse reads', html)

def test_only_reverse_reads(self):
reverse = SingleLanePerSampleSingleEndFastqDirFmt(
self.get_data_path('reverse_only'), mode='r')
with tempfile.TemporaryDirectory() as output_dir:
summarize(output_dir, _PlotQualView(reverse, paired=False), n=1)
# Checkpoint assertion
self.assertTrue(True)

def test_empty_single_end(self):
empty = SingleLanePerSampleSingleEndFastqDirFmt(
self.get_data_path('summarize_empty/empty_single_end'), mode='r')
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'data/summarize_empty/empty_forward_in_paired/*',
'data/summarize_empty/empty_reverse_in_paired/*',
'data/summarize_empty/empty_paired_end/*'
'data/reverse_only/*'
],
'q2_demux': ['_summarize/assets/*.html',
'_summarize/assets/dist/*',
Expand Down

0 comments on commit 1dcf460

Please sign in to comment.