Skip to content

Commit

Permalink
fixing tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
ale94mleon committed Jul 30, 2022
1 parent 4646c93 commit 1a8d44c
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 233 deletions.
48 changes: 25 additions & 23 deletions docs/notebooks/how_to.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"source": [
"# Import section\n",
"from moldrug.data import ligands, boxes, receptors\n",
"from rdkit import Chem\n",
"import tempfile, os, requests,inspect, gzip, shutil, yaml, sys\n",
"from moldrug import utils\n",
"from typing import List\n",
Expand Down Expand Up @@ -104,7 +105,7 @@
"text": [
"COC(=O)C=1C=CC(=CC1)S(=O)(=O)N\n",
"{'A': {'boxcenter': [12.11, 1.84, 23.56], 'boxsize': [22.5, 22.5, 22.5]}}\n",
"/tmp/tmpnlx1gpp8 ['crem.db.gz', 'x0161.pdbqt', 'crem.db']\n"
"/tmp/tmp0n8w1rkf ['crem.db.gz', 'x0161.pdbqt', 'crem.db']\n"
]
}
],
Expand Down Expand Up @@ -148,11 +149,12 @@
"data": {
"text/plain": [
"['self',\n",
" 'mol',\n",
" 'seed_mol',\n",
" 'crem_db_path',\n",
" 'costfunc',\n",
" 'grow_crem_kwargs',\n",
" 'costfunc_kwargs']"
" 'costfunc_kwargs',\n",
" 'AddHs']"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -187,7 +189,8 @@
" type: Local\n",
" njobs: 1\n",
" pick: 1\n",
" mol: COC(=O)C=1C=CC(=CC1)S(=O)(=O)N\n",
" AddHs: False\n",
" seed_mol: COC(=O)C=1C=CC(=CC1)S(=O)(=O)N\n",
" costfunc: Cost\n",
" costfunc_kwargs:\n",
" vina_executable: vina\n",
Expand Down Expand Up @@ -224,9 +227,10 @@
" type: Local\n",
" njobs: 1\n",
" pick: 1\n",
" AddHs: False\n",
"```\n",
"\n",
"Look how this section is inside of `main` (one indentation level). `type` is the name of the class inside `moldrug.utils`; for now could be `GA` or `Local` (case insensitive). In this case we want to use the class `Local`. `njobs` and `pick` are the parameters when the class `Local` (or `GA`) is call. The rest of the parameters are just the parameters that needs `Local` for the initialization. All of them are at the same level of the previous ones. Because `costfunc_kwargs` is a dictionary; we add for its value a new indentation level:\n",
"Look how this section is inside of `main` (one indentation level). `type` is the name of the class inside `moldrug.utils`; for now could be `GA` or `Local` (case insensitive). In this case we want to use the class `Local`. `njobs`, `pick` and `AddHs` are the parameters when the class `Local` (or `GA`) is call. The rest of the parameters are just the parameters that needs `Local` for the initialization. All of them are at the same level of the previous ones. Because `costfunc_kwargs` is a dictionary; we add for its value a new indentation level:\n",
"\n",
"```yaml\n",
" costfunc_kwargs:\n",
Expand Down Expand Up @@ -271,7 +275,7 @@
" \"type\": \"Local\",\n",
" \"njobs\": 1,\n",
" \"pick\": 1,\n",
" \"mol\": lig,\n",
" \"seed_mol\": lig,\n",
" \"costfunc\": \"Cost\",\n",
" \"costfunc_kwargs\": {\n",
" \"vina_executable\": \"vina\",\n",
Expand Down Expand Up @@ -324,7 +328,7 @@
"text": [
"The main job is being executed.\n",
"Calculating cost function...\n",
"100%|█████████████████████████████████████████████| 2/2 [00:06<00:00, 3.35s/it]\n",
"100%|█████████████████████████████████████████████| 2/2 [00:06<00:00, 3.20s/it]\n",
"File local_pop.sdf was createad!\n",
"The main job finished!.\n"
]
Expand Down Expand Up @@ -499,7 +503,7 @@
"text": [
"The main job is being executed.\n",
"Calculating cost function...\n",
"100%|█████████████████████████████████████████████| 2/2 [00:05<00:00, 2.68s/it]\n",
"100%|█████████████████████████████████████████████| 2/2 [00:05<00:00, 2.76s/it]\n",
"File local_pop.sdf was createad!\n",
"The main job finished!.\n"
]
Expand Down Expand Up @@ -554,7 +558,7 @@
{
"data": {
"text/plain": [
"<moldrug.utils.Local at 0x7f389d6358b0>"
"<moldrug.utils.Local at 0x7f47ac62c940>"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -631,15 +635,13 @@
"data": {
"text/plain": [
"['/home/ale/GITLAB/moldrug/docs/notebooks',\n",
" '/home/ale/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/pythonFiles',\n",
" '/home/ale/.vscode/extensions/ms-toolsai.jupyter-2022.6.1201981810/pythonFiles/lib/python',\n",
" '/home/ale/anaconda3/envs/moldrug/lib/python39.zip',\n",
" '/home/ale/anaconda3/envs/moldrug/lib/python3.9',\n",
" '/home/ale/anaconda3/envs/moldrug/lib/python3.9/lib-dynload',\n",
" '',\n",
" '/home/ale/anaconda3/envs/moldrug/lib/python3.9/site-packages',\n",
" '/home/ale/GITLAB/moldrug',\n",
" '/tmp/tmpnlx1gpp8/custom_fitness']"
" '/tmp/tmp0n8w1rkf/custom_fitness']"
]
},
"execution_count": 14,
Expand Down Expand Up @@ -725,14 +727,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 20/20 [00:00<00:00, 1060.01it/s]"
"100%|██████████| 20/20 [00:00<00:00, 1313.31it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Initial Population: Best individual: Individual(idx = 6, smiles = CC(C)(C)OC(=O)NO, cost = 0.14332947497346815)\n"
"Initial Population: Best individual: Individual(idx = 6, smiles = CCCCCCC=CCO, cost = 0.04045062715899039)\n"
]
},
{
Expand All @@ -753,14 +755,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 20/20 [00:00<00:00, 995.33it/s]"
"100%|██████████| 20/20 [00:00<00:00, 606.98it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Generation 1: Best Individual: Individual(idx = 38, smiles = C=COCC, cost = 0.05195477634991308).\n",
"Generation 1: Best Individual: Individual(idx = 22, smiles = C#CC1(O)CCCCCCCC1, cost = 0.03751898267200682).\n",
"\n"
]
},
Expand All @@ -782,26 +784,26 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 20/20 [00:00<00:00, 377.88it/s]"
"100%|██████████| 20/20 [00:00<00:00, 798.06it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Generation 2: Best Individual: Individual(idx = 44, smiles = CCOC(=O)N(C)N=NC, cost = 0.015742754415312588).\n",
"Generation 2: Best Individual: Individual(idx = 22, smiles = C#CC1(O)CCCCCCCC1, cost = 0.03751898267200682).\n",
"\n",
"\n",
"=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n",
"\n",
"The simulation finished successfully after 2 generations with a population of 20 individuals. A total number of 60 Individuals were seen during the simulation.\n",
"Initial Individual: Individual(idx = 0, smiles = CCCC(=O)OCCN, cost = 0.8568098985747594)\n",
"Final Individual: Individual(idx = 44, smiles = CCOC(=O)N(C)N=NC, cost = 0.015742754415312588)\n",
"The cost function droped in 0.8410671441594468 units.\n",
"Initial Individual: Individual(idx = 0, smiles = CCCC(=O)OCCN, cost = 0.6813211889306405)\n",
"Final Individual: Individual(idx = 22, smiles = C#CC1(O)CCCCCCCC1, cost = 0.03751898267200682)\n",
"The cost function droped in 0.6438022062586337 units.\n",
"\n",
"=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n",
"\n",
"'__call__' 86780.44 ms\n"
"'__call__' 92583.43 ms\n"
]
},
{
Expand All @@ -818,7 +820,7 @@
" return Individual\n",
"\n",
"ga = utils.GA(\n",
" 'CCCC(=O)OCCN',\n",
" Chem.MolFromSmiles('CCCC(=O)OCCN'),\n",
" crem_db_path = os.path.join(tmp_path.name, 'crem.db'),\n",
" maxiter = 2,\n",
" popsize = 20,\n",
Expand Down
Loading

0 comments on commit 1a8d44c

Please sign in to comment.