Skip to content
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

Do we have method to mutate the iCode-containing residue? #280

Open
locitran opened this issue Oct 11, 2023 · 2 comments
Open

Do we have method to mutate the iCode-containing residue? #280

locitran opened this issue Oct 11, 2023 · 2 comments

Comments

@locitran
Copy link

locitran commented Oct 11, 2023

Do we have a method to mutate the iCode-containing residue?
It seems applyMutations doesn't work.

For example, how can we mutate the residue GLY-9A-chainA of pdbID 1S9V?

@peastman
Copy link
Member

This would be a useful feature to add to applyMutations(). A PR would be welcome!

If you know what residue you want to replace, it's pretty easy to do it yourself. applyMutations() is a very simple method. Here's the part that actually makes the change. It just changes the residue's name field and deletes any existing atoms that shouldn't be present.

deleteAtoms = [] # list of atoms to delete
# Find atoms that should be deleted.
for residue in residue_map.keys():
replaceWith = residue_map[residue]
residue.name = replaceWith
template = self.templates[replaceWith]
standardAtoms = set(atom.name for atom in template.topology.atoms())
for atom in residue.atoms():
if atom.element in (None, hydrogen) or atom.name not in standardAtoms:
deleteAtoms.append(atom)
# Delete atoms queued to be deleted.
modeller = app.Modeller(self.topology, self.positions)
modeller.delete(deleteAtoms)
self.topology = modeller.topology
self.positions = modeller.positions

@locitran
Copy link
Author

Thank you @peastman
I will give a try :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants