Skip to content

igv_reports fails on chrM #138

@zmaroti

Description

@zmaroti

At fasta.py line 49:

start = region["start"] - 1 if region["start"] is not None else None
start will result as -1 for chrM variants, then the exception is caught at line 53:

            try:
                seq = self.fasta.fetch(chr, start, end)

Traceback (most recent call last):
File "/home/gdl/.local/bin/create_report", line 8, in
sys.exit(main())
File "/home/gdl/.local/lib/python3.6/site-packages/igv_reports/report.py", line 630, in main
create_report(args)
File "/home/gdl/.local/lib/python3.6/site-packages/igv_reports/report.py", line 133, in create_report
session_dict = json.dumps(create_session_dict(args, table, trackjson))
File "/home/gdl/.local/lib/python3.6/site-packages/igv_reports/report.py", line 288, in create_session_dict
data = sequence_reader.slice(regionSeq)
File "/home/gdl/.local/lib/python3.6/site-packages/igv_reports/fasta.py", line 56, in slice
seq = self.fasta.fetch(chr, start, end)
File "pysam/libcfaidx.pyx", line 288, in pysam.libcfaidx.FastaFile.fetch
File "pysam/libcutils.pyx", line 259, in pysam.libcutils.parse_region
ValueError: start out of range (-1)

I am not sure how it can happen as at report.py start is max(1, start-500)

            regionSeq = (
                {"chr": region["chr"], "start": max(1, region["start"] - 500), "end": region["end"] + 500}
                if region.get("start") is not None
                else region
            )
            data = sequence_reader.slice(regionSeq)

However with a quick hack at fasta.py

         if start < 0:
             start = 0

The error goes away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions