yannponty/VARNA

Wrongly identify external basepair in flip when two branches are adjacent

Opened this issue · 3 comments

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

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.

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?

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