wdecoster / NanoPlot

Plotting scripts for long read sequencing data
http://nanoplot.bioinf.be
MIT License
429 stars 47 forks source link

IndexError: list index out of range #51

Closed devindrown closed 6 years ago

devindrown commented 6 years ago

Ran into this error on a recent run. This was a barcoded run and I wonder if there is an issue with a lack of data in some barcodes?

Traceback (most recent call last):
  File "/home/dmdrown/anaconda3/bin/NanoPlot", line 11, in <module>
    sys.exit(main())
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanoplot/NanoPlot.py", line 74, in main
    names=barcodes)
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 159, in write_stats
    long_features[lf][1][i], feature_list(stats, long_features[lf][0], index=i)))
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 112, in feature_list
    return '\t'.join([str(s.__dict__[feature][index]) for s in stats])
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 112, in <listcomp>
    return '\t'.join([str(s.__dict__[feature][index]) for s in stats])
IndexError: list index out of range

Logfile

2018-03-04 07:00:51,730 NanoPlot 1.10.4 started with arguments Namespace(N50=False, alength=False, bam=None, barcoded=True, color='#4CB391', cram=None, downsample=None, drop_outliers=True, fasta=None, fastq=None,
fastq_minimal=None, fastq_rich=None, format='png', listcolors=False, loglength=False, maxlength=None, minlength=None, minqual=None, no_N50=False, outdir='/home/dmdrown/watertreat/plots/', percentqual=False, pickle
=None, plots=['dot'], prefix='FBXWasteWater2018_run2', raw=False, readtype='1D', store=False, summary=['/home/dmdrown/watertreat/basecalled/FBXWasteWater2018_run2/sequencing_summary.txt'], threads=12, title=None,
verbose=False)
2018-03-04 07:00:51,730 Python version is: 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)  [GCC 7.2.0]
2018-03-04 07:00:51,732 Nanoplotter: valid output format png
2018-03-04 07:00:51,741 Nanoget: Staring to collect statistics from summary file /home/dmdrown/watertreat/basecalled/FBXWasteWater2018_run2/sequencing_summary.txt
2018-03-04 07:00:51,741 Nanoget: Collecting statistics for 1D sequencing
2018-03-04 07:00:51,741 Nanoget: Extracting metrics per barcode.
2018-03-04 07:00:57,849 Nanoget: Finished collecting statistics from summary file /home/dmdrown/watertreat/basecalled/FBXWasteWater2018_run2/sequencing_summary.txt
2018-03-04 07:01:00,589 Nanoget: Gathered all metrics of 1605423 reads
2018-03-04 07:01:01,830 Calculated statistics
2018-03-04 07:01:01,830 Using sequenced read lengths for plotting.
2018-03-04 07:01:02,113 Removing 8524 length outliers for plotting.
2018-03-04 07:01:02,113 Processed the reads, optionally filtered. 1596899 reads left
2018-03-04 07:01:04,988 list index out of range
Traceback (most recent call last):
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanoplot/NanoPlot.py", line 74, in main
    names=barcodes)
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 159, in write_stats
    long_features[lf][1][i], feature_list(stats, long_features[lf][0], index=i)))
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 112, in feature_list
    return '\t'.join([str(s.__dict__[feature][index]) for s in stats])
  File "/home/dmdrown/anaconda3/lib/python3.6/site-packages/nanomath/nanomath.py", line 112, in <listcomp>
    return '\t'.join([str(s.__dict__[feature][index]) for s in stats])
IndexError: list index out of range
wdecoster commented 6 years ago

I don't immediately see the problem, I'll dive into the code. Can you perhaps share the summary? That would make things easier to replicate.

wdecoster commented 6 years ago

I think that your error gets raised in the case of a (barcoded) sample, for which (after filtering perhaps) more than 0 but less than 5 reads remain. That scenario I was able to replicate and should be fixed in NanoPlot v1.10.5.

Could you check if it also works for your issue?

devindrown commented 6 years ago

After the upgrade to v1.10.5 the issue appears to be fixed. I have some barcodes with very few reads (<5).

Thanks very much for the improvement!