mdshw5 / fastqp

Simple FASTQ quality assessment using Python

Home Page:https://pypi.python.org/pypi/fastqp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An ZeroDivisionError when I run fastqp.py

EnzoAndree opened this issue · comments

Dear, I just install fastqp and an error occurred when i run the script, this is the error.

fastqp Sanger_F_sample.fastq
At 2186 bytes per read of 1086 length we estimate 96 reads in input file.
Bin size (-s) set to 1.
Traceback (most recent call last):
File "/usr/local/bin/fastqp", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/fastqp/cli.py", line 370, in main
run(arguments)
File "/usr/local/lib/python2.7/site-packages/fastqp/cli.py", line 270, in run
cycle_nuc[i]['T']]) * 100 for i in positions]
ZeroDivisionError: integer division or modulo by zero

Any idea why this error occurred?
I use OSx, python 2.7.13 and a sample of the fastq file is on the attachment.

Regards
Sanger_F.fastq.zip

Thanks for reporting this, and for sending the test data! I think I know what's going on here, but give me a day or two to push a new version with the fix.

I've just pushed a fix, and a new version (0.3) to PyPI. You should update using python install --upgrade fastqp and then give it another shot. Here's an example plot from the test data you sent:
quality_score_quantiles

WoW @mdshw5, it looks awesome. Nevertheless i can't get the full output of fastqp, I get this error.

Sanger_F.fastq NNNNN None 2748.42
/usr/local/lib/python2.7/site-packages/matplotlib/artist.py:879: MatplotlibDeprecationWarning: The set_axis_bgcolor function was deprecated in version 2.0. Use set_facecolor instead.
return func(v)
Traceback (most recent call last):
File "/usr/local/bin/fastqp", line 11, in
load_entry_point('fastqp==0.3.1', 'console_scripts', 'fastqp')()
File "/usr/local/lib/python2.7/site-packages/fastqp/cli.py", line 409, in main
run(arguments)
File "/usr/local/lib/python2.7/site-packages/fastqp/cli.py", line 348, in run
kmerplot(positions, cycle_kmers, zip_archive, [fields[0] for fields in bad_kmers], fig_kw)
File "/usr/local/lib/python2.7/site-packages/fastqp/plots.py", line 493, in kmerplot
'axis_bgcolor': 'white'}, **fig_kw)
File "/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 1211, in subplots
ax0 = fig.add_subplot(gs[0, 0], **subplot_kw)
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1021, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py", line 73, in init
self._axes_class.init(self, fig, self.figbox, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 526, in init
self.spines = self._gen_axes_spines()
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 963, in _gen_axes_spines
('left', mspines.Spine.linear_spine(self, 'left')),
File "/usr/local/lib/python2.7/site-packages/matplotlib/spines.py", line 469, in linear_spine
result = cls(axes, spine_type, path, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/spines.py", line 54, in init
super(Spine, self).init(**kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 126, in init
self.set_facecolor(facecolor)
File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 334, in set_facecolor
self._set_facecolor(color)
File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 324, in _set_facecolor
self._facecolor = colors.to_rgba(color, alpha)
File "/usr/local/lib/python2.7/site-packages/matplotlib/colors.py", line 139, in to_rgba
c = colors[int(c[1]) % len(colors)]
ZeroDivisionError: integer division or modulo by zero

and ONLY this plots:

cycle_specific_base_composition.png
cycle_specific_gc.png
gc_distribution.png
quality_score_distribution.png
quality_score_heatmap.png
quality_score_quantiles.png
read_length_distribution.png

dear @mdshw5, this error appear only to me?

Regards

@EnzoAndree @mdshw5 I am running across the same (more recent) issue, and can reproduce it on the above sample fastq file on fastqp (0.3.1).

I'll take a look and see if I can reproduce it. Can I ask what python version you're running?

python 2.7.13 Anaconda 64-bit

@mdshw5 The problem is caused by an empty list if there are no "bad kmers". I have pushed a (hack-ish) solution #28 that will (temporarily) solve the problem until a better way is found.

Thanks @edawine for taking the time to look in to this. I'll merge your changes and push a new release! I do think an empty list is the correct solution, since I'm using a test of nonlinearity to define over-represented kmers.