Skip to content

Instantly share code, notes, and snippets.

@goraj
Created March 31, 2022 14:38
Show Gist options
  • Save goraj/dcea23b6f1b84cb774c240f4586bf639 to your computer and use it in GitHub Desktop.
Save goraj/dcea23b6f1b84cb774c240f4586bf639 to your computer and use it in GitHub Desktop.
openeye_bug.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "f6cbd1dd-d209-4682-9c0e-e9f14ae3a154",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"makecircular uses fp type: tb.GetFPType()=104\n",
"makecircular uses fp type: tb.GetFPType()=104\n",
"0.6721311211585999\n",
"makefp uses fp type: tb.GetFPType()=104\n",
"makefp uses fp type: tb.GetFPType()=104\n",
"0.641791045665741\n"
]
},
{
"ename": "AssertionError",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 65>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 62\u001b[0m makefp_similarity \u001b[38;5;241m=\u001b[39m OETanimoto(fpa, fpb)\n\u001b[1;32m 63\u001b[0m \u001b[38;5;28mprint\u001b[39m(makefp_similarity)\n\u001b[0;32m---> 65\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m makefp_similarity \u001b[38;5;241m==\u001b[39m makecircular_similarity\n",
"\u001b[0;31mAssertionError\u001b[0m: "
]
}
],
"source": [
"import os\n",
"import random\n",
"os.environ[\"OE_LICENSE\"] = \"/home/ec2-user/oe_license.txt\"\n",
"\n",
"from openeye.oechem import (\n",
" OEGraphMol,\n",
" OESmilesToMol,\n",
")\n",
"from openeye.oegraphsim import (\n",
" OEMakeCircularFP,\n",
" OEFPBondType_DefaultCircularBond,\n",
" OEFPAtomType_DefaultCircularAtom,\n",
" OEMakeFP,\n",
" OEFingerPrint,\n",
" OEFingerPrintType,\n",
" OETanimoto,\n",
" OEFPTypeParams\n",
")\n",
"\n",
"\n",
"def makecircular(mol):\n",
" fp = OEFingerPrint()\n",
" numbits = 512\n",
" minradius = 0\n",
" maxradius = 5\n",
" atype = OEFPAtomType_DefaultCircularAtom\n",
" btype = OEFPBondType_DefaultCircularBond\n",
" \n",
" OEMakeCircularFP(\n",
" fp, mol, \n",
" numbits, minradius, maxradius, atype, btype\n",
" )\n",
" tb = fp.GetFPTypeBase()\n",
" \n",
" print(f\"makecircular uses fp type: tb.GetFPType()={tb.GetFPType()}\")\n",
" return fp\n",
"\n",
"def makefp(mol):\n",
" fp = OEFingerPrint()\n",
" fptype = OEFPTypeParams('Circular,ver=2.0.0,size=512,radius=0-5,atype=AtmNum|Arom|Chiral|FCharge|HCount|EqHalo,btype=Order')\n",
" OEMakeFP(fp, mol, fptype.GetFPType())\n",
" tb = fp.GetFPTypeBase()\n",
" print(f\"makefp uses fp type: tb.GetFPType()={tb.GetFPType()}\")\n",
" return fp\n",
"\n",
"\n",
"def makemol(smiles):\n",
" mol = OEGraphMol()\n",
" OESmilesToMol(mol, smiles)\n",
" return mol\n",
"\n",
"\n",
"fpa = makecircular(makemol('CCOCCCCc1ccc(C)cc1CNC'))\n",
"fpb = makecircular(makemol('CCOCCCc1ccc(C)cc1CNC'))\n",
"\n",
"makecircular_similarity = OETanimoto(fpa, fpb)\n",
"print(makecircular_similarity)\n",
"\n",
"fpa = makefp(makemol('CCOCCCCc1ccc(C)cc1CNC'))\n",
"fpb = makefp(makemol('CCOCCCc1ccc(C)cc1CNC'))\n",
"\n",
"makefp_similarity = OETanimoto(fpa, fpb)\n",
"print(makefp_similarity)\n",
"\n",
"assert makefp_similarity == makecircular_similarity"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e4f0d30d-ec0f-4443-aa09-fbac0ca91ddf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2021.2.0\n"
]
}
],
"source": [
"import openeye\n",
"print(openeye.__version__)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db832aef-40fc-4590-9b52-9dffac90e5ac",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment