Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 128,
- "metadata": {},
- "outputs": [],
- "source": [
- "from rdkit import Chem"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Xe can be handled as we want if imported from smiles"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 129,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'[Xe]c1ccccc1'"
- ]
- },
- "execution_count": 129,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "x = Chem.MolFromSmiles(\"[Xe]c1ccccc1\")\n",
- "Chem.MolToSmiles(x)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Add Xe atom to benzene"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 130,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "6"
- ]
- },
- "execution_count": 130,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "m = Chem.MolFromSmiles(\"c1ccccc1\")\n",
- "mw = Chem.RWMol(m)\n",
- "mw.GetNumAtoms()\n",
- "xe = Chem.Atom(54)\n",
- "idx = mw.AddAtom(xe)\n",
- "idx"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Create the bond"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 131,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "1"
- ]
- },
- "execution_count": 131,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "mw.AddBond(0,6,Chem.BondType.SINGLE)\n",
- "Chem.SanitizeMol(mw)\n",
- "atom = mw.GetAtomWithIdx(idx)\n",
- "atom.GetExplicitValence()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Why the extra H when we write to smiles?"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 132,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'[XeH]c1ccccc1'"
- ]
- },
- "execution_count": 132,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "Chem.MolToSmiles(mw)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "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.7.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement