volkamerlab / opencadd

A Python library for structural cheminformatics
https://opencadd.readthedocs.io
MIT License
91 stars 18 forks source link

Superposition align function fails when no models available in MDA Universe #147

Closed noahharrison64 closed 2 years ago

noahharrison64 commented 2 years ago

Have been trying to use the align function to align a series of MDA Universes. These universes don't contain more than one model. In the align function models are attempted to be accessed, but if they don't exist the function produces an error.

I'd suggest checking to see if they exist prior to trying to assign to a variable. For now I've just commented out this line and it appears to be working no problem.

dominiquesydow commented 2 years ago

Hi @noahharrison64, thanks a lot for reporting this issue! Could you please post your PDB ID that has no MDA universe model in case you encountered this problem with public data?


Note to myself: We could move

reference = reference.models[0]
for mobile in mobiles:
    mobile = mobile.models[0]

before the if-else loop (would reduce redundancy) and add here already the checks for existing models; show a warning if structures without models exist and drop them.

noahharrison64 commented 2 years ago

Hi @dominiquesydow

This issue arose while using custom PDBs rather than accessed directly from RCSB. Is there any reason to drop structures without models? The align function worked when I used these structures without models associated (post commenting out) so might be worth just checking if they exist and if not then using the structure directly

dominiquesydow commented 2 years ago

Thanks, @noahharrison64, very good point, no need to drop them after looking into the model "issue" a bit more.

I found an example for structures without models and suggest the following workaround to account for structures with and without MDA models: PR https://github.com/volkamerlab/opencadd/pull/149

If you can make the time, would you mind checking if this workaround works with your custom PDBs?

noahharrison64 commented 2 years ago

Hey @dominiquesydow Had a go with the update api.py file and it appears to be working no problem.

Thanks for fixing, Noah

dominiquesydow commented 2 years ago

Great news, thanks! I have merged the changes now to the master branch. Thanks again, @noahharrison64, for bringing this issue to our attention.