Created
August 31, 2018 07:51
-
-
Save ptosco/f499c7a8ced9c38067d36565ebd693f4 to your computer and use it in GitHub Desktop.
PDBAtomResidueInfo
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from rdkit import Chem\n", | |
"from rdkit.Chem import rdDistGeom\n", | |
"from rdkit.Chem.Draw import IPythonConsole" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"mol = Chem.MolFromSmiles('c1ccccn1')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"rdDistGeom.EmbedMolecule(mol)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"elem_count = {}\n", | |
"for a in mol.GetAtoms():\n", | |
" n = elem_count.get(a.GetAtomicNum(), 0)\n", | |
" n += 1\n", | |
" elem_count[a.GetAtomicNum()] = n\n", | |
" n = min(n, 99)\n", | |
" mi = Chem.AtomPDBResidueInfo()\n", | |
" mi.SetResidueName('MOL')\n", | |
" mi.SetResidueNumber(1)\n", | |
" atom_name = '{0:>2s}{1:<2d}'.format(a.GetSymbol(), n)\n", | |
" mi.SetIsHeteroAtom(True)\n", | |
" mi.SetName(atom_name)\n", | |
" mi.SetOccupancy(0.0)\n", | |
" mi.SetTempFactor(0.0)\n", | |
" a.SetMonomerInfo(mi)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"HETATM 1 C1 MOL 1 -1.011 0.850 -0.017 0.00 0.00 C \n", | |
"HETATM 2 C2 MOL 1 0.159 1.321 -0.598 0.00 0.00 C \n", | |
"HETATM 3 C3 MOL 1 1.251 0.462 -0.564 0.00 0.00 C \n", | |
"HETATM 4 C4 MOL 1 1.052 -0.805 -0.026 0.00 0.00 C \n", | |
"HETATM 5 C5 MOL 1 -0.213 -1.342 -0.195 0.00 0.00 C \n", | |
"HETATM 6 N1 MOL 1 -1.238 -0.486 0.039 0.00 0.00 N \n", | |
"CONECT 1 2 2 6\n", | |
"CONECT 2 3\n", | |
"CONECT 3 4 4\n", | |
"CONECT 4 5\n", | |
"CONECT 5 6 6\n", | |
"END\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"print(Chem.MolToPDBBlock(mol))" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment