Last active
April 4, 2022 14:09
-
-
Save hemahecodes/4a44bad69b42bfff8dbbb9faa26b7fd4 to your computer and use it in GitHub Desktop.
Merging fragment and core using RDKit for FragPELE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rdkit.Chem import rdchem | |
from rdkit import Chem | |
# Import molecules | |
core = Chem.MolFromPDBFile('../FFF/core.pdb') | |
fragment = Chem.MolFromPDBFile('../FFF/fragment.pdb') | |
# Merge both molecules | |
combo = Chem.CombineMols(core,fragment) | |
# Convert merged molecule to RWmol si we can add a bond between the two molecules (now they're separated) | |
mw = Chem.RWMol(combo) | |
mw.AddBond(11,5) # In this case, 11 and 5 are the atom idx from the rdkit mw molecule. | |
# Convert RWMol to SMILES | |
Chem.MolToSmiles(mw) | |
# Sanitize to fix connectivity | |
Chem.SanitizeMol(mw) | |
smiles = Chem.MolToSmiles(mw) | |
# Convert back to mol so we can save into PDB | |
m = Chem.MolFromSmiles(smiles) | |
# Save merged molecule into a PDB file. | |
Chem.MolToPDBFile(m,'m.pdb') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment