rlabduke / reduce

Reduce - tool for adding and correcting hydrogens in PDB files
Other
120 stars 36 forks source link

Avoid invalidated records when scoring methyl rotation angles #11

Closed sbstnk closed 4 years ago

sbstnk commented 5 years ago

Invalidated records do not have a corresponding entry in the pre-built list of bonded atoms "_bnded" (see "RotMethyl::finalize"). When trying to score a rotation angle in "RotMethyl::scoreThisAngle" the loop iterates over all records, including invalidated ones and increments the counter "i" which is used as an index to access "_bnded". This means when there is an invalidated record, this access will be out of bounds resulting in either a crash or incorrect results. Such a crash can be observed with 1QIR. The solution to this issue is to skip over invalidated records in "scoreThisAngle". This does not affect the result of the function because the called "atomScore" function exits early with a score of 0 in case of invalid records anyway.

Fixes: https://github.com/rlabduke/reduce/issues/7

russell-taylor commented 4 years ago

@sbstnk Thank you for the pull request. Sorry it took so long to merge.