TeselaGen / tg-oss

Teselagen Open Source modules
https://teselagen.github.io/tg-oss/
MIT License
37 stars 18 forks source link

OVE - feature strand not correctly displayed in SimpleCircularOrLinearView #70

Closed manulera closed 2 months ago

manulera commented 2 months ago

Hi @tnrich, I noticed that the SimpleCircularOrLinearView editors always display the feature as if it was in the reverse strand, regardless of the feature.strand attribute.

You can check this in this repo

Also, I made a video of it. An app that changes the strand of the feature, and you can see the main editor changes, but not the SimpleCircularOrLinearView.

Happy to provide a fix via PR if you point me somewhere.

https://github.com/TeselaGen/tg-oss/assets/22526102/3f604f06-ce40-4b8e-bc62-e3d62325ba22

tnrich commented 2 months ago

Hi @manulera you can set forward: true, for a feature/part and have it display in the forward orientation. That should fix this for you. I'll add an example to the SimpleCircularOrLinearView demo

manulera commented 2 months ago

Hi @tnrich, thanks that makes it work for me as well.

However, why is this needed only for SimpleCircularOrLinearView? When I use createVectorEditor, setting strand in the features is enough for them to render in the right orientation. Also, when reading a file from genbank format, this forward attribute does not seem to be set either, perhaps something to do with the feature parser then?

tnrich commented 2 months ago

Hi @manulera probably because the createVectorEditor runs the sequenceData through the tidyUpSequenceData function whereas the SimpleCircularOrLinearView does not do that..? Perhaps we should investigate running the sequenceData passed to the SimpleCircularOrLinearView thru the same tidyUpSequenceData function?

manulera commented 2 months ago

Hi @tnrich, yes that worked, thank you! Do you think tidyUpSequenceData should be called by convertToTeselaJson by default before returning the result?

manulera commented 2 months ago

Also, now the sequences look so much better! Is there some docs on the difference between the input and output?

Before

Screenshot 2024-05-24 at 11 42 47

After

Screenshot 2024-05-24 at 11 42 43
tnrich commented 2 months ago

@manulera where is the convertToTeselaJson function you're asking about?

I'm not sold on adding the tidyUpSequenceData step directly to SimpleCircularOrLinear view since I don't want that conversion to be run more than is necessary.

manulera commented 1 month ago

Hi @tnrich, I have made a minimal example that you can test in https://ove-playground.netlify.app/

Essentially, using the bottoms at the top, you can:

All this is in this very short component.

As you can see, when reading a sequence using genbankToJson:

Should I be using another function that runs this post-processing instead of genbankToJson?

tnrich commented 1 month ago

@manulera thanks for catching this. I've updated the genbankToJson to output the .forward property as well. Let me know if the latest release fixes this for you.

manulera commented 1 month ago

Hi @tnrich I updated to the last version of bio-parsers, and as you can see the problem persists (I still have to call tidyUpSequenceData) when using SimpleCircularOrLinearView.

See the demo app here: https://ove-playground.netlify.app/

Also, as mentioned above the features are still displayed differently in the UI when you call or not call tidyUp

tnrich commented 1 month ago

@manulera seems to work for me off the master branch - https://github.com/TeselaGen/tg-oss/compare/tnwTestEdComparison

image
manulera commented 1 month ago

I see, that works for me as well, I was just changing strand in my code when the button was clicked, and I had to change forward as well. I have changed that in the playground example and now it reverts the feature in the display. Sorry about that.

However, the displayed sequence still looks much better if using tidyUpSequenceData in the SimpleCircularOrLinearView, but in the main editor it always looks well. Should this be the case?

With tidyUp

Screenshot 2024-06-05 at 20 54 24 Screenshot 2024-06-05 at 20 54 07

Without tidyUp. All features are shown in purple regardless of type in circular, and names overlap in both linear and circular

Screenshot 2024-06-05 at 20 54 20 Screenshot 2024-06-05 at 20 54 11

You can test again here: https://ove-playground.netlify.app/

tnrich commented 1 month ago

Just run tidyUpSeq yourself before passing stuff to SimpleCircLinView ?

I unfortunately don't think it is the best idea to add that fn directly to SimpleCircLinView for fear of running it more than necessary

manulera commented 1 month ago

Alright, will do that!

tnrich commented 1 month ago

Thanks! Appreciate all the work you're doing!