Created
May 13, 2020 13:22
-
-
Save bdrown/9686c3201826a5ccd50f074f6b017eb9 to your computer and use it in GitHub Desktop.
Short python script for guessing the 3D structure of a molecule from a smiles string and writing out to mol file
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
# smiles_to_mol.py | |
__doc__ = """Guesses the initial geometry of a molecule based on SMILES string | |
""" | |
############################### | |
from rdkit import Chem | |
from rdkit.Chem import AllChem | |
import sys | |
############################### | |
# Get parameters | |
smiles = sys.argv[1] | |
mol_out = sys.argv[2] | |
m = Chem.MolFromSmiles(smiles) | |
m2 = Chem.AddHs(m) | |
# Generate initial guess | |
AllChem.EmbedMolecule(m2,AllChem.ETKDG()) | |
AllChem.MMFFOptimizeMolecule(m2) | |
# Write mol file | |
print(Chem.MolToMolBlock(m2),file=open(mol_out,'w')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment