-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support reading and writing intra-residue bonds in PDBx files #567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a pretty common use case might be reading SDF files generates from some cheminformatics software (e.g., RDKit), and then wanting to have the same bond information in cif format.
I've tried reading an RDKit-generated SDF file (attached below, rename to aspirin.sdf
), saving it as PDBx (incl. bonds), then reading it again from cif, which didn't seem to keep the bond information:
import biotite.structure.io as strucio
import biotite.structure.io.pdbx as pdbx
arr = strucio.load_structure("aspirin.sdf")
print(arr.bonds.as_array().shape) # (13, 3)
f = pdbx.CIFFile()
pdbx.set_structure(f, arr, include_bonds=True)
f.write("aspirin.cif")
arr2 = strucio.load_structure("aspirin.cif", include_bonds=True)
print(arr2.bonds.as_array().shape) # (0, 3)
Am I missing something?
src/biotite/structure/bonds.pyx
Outdated
custom_bond_dict : dict (str -> dict ((str, str) -> int)), optional | ||
A dictionary of dictionaries: | ||
The inner dictionary maps tuples of two atom names | ||
to their respective bond types (represented as integer) for . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
word missing in docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, rather an entire sentence. Thanks for spotting this
I reproduced your problem. There are two issues here:
|
Did the code snippet you posted above run for you? Pulling your changes and running locally, I got an error from the final line |
Did you reinstall the package? |
This PR add support for reading/writing intra-residue bonds via the
chem_comp_bond
category in PDBx files. Files that contain this category were introduced in the PDB NextGen Archive.