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

Add keyword argument rename_atoms to MoleculePreparation.prepare and make option avail in CLI script #255

Merged
merged 9 commits into from
Dec 4, 2024

Conversation

rwxayheee
Copy link
Contributor

This PR enables unique atom names in MoleculeSetup after MoleculePreparation with the relevant option. The main purpose is to address request #47. Option --rename_atoms is added to the CLI script in an analog to In prepare_ligand4.py; there's a -w option that renames ligand atoms, and each newname is the original name of the atom plus its (1-based) uniqIndex.

Here're more details:

  • Add keyword argument rename_atoms to MoleculePreparation.prepare
    The default is False, and it's just a keyword argument in function prepare. Because I didn't make it an attribute of MoleculePreparation, it can't be from the config (but we could, if the other way is preferred?). Python usage:
from meeko import MoleculePreparation
preparator = MoleculePreparation()
molsetups = preparator(mol, rename_atoms = True)

is equivalent to

molsetups = preparator.prepare(mol, rename_atoms = True)
  • Make option available in mk_prepare_ligand.py
    mk_prepare_ligand.py has a new option:
  --rename_atoms        rename atoms: the new name will be the original name and its (1-based) index in
                        MoleculeSetup
  • Format of new names
    The new names are a combination of original name plus the atom's (1-based) index in MoleculeSetup at the last moment of molecule preparation. For example: C might become C14 and OH might become OH15. The index should be generally consistent with the order of atoms in the input molecule, but not Smiles or the order of output PDBQT file. And glue atoms will have indices too. When the name is longer than 4 characters, the original name will remain unchanged and a warning message shall be seen:
Warning: Attempted to rename atom with original name XXX to XXX10. 
But the new name is too long (> 4 characters). The original name will be kept. 
  • Assign/Import atom names
    It's always possible to assign atom names in a rdkit molecule before MoleculePreparation. To import atom names, possible source includes: CIF files, MOL2/MOL files, PDB files, but PDB files are currently the only ones where atom names are parsed natively by RDKit.

This started from the release branch, so it includes some other commits that have been merged into release but not present in develop. It also includes another small fix (14ec360) just for #233, although noncritical to the rest of this PR.

@diogomart Please let me know what you think! Thanks for your time and advice in advance

@rwxayheee rwxayheee requested a review from diogomart November 27, 2024 23:47
@diogomart diogomart changed the base branch from develop to andg_coords December 4, 2024 00:12
@diogomart diogomart changed the base branch from andg_coords to develop December 4, 2024 00:13
Copy link
Contributor

@diogomart diogomart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rwxayheee
Copy link
Contributor Author

Thanks! Merging to develop

@rwxayheee rwxayheee merged commit b41338c into forlilab:develop Dec 4, 2024
1 check passed
@rwxayheee rwxayheee deleted the molsetup_python_usage branch December 4, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants