I noticed that the NMRSTAR bundle raises an exception when any distance constraint in an NMR-STAR file does not contain "float-parseable" values for both the minimum and maximum distance. For example, PDB entry 7SA5's restraint file contains only one distance for each constraint and uses '.' for the missing value, which means that one restraint is parsed as e.g. ['A', '49', 'GLN', 'H', 'A', '49', 'GLN', 'HB2', '.', '2.81']. NMRSTAR tries to convert the '.' into a float for the restraint's minimum distance and immediately stops when the conversion raises an error. I believe it would be better not to directly raise an exception here, but to draw as many constraints as possible and just provide the user with warnings regarding invalid distances.
This patch catches each raised exception, logs it as a warning (automatically collated with any other output from the module) and falls back to a default value that ensures the invalid distance is never considered violated (-1.0 for minimum distance, float("inf") for maximum distance). This means that each constraint with at least one valid distance is still drawn and that its representation can still be altered if the actual distance between its two atoms is longer than its (valid) maximum distance. However, if both the minimum and maximum distance of a constraint are invalid, the restraint is ignored entirely.
Hi,
I noticed that the NMRSTAR bundle raises an exception when any distance constraint in an NMR-STAR file does not contain "
float
-parseable" values for both the minimum and maximum distance. For example, PDB entry 7SA5's restraint file contains only one distance for each constraint and uses'.'
for the missing value, which means that one restraint is parsed as e.g.['A', '49', 'GLN', 'H', 'A', '49', 'GLN', 'HB2', '.', '2.81']
. NMRSTAR tries to convert the'.'
into afloat
for the restraint's minimum distance and immediately stops when the conversion raises an error. I believe it would be better not to directly raise an exception here, but to draw as many constraints as possible and just provide the user with warnings regarding invalid distances.This patch catches each raised exception, logs it as a warning (automatically collated with any other output from the module) and falls back to a default value that ensures the invalid distance is never considered violated (
-1.0
for minimum distance,float("inf")
for maximum distance). This means that each constraint with at least one valid distance is still drawn and that its representation can still be altered if the actual distance between its two atoms is longer than its (valid) maximum distance. However, if both the minimum and maximum distance of a constraint are invalid, the restraint is ignored entirely.