igvteam / igv-reports

Python application to generate self-contained pages embedding IGV visualizations, with no dependency on original input files.
MIT License
347 stars 51 forks source link

AttributeError: 'pysam.libcbcf.TabixIterator' object has no attribute 'append' #76

Closed lindenb closed 9 months ago

lindenb commented 1 year ago

Hi,

I'm sure I'm doing something wrong but I cannot find the source of my error. igv-reports used to work with simple variants but now it fails for BEDPE.

version:

igv-reports               1.7.0                    pypi_0    pypi

This is my command:

create_report /path/work/5e/01e8bdd63bfe616f2b874350506418/OUT/00013.bedpe  \
/path/to/hs37d5_all_chr.fasta  \
 --ideogram "/path/work/00/7828d9e3ffbc5df2b0533346431846/hg19.cytoBandIdeo.txt"  \
--flanking 250  \
--tracks /path/work/jeter.vcf.gz /path/to/file1.cram /path/to/file2.cram /path/to/file3.cram /path/to/file4.cram /path/work/f4/a337a2930ad0f83b3074666080e898/hg19.refGene.txt.gz         --output TMP/output.html

And this is my error:

Traceback (most recent call last):
  File "/CONDAS/users/lindenbaum-p/IGVREPORTS/bin/create_report", line 8, in <module>
    sys.exit(main())
  File "/CONDAS/users/lindenbaum-p/IGVREPORTS/lib/python3.7/site-packages/igv_reports/report.py", line 346, in main
    create_report(args)
  File "/CONDAS/users/lindenbaum-p/IGVREPORTS/lib/python3.7/site-packages/igv_reports/report.py", line 210, in create_report
    data = reader.slice(region, region2)
  File "/CONDAS/users/lindenbaum-p/IGVREPORTS/lib/python3.7/site-packages/igv_reports/vcf.py", line 42, in slice
    records.append(rec)
AttributeError: 'pysam.libcbcf.TabixIterator' object has no attribute 'append'

I'm not a python guy but it looks like the first iterator should be converted to an array before calling append?

lindenb commented 1 year ago

it looks like the problem is fixed by adding list( to

            records = list(self.fetch(self.get_chrname(region['chr']), region['start'], region['end']))
jrobinso commented 1 year ago

@lindenb Apologies for not responding sooner. I rotate through all the IGV projects and just missed this issue earlier. You are correct, but the solution is to return a list from "fetch". There are 2 cases handled there, vcf with and without index. I tested on non-indexed VCFs and missed this case. I will push a fix soon and do a point release.