pdb2sql icon indicating copy to clipboard operation
pdb2sql copied to clipboard

compute_lrmsd_pdb2sql works only if there is no missing backbone atom

Open FarzanehParizi opened this issue 1 year ago • 9 comments

Describe the bug If a backbone atom is missing in the Ligand part of one of the two PDBs, compute_lrmsd_pdb2sql does not report it and leads to an error

Environment:

  • OS system: Ubuntu
  • Branch commit ID: fix_lrmsd

To Reproduce

  1. Input these two PDBs:

BL00190001_decoy.txt BL00190001_ref.txt

sim = StructureSimilarity(decoy_path, ref_path) lrmsd = sim.compute_lrmsd_pdb2sql(exportpath=None, method='svd')

Expected Results calculates the LRMSD value even if one (or more) of the backbone atoms is missing or prints a proper error message to report the mismatched backbone atom(s)

Actual Results or Error Info

624         # compute the RMSD
625         lrmsd = self.get_rmsd(xyz_decoy_short, xyz_ref_short)
626 
627         # export the pdb for verifiactions

             ..../pdb2sql/pdb2sql/StructureSimilarity.py in get_rmsd(P, Q)
1280         """
1281         n = len(P)
1282         return round(np.sqrt(1. / n * np.sum((P - Q)**2)), 3)

Additional Context The compute_lrmsd_fast does not have this problem and prints the backbone LRMSD value

FarzanehParizi avatar Sep 30 '22 10:09 FarzanehParizi

Hey @FarzanehParizi thanks for testing the code. Indeed if the residue were matching but not the atoms in each residues the code was failing. I've fixed that and tested the code on the two pdbs you linked and it seems to be working. Could you double check ?

NicoRenaud avatar Oct 03 '22 12:10 NicoRenaud

Code in #82

NicoRenaud avatar Oct 03 '22 12:10 NicoRenaud

Thanks @NicoRenaud for the check . With this new fix this new error message is then printed:

rmsd = sim.compute_lrmsd_pdb2sql(exportpath=None, method='svd') File "..../pdb2sql/pdb2sql/StructureSimilarity.py", line 597, in compute_lrmsd_pdb2sql if self.check_residues() is False: File "..../pdb2sql/StructureSimilarity.py", line 100, in check_residues raise ValueError( ValueError: Atoms not identical in ref and decoy. Set enforce_residue_matching=False to bypass this error.

But the residue numbering is identical in two PDBs, only one PDB has two extra atoms for one of the residues.

it only works if setting enforce_residue_matching to False, and then prints the Warning message:

.../pdb2sql/StructureSimilarity.py:103: UserWarning: Atoms not identical in ref and decoy. warnings.warn('Atoms not identical in ref and decoy.')

FarzanehParizi avatar Oct 03 '22 16:10 FarzanehParizi

Yes that would be the expected behavior no ? We can refine the error message so that the exact atom/residue is printed as well if you think that's better

NicoRenaud avatar Oct 03 '22 16:10 NicoRenaud

I am puzzled, should not pdbsql ignore missing residues/atoms? So if there is a missing atom in one PDB ignore that also for the other PDB? Maybe I am wrong in this case. @LilySnow what is your opinion?

FarzanehParizi avatar Oct 04 '22 15:10 FarzanehParizi

@FarzanehParizi I think that's what happening here. There is a step where we extract the common atoms of both PDB and use only those to compute the rmsd

NicoRenaud avatar Oct 04 '22 15:10 NicoRenaud

So then it should give an RMSD value for this case, not an error. Even if I use only 'CA' LRMSD, it still leads to error (the difference in two PDBs is only one of them has a residue which has two extra atoms: O and OXT ... not "CA")

FarzanehParizi avatar Oct 04 '22 15:10 FarzanehParizi

I've changed the code so that we use the filter specified when calling compute_lrmsd (e.g. name=['CA']) when checking if the residues are matching. Let me know if that works out for you. I think we should refactor the StructureSimilarity cause it is now a big mess. We should probably sit down for a bit and define the requirement and API and rewrite it from scratch

NicoRenaud avatar Oct 04 '22 15:10 NicoRenaud

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Nov 04 '22 04:11 github-actions[bot]