Closed HubLot closed 7 years ago
Nice work @HubLot
shit I forgot the CHANGELOG :(
@pierrepo, can you commit directly to the master (bad I know) with only the modification in the CHANGELOG file (like 'Handle production of NaN during angle calculations') ?
@HubLot already done + reformat comments
great, thank you!
Numpy can produce NaN during dihedral calculations (in
get_dihedral
function). This can occurs when we try to normalize the vectors ("Divide by Zero"). It usually means there is issues with some residus coordinates (for example, 2 residus superposed). The problem is the dictionary of phi/psi angle is still returned and the assignation is still made despite the NaN in the angle. This produces incorrect assignations which could be difficult to spot on a analysis of many PDBs.This PR fix those issues by :
RuntimeWarning
produced by numpy in a properFloatingPointException
exception (throughnumpy.errstate(invalid='raise')
). This change is made inget_phi_psi_angles()
function before the main loop on the residus. Hence, it's only done once and do not change the speed of the calculations (it's even a little bit faster but not sure it's significative).get_phi_psi_angles()
function in order to keep the traceback and provide a proper exiting tool for the function (helpful for module users).PBassign
, warn the user about the issue and don't write the assignation.