Off by one error in get_aa() function

Started by Tlaloc

Tlaloc Lv 1

If you try to use get_aa() to retrieve the last segment of some proteins, it gives an error.

The following code in a lua script doesn't work on the current TNT protein:

print(get_aa(get_segment_count()))

However, this does work:

print(get_aa(get_segment_count() - 1))

However, both calls works on the current Platypus Venom puzzle. It may have something to do with TNT is a design puzzle.

dimension9 Lv 1

I noticed also that the score reported by the our replacement score function, which adds the get_segment_ score() for each segment, then adds 8000 - also computes wrong on the design puzzle, returning a value a few thousand points too high. I thought it may have something to do with the fact that the ligand is a separate non-attached element, even though it has a sequential segment number… - just an observation, maybe it is helpful…?

Crashguard303 Lv 1

dimension9 and Vakobo seem to be right.
I guess, that the whole ligand is declared as only one single sidechain, but consists of more parts, so the score are calculated strangely and setting the sidechain shape of this "segment" is impossible.

Splitting the ligand into more segments would help.
This would also allow manipulating it better.

Crashguard303 Lv 1

It would be useful to have a global variable, to check if a puzzle is a ligand puzzle, so we could compensate the error and adapt scripts for this special situation.

puzzle_ligand() could give back "true" if this a ligand puzzle.

For most operations then, working not with get_segment_count() but get_segment_count()-1 could help preventing crashes.

Furthermore, a global variable, to respond if a puzzle is mutable would help.

puzzle_mutable() could answer "true" if there is minimum one segment which can be mutated.

Crashguard303 Lv 1

get_aa(get_segment_count(()), which is get_aa(248) on TNT doesn't work because this segment is the ligand.

As the ligand is no sidechain, but a more complex structure, it doesn't have a sidechain letter.

But to my opinion, the get_aa()-function should return a value even in this case to keep scripts running.
Even if the letter you get is none of the regular sidechain letters, or just nothing like "", but it should not give a "bad argument" error when executing get_aa().