An inverter that would rotate each stem by 180 degrees. (Swapping of the 5’ and 3’ stem sequences without change.)
During solution generation I employ heuristics to explore the solution space, and perform any necessary repairs on the result. An operation like flipping all the pairs is easy to perform manually, but stem inversion is more time consuming and prone to errors.
Inspiration comes from DNA inversion when a segment of DNA is cleaved, rotates, and is repaired in the opposite orientation.
Inversion is an involution, so performing it twice should return the WT. Inversion of a palindromic stem, like stems 1 and 14, doesn’t produce a change. A single pair, like at 4, is just a flip.
For implementation, it may help to scan from base 1 to the end and only trigger inversion when a base is paired to a higher number base (to avoid operating on the same stem twice). Then initiate a scan that looks at both strands, counting up on one and down on the other (to detect bulges, like at 56), and perform the inversion on a separate copy of the sequence when any unpaired base is detected. Then resume the primary scan at a position that is increased by the length of the stem just inverted. And of course set the sequence to the inverted one at the end.
Thanks for reading.