make smiles canonical
Browse files- binding_affinity.py +2 -2
- combine_dbs.ipynb +60 -13
- data/all.parquet +2 -2
binding_affinity.py
CHANGED
|
@@ -90,7 +90,7 @@ class BindingAffinity(datasets.ArrowBasedBuilder):
|
|
| 90 |
features = datasets.Features(
|
| 91 |
{
|
| 92 |
"seq": datasets.Value("string"),
|
| 93 |
-
"
|
| 94 |
"neg_log10_affinity_M": datasets.Value("float"),
|
| 95 |
"affinity": datasets.Value("float"),
|
| 96 |
# These are the features of your dataset like images, labels ...
|
|
@@ -161,7 +161,7 @@ class BindingAffinity(datasets.ArrowBasedBuilder):
|
|
| 161 |
for k, row in df.iterrows():
|
| 162 |
yield k, {
|
| 163 |
"seq": row["seq"],
|
| 164 |
-
"
|
| 165 |
"neg_log10_affinity_M": row["neg_log10_affinity_M"],
|
| 166 |
"affinity_uM": row["affinity_uM"],
|
| 167 |
}
|
|
|
|
| 90 |
features = datasets.Features(
|
| 91 |
{
|
| 92 |
"seq": datasets.Value("string"),
|
| 93 |
+
"smiles_can": datasets.Value("string"),
|
| 94 |
"neg_log10_affinity_M": datasets.Value("float"),
|
| 95 |
"affinity": datasets.Value("float"),
|
| 96 |
# These are the features of your dataset like images, labels ...
|
|
|
|
| 161 |
for k, row in df.iterrows():
|
| 162 |
yield k, {
|
| 163 |
"seq": row["seq"],
|
| 164 |
+
"smiles_can": row["smiles_can"],
|
| 165 |
"neg_log10_affinity_M": row["neg_log10_affinity_M"],
|
| 166 |
"affinity_uM": row["affinity_uM"],
|
| 167 |
}
|
combine_dbs.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"id": "95bd761a-fe51-4a8e-bc70-1365260ba5f8",
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
|
@@ -1363,17 +1363,62 @@
|
|
| 1363 |
"metadata": {},
|
| 1364 |
"outputs": [],
|
| 1365 |
"source": [
|
| 1366 |
-
"df.to_parquet('data/
|
| 1367 |
]
|
| 1368 |
},
|
| 1369 |
{
|
| 1370 |
"cell_type": "code",
|
| 1371 |
-
"execution_count":
|
| 1372 |
"id": "4e2d89f7-f6ea-41de-a13b-4a184b4fd580",
|
| 1373 |
"metadata": {},
|
| 1374 |
"outputs": [],
|
| 1375 |
"source": [
|
| 1376 |
-
"df = pd.read_parquet('data/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1377 |
]
|
| 1378 |
},
|
| 1379 |
{
|
|
@@ -1449,7 +1494,7 @@
|
|
| 1449 |
},
|
| 1450 |
{
|
| 1451 |
"cell_type": "code",
|
| 1452 |
-
"execution_count":
|
| 1453 |
"id": "c6c64066-4032-4247-a8b9-00388176cc7b",
|
| 1454 |
"metadata": {},
|
| 1455 |
"outputs": [],
|
|
@@ -1459,17 +1504,19 @@
|
|
| 1459 |
},
|
| 1460 |
{
|
| 1461 |
"cell_type": "code",
|
| 1462 |
-
"execution_count":
|
| 1463 |
"id": "469cf0dd-7b87-4245-973c-2a445e1fcca9",
|
| 1464 |
"metadata": {},
|
| 1465 |
"outputs": [
|
| 1466 |
{
|
| 1467 |
"data": {
|
| 1468 |
"text/plain": [
|
| 1469 |
-
"Index(['seq', 'smiles', 'affinity_uM', 'neg_log10_affinity_M', 'affinity'
|
|
|
|
|
|
|
| 1470 |
]
|
| 1471 |
},
|
| 1472 |
-
"execution_count":
|
| 1473 |
"metadata": {},
|
| 1474 |
"output_type": "execute_result"
|
| 1475 |
}
|
|
@@ -1480,7 +1527,7 @@
|
|
| 1480 |
},
|
| 1481 |
{
|
| 1482 |
"cell_type": "code",
|
| 1483 |
-
"execution_count":
|
| 1484 |
"id": "d91c0d91-474c-4ab2-9a5e-3b7861f7a832",
|
| 1485 |
"metadata": {},
|
| 1486 |
"outputs": [
|
|
@@ -1506,23 +1553,23 @@
|
|
| 1506 |
},
|
| 1507 |
{
|
| 1508 |
"cell_type": "code",
|
| 1509 |
-
"execution_count":
|
| 1510 |
"id": "9ca8df46-15d3-40f9-b304-dd6e5597be5e",
|
| 1511 |
"metadata": {},
|
| 1512 |
"outputs": [
|
| 1513 |
{
|
| 1514 |
"data": {
|
| 1515 |
"text/plain": [
|
| 1516 |
-
"
|
| 1517 |
]
|
| 1518 |
},
|
| 1519 |
-
"execution_count":
|
| 1520 |
"metadata": {},
|
| 1521 |
"output_type": "execute_result"
|
| 1522 |
}
|
| 1523 |
],
|
| 1524 |
"source": [
|
| 1525 |
-
"(df['neg_log10_affinity_M']<
|
| 1526 |
]
|
| 1527 |
},
|
| 1528 |
{
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
"id": "95bd761a-fe51-4a8e-bc70-1365260ba5f8",
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
|
|
|
| 1363 |
"metadata": {},
|
| 1364 |
"outputs": [],
|
| 1365 |
"source": [
|
| 1366 |
+
"df.to_parquet('data/all_nocan.parquet')"
|
| 1367 |
]
|
| 1368 |
},
|
| 1369 |
{
|
| 1370 |
"cell_type": "code",
|
| 1371 |
+
"execution_count": 11,
|
| 1372 |
"id": "4e2d89f7-f6ea-41de-a13b-4a184b4fd580",
|
| 1373 |
"metadata": {},
|
| 1374 |
"outputs": [],
|
| 1375 |
"source": [
|
| 1376 |
+
"df = pd.read_parquet('data/all_nocan.parquet')"
|
| 1377 |
+
]
|
| 1378 |
+
},
|
| 1379 |
+
{
|
| 1380 |
+
"cell_type": "code",
|
| 1381 |
+
"execution_count": 5,
|
| 1382 |
+
"id": "b4b9acd7-7784-492b-9fa3-b7fad9d18a9d",
|
| 1383 |
+
"metadata": {},
|
| 1384 |
+
"outputs": [
|
| 1385 |
+
{
|
| 1386 |
+
"name": "stdout",
|
| 1387 |
+
"output_type": "stream",
|
| 1388 |
+
"text": [
|
| 1389 |
+
"INFO: Pandarallel will run on 256 workers.\n",
|
| 1390 |
+
"INFO: Pandarallel will use Memory file system to transfer data between the main process and workers.\n"
|
| 1391 |
+
]
|
| 1392 |
+
}
|
| 1393 |
+
],
|
| 1394 |
+
"source": [
|
| 1395 |
+
"from pandarallel import pandarallel\n",
|
| 1396 |
+
"pandarallel.initialize()\n"
|
| 1397 |
+
]
|
| 1398 |
+
},
|
| 1399 |
+
{
|
| 1400 |
+
"cell_type": "code",
|
| 1401 |
+
"execution_count": 12,
|
| 1402 |
+
"id": "eb99774f-9bcc-454d-b5e5-a8470223d6ca",
|
| 1403 |
+
"metadata": {},
|
| 1404 |
+
"outputs": [],
|
| 1405 |
+
"source": [
|
| 1406 |
+
"from rdkit import Chem\n",
|
| 1407 |
+
"def make_canonical(smi):\n",
|
| 1408 |
+
" try:\n",
|
| 1409 |
+
" return Chem.MolToSmiles(Chem.MolFromSmiles(smi))\n",
|
| 1410 |
+
" except:\n",
|
| 1411 |
+
" return smi"
|
| 1412 |
+
]
|
| 1413 |
+
},
|
| 1414 |
+
{
|
| 1415 |
+
"cell_type": "code",
|
| 1416 |
+
"execution_count": 14,
|
| 1417 |
+
"id": "4d44bd8e-f2e1-44b4-aea7-40b4437baf44",
|
| 1418 |
+
"metadata": {},
|
| 1419 |
+
"outputs": [],
|
| 1420 |
+
"source": [
|
| 1421 |
+
"df['smiles_can'] = df['smiles'].parallel_apply(make_canonical)"
|
| 1422 |
]
|
| 1423 |
},
|
| 1424 |
{
|
|
|
|
| 1494 |
},
|
| 1495 |
{
|
| 1496 |
"cell_type": "code",
|
| 1497 |
+
"execution_count": 16,
|
| 1498 |
"id": "c6c64066-4032-4247-a8b9-00388176cc7b",
|
| 1499 |
"metadata": {},
|
| 1500 |
"outputs": [],
|
|
|
|
| 1504 |
},
|
| 1505 |
{
|
| 1506 |
"cell_type": "code",
|
| 1507 |
+
"execution_count": 18,
|
| 1508 |
"id": "469cf0dd-7b87-4245-973c-2a445e1fcca9",
|
| 1509 |
"metadata": {},
|
| 1510 |
"outputs": [
|
| 1511 |
{
|
| 1512 |
"data": {
|
| 1513 |
"text/plain": [
|
| 1514 |
+
"Index(['seq', 'smiles', 'affinity_uM', 'neg_log10_affinity_M', 'affinity',\n",
|
| 1515 |
+
" 'smiles_can'],\n",
|
| 1516 |
+
" dtype='object')"
|
| 1517 |
]
|
| 1518 |
},
|
| 1519 |
+
"execution_count": 18,
|
| 1520 |
"metadata": {},
|
| 1521 |
"output_type": "execute_result"
|
| 1522 |
}
|
|
|
|
| 1527 |
},
|
| 1528 |
{
|
| 1529 |
"cell_type": "code",
|
| 1530 |
+
"execution_count": 19,
|
| 1531 |
"id": "d91c0d91-474c-4ab2-9a5e-3b7861f7a832",
|
| 1532 |
"metadata": {},
|
| 1533 |
"outputs": [
|
|
|
|
| 1553 |
},
|
| 1554 |
{
|
| 1555 |
"cell_type": "code",
|
| 1556 |
+
"execution_count": 6,
|
| 1557 |
"id": "9ca8df46-15d3-40f9-b304-dd6e5597be5e",
|
| 1558 |
"metadata": {},
|
| 1559 |
"outputs": [
|
| 1560 |
{
|
| 1561 |
"data": {
|
| 1562 |
"text/plain": [
|
| 1563 |
+
"0.17005836848632214"
|
| 1564 |
]
|
| 1565 |
},
|
| 1566 |
+
"execution_count": 6,
|
| 1567 |
"metadata": {},
|
| 1568 |
"output_type": "execute_result"
|
| 1569 |
}
|
| 1570 |
],
|
| 1571 |
"source": [
|
| 1572 |
+
"(df['neg_log10_affinity_M']<5).sum()/len(df)"
|
| 1573 |
]
|
| 1574 |
},
|
| 1575 |
{
|
data/all.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4864292b2aa4e63ffdc28ebdc7baea53a3a396d6e66ccd9927a04885586d160e
|
| 3 |
+
size 228485896
|