yannponty / VARNA

Visualization Application for RNA
GNU General Public License v3.0
7 stars 7 forks source link

Wrongly identify external basepair in flip when two branches are adjacent #6

Open anthonyhtyao opened 1 year ago

anthonyhtyao commented 1 year ago

Consider secondary structure "...((...))((...))...", flipping base 12 via -flip option in cmd is supposed to flip the second branch, however, the first one is flipped.

This only happens when two branches are adjacent

credit to Denis Skibinski

anthonyhtyao commented 1 year ago

I think I found the problem, in RNA::getExteriorHelix, we first find the index of 5' base of the current helix, denoted by a. Then, in the following while loop, we call ‎RNA::getHelixInterval with a-1, which brings to the other branch when two are adjacent.

anthonyhtyao commented 1 year ago

This brings my second question. I believe the intention of option -flip(index) is to flip the entire branch, starting from the exterior loop, that the base index belongs to. Thus, the while loop in RNA:getExteriorHelix.

However, RNA::getHelixInterval returns Point(0,0) if the given is an unpaired base. So the while loop stops immediately, which means the option -flip only flips the helix of the base index w.r.t the largest basepair in that helix.

@yannponty is the origin intention of the option -flip to flip the entire branch?

anthonyhtyao commented 7 months ago

The same bug also appears when flipping the first branch which is located at the first position. One way to fix is to comment the code that calls getHelixInterval in while loop