Edinburgh-Genome-Foundry / DnaFeaturesViewer

:eye: Python library to plot DNA sequence features (e.g. from Genbank files)
https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/
MIT License
584 stars 90 forks source link

BiopythonTranslator: SeqFeatures with location_operator='join' get wrong position #63

Open MrTomRod opened 2 years ago

MrTomRod commented 2 years ago

Hello

Thanks for your work, I implemented DnaFeaturesViewer in my software (click on compare gene loci)!

I found a small bug: sometimes, a gene spans the scaffold. Happens rarely with circular assemblies annotated with PGAP. In this case, BiopythonTranslator gives the gene a start position at the beginning of the scaffold, and an end position at the end of the scaffold, meaning the gene spans the entire scaffold.

Example: image

Use this genbank file to reproduce the issue.

I managed to fix it by changing the translate_feature function:

location = feature.location if feature.location_operator != 'join' else feature.location.parts[0]

return GraphicFeature(
    start=location.start,
    end=location.end,
    strand=location.strand,
    **properties
)

Then, I get the expected result: image