{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Getting list of molecule IDs...\n", "Done!\n" ] } ], "source": [ "# Make lists of the guest smiles strings and the molecule identifiers \n", "file = 'GDCC_hosts_guests_smiles.txt'\n", "\n", "file = open(file, 'r')\n", "text = file.readlines()\n", "file.close()\n", "print(\"Getting list of molecule IDs...\") \n", "MoleculeIDs = [] #SAMPL6 Molecule ID \n", "smiles = [] #isomeric SMILES\n", "#Loop over lines and parse\n", "for line in text:\n", " tmp = line.split(';') #Split into columns\n", " MoleculeID = tmp[1].strip() #mol ID\n", " smi = tmp[0] #smiles string\n", " try:\n", " MoleculeIDs.append(MoleculeID)\n", " smiles.append(smi)\n", " except:\n", " print(\"Error storing line: %s\" % line)\n", "print(\"Done!\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from openeye.oechem import *\n", "from openeye.oeomega import * # conformer generation\n", "\n", "for idx in range( len( smiles ) ):\n", " #initialize omega, this is a conformation generator\n", " omega = OEOmega()\n", " #set the maximum conformer generated to 1\n", " omega.SetMaxConfs(1) \n", " omega.SetIncludeInput(False)\n", " omega.SetStrictAtomTypes(False) #Leniency is assigning atom types\n", " omega.SetStrictStereo(True) #Don't generate conformers if stereochemistry not provided\n", " \n", " # Generate new OEMol and parse SMILES\n", " mol = OEMol()\n", " OEParseSmiles( mol, smiles[idx])\n", " # Generate one conformer\n", " status = omega(mol)\n", " if not status:\n", " print(\"Error generating conformers for %s, %s.\" % (smiles[idx], MoleculeIDs[idx]))\n", "\n", " # Write out PDB of molecule\n", " ofile = oemolostream('%s.pdb'%(MoleculeIDs[idx]))\n", " OEWriteMolecule(ofile, mol)\n", " ofile.close()\n", "\n", " # Write out MOL2 of molecule\n", " ofile = oemolostream('%s.mol2'%(MoleculeIDs[idx]))\n", " OEWriteMolecule(ofile, mol)\n", " ofile.close()\n", " \n", " # Write out SDF of molecule\n", " ofile = oemolostream('%s.sdf'%(MoleculeIDs[idx]))\n", " OEWriteMolecule(ofile, mol)\n", " ofile.close()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Host done: OA\n", "Host done: exoOA\n" ] } ], "source": [ "hosts = ['OA', 'exoOA']\n", "for idx in range( len( hosts ) ):\n", " inputfile = oemolistream('%s.pdb'%(hosts[idx]) )\n", " mol = OEMol()\n", " OEReadMolecule( inputfile, mol )\n", " inputfile.close()\n", "\n", " # Write to a SDF file\n", " ofile = oemolostream( '%s.sdf'%(hosts[idx]) ) \n", " OEWriteMolecule( ofile, mol)\n", " ofile.close()\n", "\n", " # Write to a PDB file\n", " ofile = oemolostream( '%s.mol2'%(hosts[idx]) ) \n", " OEWriteMolecule( ofile, mol)\n", " ofile.close()\n", " print(\"Host done:\", hosts[idx])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:drugcomp]", "language": "python", "name": "conda-env-drugcomp-py" }, "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.7" } }, "nbformat": 4, "nbformat_minor": 2 }