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

Circular DNA feature wrap issue #29

Open mmcguffi opened 4 years ago

mmcguffi commented 4 years ago

image

Hello, I have found that when I try to render a circular graphic record that has a feature that spans the "origin", it is instead incorrectly rendered as looping around the entire DNA segment. I see that this does not happen in your bioRxiv preprint, so maybe I am missing something obvious?

This is the raw text from the .gbk for the incorrect feature in question in the picture above:

enhancer        join(7368..7381,1..366)
                     /label="CMV enhancer (2)"
                     /identity="100.0"
                     /match length="100.0"
                     /Other:="enhancer"
Zulko commented 4 years ago

I think we never had an origin-spanning feature plotted circularly before (in the preprint figure, there are no origin-spanning annotations but the Graphic Record itself is rotated with graphic_record.rotate() which is why some features appear to be cross-origin).

That seems fixable (by amending the way the angles of the arrow are computed here) but I am under the water this week and possibly the next, so if you find a fix, I'll happily merge it.

mmcguffi commented 4 years ago

I took a look at the CircularGraphicRecord.py, but I believe the coordinates that are passed to CircularGraphicRecord from GraphicRecord are already incorrect, thus the error lies within GraphicRecord (GR sends CGR [0, len(sequence)] instead of [1034, 6], or something). These are then translated into [90.0 -270.0] in polar coordinates.

I see you have this function already: https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/blob/12ddaa56738e104094b1f2cc27e204d7cc333c42/dna_features_viewer/GraphicRecord/GraphicRecord.py#L166

There is a lot to follow in this code (hence I haven't cracked this yet), but I don't think this function is implemented?