in reply to recursive algorithm
Adding a little sanity checking to evalRna may help you figure out the problem:
sub evalRna { my ($l, $r) = @_; my %bonds = (GU => 1, UG => 1, AU => 2, UA => 2, CG => 3, GC => + 3); my $lu = "$bases[$l]$bases[$r]"; my $numBonds = $bonds{$lu} || die "Bad bond type '$lu' given $l, $ +r\n";
When given your sample input data you get:
Bad bond type '5C' given 0, 21
|
|---|