jglaser commited on
Commit
759172e
·
1 Parent(s): 35a0528

fix indexing for [CLS] and [SEP]

Browse files
Files changed (4) hide show
  1. README.md +2 -1
  2. data/pdbbind_with_contacts.parquet +2 -2
  3. pdbbind.ipynb +40 -38
  4. pdbbind.py +2 -3
README.md CHANGED
@@ -10,7 +10,8 @@ tags:
10
  This dataset contains more than 16,000 unique pairs of protein sequences and ligand SMILES with experimentally determined
11
  binding affinities and protein-ligand contacts (ligand atom/SMILES token vs. Calpha within 5 Angstrom). These
12
  are represented by a list that contains the positions of non-zero elements of the flattened, sparse
13
- sequence x smiles tokens (2048x512) matrix.
 
14
 
15
  It can be used for fine-tuning a language model.
16
 
 
10
  This dataset contains more than 16,000 unique pairs of protein sequences and ligand SMILES with experimentally determined
11
  binding affinities and protein-ligand contacts (ligand atom/SMILES token vs. Calpha within 5 Angstrom). These
12
  are represented by a list that contains the positions of non-zero elements of the flattened, sparse
13
+ sequence x smiles tokens (2048x512) matrix. The first and last entries in both dimensions
14
+ are padded to zero, they correspond to [CLS] and [SEP].
15
 
16
  It can be used for fine-tuning a language model.
17
 
data/pdbbind_with_contacts.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ddad766228c134cc220959f62e9e95bce250083963079386be1d23e7eae78f7d
3
- size 16022320
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46dfc8d5f369cfe05c12955b45e15b3d8991014d01e0d5f28530b0bb0c6a6eb3
3
+ size 16075354
pdbbind.ipynb CHANGED
@@ -20,7 +20,7 @@
20
  },
21
  {
22
  "cell_type": "code",
23
- "execution_count": 4,
24
  "id": "9b2be11c-f4bb-4107-af49-abd78052afcf",
25
  "metadata": {},
26
  "outputs": [],
@@ -34,7 +34,7 @@
34
  },
35
  {
36
  "cell_type": "code",
37
- "execution_count": 5,
38
  "id": "68983ab8-bf11-4ed6-ba06-f962dbdc077e",
39
  "metadata": {},
40
  "outputs": [],
@@ -44,7 +44,7 @@
44
  },
45
  {
46
  "cell_type": "code",
47
- "execution_count": 6,
48
  "id": "3acbca3c-9c0b-43a1-a45e-331bf153bcfa",
49
  "metadata": {},
50
  "outputs": [],
@@ -67,7 +67,7 @@
67
  },
68
  {
69
  "cell_type": "code",
70
- "execution_count": 7,
71
  "id": "58e5748b-2cea-43ff-ab51-85a5021bd50b",
72
  "metadata": {},
73
  "outputs": [],
@@ -78,7 +78,7 @@
78
  },
79
  {
80
  "cell_type": "code",
81
- "execution_count": 8,
82
  "id": "d92f0004-68c1-4487-94b9-56b4fd598de4",
83
  "metadata": {},
84
  "outputs": [
@@ -88,7 +88,7 @@
88
  "<AxesSubplot:>"
89
  ]
90
  },
91
- "execution_count": 8,
92
  "metadata": {},
93
  "output_type": "execute_result"
94
  },
@@ -111,7 +111,7 @@
111
  },
112
  {
113
  "cell_type": "code",
114
- "execution_count": 42,
115
  "id": "aa358835-55f3-4551-9217-e76a15de4fe8",
116
  "metadata": {},
117
  "outputs": [],
@@ -122,7 +122,7 @@
122
  },
123
  {
124
  "cell_type": "code",
125
- "execution_count": 11,
126
  "id": "d6dda488-f709-4fe7-b372-080042cf7c66",
127
  "metadata": {},
128
  "outputs": [],
@@ -132,7 +132,7 @@
132
  },
133
  {
134
  "cell_type": "code",
135
- "execution_count": 12,
136
  "id": "ed3fe035-6035-4d39-b072-d12dc0a95857",
137
  "metadata": {},
138
  "outputs": [],
@@ -147,7 +147,7 @@
147
  },
148
  {
149
  "cell_type": "code",
150
- "execution_count": 13,
151
  "id": "cd26125b-e68b-4fa3-846e-2b6e7f635fe0",
152
  "metadata": {},
153
  "outputs": [],
@@ -158,7 +158,7 @@
158
  },
159
  {
160
  "cell_type": "code",
161
- "execution_count": 14,
162
  "id": "0e773f9d-6555-49c0-b0af-202c5e19b2cc",
163
  "metadata": {},
164
  "outputs": [
@@ -239,7 +239,7 @@
239
  "4 CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1 "
240
  ]
241
  },
242
- "execution_count": 14,
243
  "metadata": {},
244
  "output_type": "execute_result"
245
  }
@@ -250,7 +250,7 @@
250
  },
251
  {
252
  "cell_type": "code",
253
- "execution_count": 15,
254
  "id": "9c7c9849-2345-4baf-89e7-d412f52353b6",
255
  "metadata": {},
256
  "outputs": [
@@ -265,8 +265,8 @@
265
  " <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n",
266
  " </thead>\n",
267
  " <tbody>\n",
268
- " <tr><th> Bytes </th><td> 1.71 GiB </td> <td> 1.71 GiB </td></tr>\n",
269
- " <tr><th> Shape </th><td> (438, 1048576) </td> <td> (438, 1048576) </td></tr>\n",
270
  " <tr><th> Count </th><td> 75 Tasks </td><td> 1 Chunks </td></tr>\n",
271
  " <tr><th> Type </th><td> float32 </td><td> numpy.ndarray </td></tr>\n",
272
  " </tbody>\n",
@@ -287,7 +287,7 @@
287
  " <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
288
  "\n",
289
  " <!-- Text -->\n",
290
- " <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1048576</text>\n",
291
  " <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,12.706308)\">438</text>\n",
292
  "</svg>\n",
293
  "</td>\n",
@@ -295,10 +295,10 @@
295
  "</table>"
296
  ],
297
  "text/plain": [
298
- "dask.array<blocks, shape=(438, 1048576), dtype=float32, chunksize=(438, 1048576), chunktype=numpy.ndarray>"
299
  ]
300
  },
301
- "execution_count": 15,
302
  "metadata": {},
303
  "output_type": "execute_result"
304
  }
@@ -309,7 +309,7 @@
309
  },
310
  {
311
  "cell_type": "code",
312
- "execution_count": 17,
313
  "id": "42e95d84-ef27-4417-9479-8b356462b8c3",
314
  "metadata": {},
315
  "outputs": [],
@@ -317,7 +317,8 @@
317
  "import numpy as np\n",
318
  "def chunk_to_sparse(chunk, idx_chunk):\n",
319
  " res = df_complex.iloc[idx_chunk].copy()\n",
320
- " res['contacts'] = [np.where(a)[0] for a in chunk]\n",
 
321
  " return res\n",
322
  "\n",
323
  "partitions = [delayed(chunk_to_sparse)(b,k)\n",
@@ -364,35 +365,35 @@
364
  " <td>2lbv</td>\n",
365
  " <td>MTVPDRSEIAGKWYVVALASNTEFFLREKDKMKMAMARISFLGEDE...</td>\n",
366
  " <td>CCCCCCCCCCCCCCCCCCCC(=O)O</td>\n",
367
- " <td>[1046, 2578, 2579, 2582, 2584, 6144, 6145, 614...</td>\n",
368
  " </tr>\n",
369
  " <tr>\n",
370
  " <th>1</th>\n",
371
  " <td>1lt6</td>\n",
372
  " <td>APQTITELCSEYRNTQIYTINDKILSYTESMAGKREMVIITFKSGE...</td>\n",
373
  " <td>O=[N+]([O-])c1cccc(OC2OC(CO)C(O)C(O)C2O)c1</td>\n",
374
- " <td>[514, 518, 520, 521, 522, 523, 525, 526, 546, ...</td>\n",
375
  " </tr>\n",
376
  " <tr>\n",
377
  " <th>2</th>\n",
378
  " <td>4lwi</td>\n",
379
  " <td>VETFAFQAEIAQLMSLIINTFYSNKEIFLRELISNSSDALDKIRYE...</td>\n",
380
  " <td>COc1ccc(-c2c(-c3cc(C(C)C)c(O)cc3O)noc2NC(=O)C2...</td>\n",
381
- " <td>[521, 523, 526, 542, 544, 546, 547, 548, 1041,...</td>\n",
382
  " </tr>\n",
383
  " <tr>\n",
384
  " <th>3</th>\n",
385
  " <td>6oyz</td>\n",
386
  " <td>VQLQESGGGLVQTGGSLTLSCATSGRSFSLYAMAWFRQAPGKEREF...</td>\n",
387
  " <td>COC1C(O)C(n2ccc(=O)[nH]c2=O)OC1C(OC1OC(C(=O)NC...</td>\n",
388
- " <td>[35332, 35334, 35336, 35338, 35342, 35347, 353...</td>\n",
389
  " </tr>\n",
390
  " <tr>\n",
391
  " <th>4</th>\n",
392
  " <td>4i11</td>\n",
393
  " <td>GSFVEMVDNLRGKSGQGYYVEMTVGSPPQTLNILVDTGSSNFAVGA...</td>\n",
394
  " <td>CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1</td>\n",
395
- " <td>[36372, 36373, 36375, 36376, 36377, 36378, 363...</td>\n",
396
  " </tr>\n",
397
  " </tbody>\n",
398
  "</table>\n",
@@ -414,11 +415,11 @@
414
  "4 CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1 \n",
415
  "\n",
416
  " contacts \n",
417
- "0 [1046, 2578, 2579, 2582, 2584, 6144, 6145, 614... \n",
418
- "1 [514, 518, 520, 521, 522, 523, 525, 526, 546, ... \n",
419
- "2 [521, 523, 526, 542, 544, 546, 547, 548, 1041,... \n",
420
- "3 [35332, 35334, 35336, 35338, 35342, 35347, 353... \n",
421
- "4 [36372, 36373, 36375, 36376, 36377, 36378, 363... "
422
  ]
423
  },
424
  "execution_count": 20,
@@ -442,7 +443,7 @@
442
  },
443
  {
444
  "cell_type": "code",
445
- "execution_count": 45,
446
  "id": "f6cdee43-33c6-445c-8619-ace20f90638c",
447
  "metadata": {},
448
  "outputs": [],
@@ -452,7 +453,7 @@
452
  },
453
  {
454
  "cell_type": "code",
455
- "execution_count": 46,
456
  "id": "8f49f871-76f6-4fb2-b2db-c0794d4c07bf",
457
  "metadata": {},
458
  "outputs": [
@@ -460,8 +461,8 @@
460
  "name": "stdout",
461
  "output_type": "stream",
462
  "text": [
463
- "CPU times: user 1min 42s, sys: 3min 24s, total: 5min 6s\n",
464
- "Wall time: 28.9 s\n"
465
  ]
466
  }
467
  ],
@@ -472,7 +473,7 @@
472
  },
473
  {
474
  "cell_type": "code",
475
- "execution_count": 47,
476
  "id": "45e4b4fa-6338-4abe-bd6e-8aea46e2a09c",
477
  "metadata": {},
478
  "outputs": [],
@@ -482,7 +483,7 @@
482
  },
483
  {
484
  "cell_type": "code",
485
- "execution_count": 48,
486
  "id": "7c3db301-6565-4053-bbd4-139bb41dd1c4",
487
  "metadata": {},
488
  "outputs": [
@@ -492,7 +493,7 @@
492
  "(array([6.3455065]), array([3.57430038]))"
493
  ]
494
  },
495
- "execution_count": 48,
496
  "metadata": {},
497
  "output_type": "execute_result"
498
  }
@@ -506,11 +507,12 @@
506
  },
507
  {
508
  "cell_type": "code",
509
- "execution_count": 41,
510
  "id": "c9d674bb-d6a2-4810-aa2b-e3bc3b4bbc98",
511
  "metadata": {},
512
  "outputs": [],
513
  "source": [
 
514
  "df_all_contacts.drop(columns=['name','affinity_quantity']).astype({'affinity': 'float32','neg_log10_affinity_M': 'float32'}).to_parquet('data/pdbbind_with_contacts.parquet',index=False)"
515
  ]
516
  },
 
20
  },
21
  {
22
  "cell_type": "code",
23
+ "execution_count": 2,
24
  "id": "9b2be11c-f4bb-4107-af49-abd78052afcf",
25
  "metadata": {},
26
  "outputs": [],
 
34
  },
35
  {
36
  "cell_type": "code",
37
+ "execution_count": 3,
38
  "id": "68983ab8-bf11-4ed6-ba06-f962dbdc077e",
39
  "metadata": {},
40
  "outputs": [],
 
44
  },
45
  {
46
  "cell_type": "code",
47
+ "execution_count": 4,
48
  "id": "3acbca3c-9c0b-43a1-a45e-331bf153bcfa",
49
  "metadata": {},
50
  "outputs": [],
 
67
  },
68
  {
69
  "cell_type": "code",
70
+ "execution_count": 5,
71
  "id": "58e5748b-2cea-43ff-ab51-85a5021bd50b",
72
  "metadata": {},
73
  "outputs": [],
 
78
  },
79
  {
80
  "cell_type": "code",
81
+ "execution_count": 6,
82
  "id": "d92f0004-68c1-4487-94b9-56b4fd598de4",
83
  "metadata": {},
84
  "outputs": [
 
88
  "<AxesSubplot:>"
89
  ]
90
  },
91
+ "execution_count": 6,
92
  "metadata": {},
93
  "output_type": "execute_result"
94
  },
 
111
  },
112
  {
113
  "cell_type": "code",
114
+ "execution_count": 7,
115
  "id": "aa358835-55f3-4551-9217-e76a15de4fe8",
116
  "metadata": {},
117
  "outputs": [],
 
122
  },
123
  {
124
  "cell_type": "code",
125
+ "execution_count": 8,
126
  "id": "d6dda488-f709-4fe7-b372-080042cf7c66",
127
  "metadata": {},
128
  "outputs": [],
 
132
  },
133
  {
134
  "cell_type": "code",
135
+ "execution_count": 9,
136
  "id": "ed3fe035-6035-4d39-b072-d12dc0a95857",
137
  "metadata": {},
138
  "outputs": [],
 
147
  },
148
  {
149
  "cell_type": "code",
150
+ "execution_count": 10,
151
  "id": "cd26125b-e68b-4fa3-846e-2b6e7f635fe0",
152
  "metadata": {},
153
  "outputs": [],
 
158
  },
159
  {
160
  "cell_type": "code",
161
+ "execution_count": 11,
162
  "id": "0e773f9d-6555-49c0-b0af-202c5e19b2cc",
163
  "metadata": {},
164
  "outputs": [
 
239
  "4 CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1 "
240
  ]
241
  },
242
+ "execution_count": 11,
243
  "metadata": {},
244
  "output_type": "execute_result"
245
  }
 
250
  },
251
  {
252
  "cell_type": "code",
253
+ "execution_count": 12,
254
  "id": "9c7c9849-2345-4baf-89e7-d412f52353b6",
255
  "metadata": {},
256
  "outputs": [
 
265
  " <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n",
266
  " </thead>\n",
267
  " <tbody>\n",
268
+ " <tr><th> Bytes </th><td> 1.70 GiB </td> <td> 1.70 GiB </td></tr>\n",
269
+ " <tr><th> Shape </th><td> (438, 1043460) </td> <td> (438, 1043460) </td></tr>\n",
270
  " <tr><th> Count </th><td> 75 Tasks </td><td> 1 Chunks </td></tr>\n",
271
  " <tr><th> Type </th><td> float32 </td><td> numpy.ndarray </td></tr>\n",
272
  " </tbody>\n",
 
287
  " <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
288
  "\n",
289
  " <!-- Text -->\n",
290
+ " <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1043460</text>\n",
291
  " <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,12.706308)\">438</text>\n",
292
  "</svg>\n",
293
  "</td>\n",
 
295
  "</table>"
296
  ],
297
  "text/plain": [
298
+ "dask.array<blocks, shape=(438, 1043460), dtype=float32, chunksize=(438, 1043460), chunktype=numpy.ndarray>"
299
  ]
300
  },
301
+ "execution_count": 12,
302
  "metadata": {},
303
  "output_type": "execute_result"
304
  }
 
309
  },
310
  {
311
  "cell_type": "code",
312
+ "execution_count": 19,
313
  "id": "42e95d84-ef27-4417-9479-8b356462b8c3",
314
  "metadata": {},
315
  "outputs": [],
 
317
  "import numpy as np\n",
318
  "def chunk_to_sparse(chunk, idx_chunk):\n",
319
  " res = df_complex.iloc[idx_chunk].copy()\n",
320
+ " # pad to account for [CLS] and [SEP]\n",
321
+ " res['contacts'] = [np.where(np.pad(a,pad_width=(1,1)))[0] for a in chunk]\n",
322
  " return res\n",
323
  "\n",
324
  "partitions = [delayed(chunk_to_sparse)(b,k)\n",
 
365
  " <td>2lbv</td>\n",
366
  " <td>MTVPDRSEIAGKWYVVALASNTEFFLREKDKMKMAMARISFLGEDE...</td>\n",
367
  " <td>CCCCCCCCCCCCCCCCCCCC(=O)O</td>\n",
368
+ " <td>[1043, 2569, 2570, 2573, 2575, 6121, 6122, 612...</td>\n",
369
  " </tr>\n",
370
  " <tr>\n",
371
  " <th>1</th>\n",
372
  " <td>1lt6</td>\n",
373
  " <td>APQTITELCSEYRNTQIYTINDKILSYTESMAGKREMVIITFKSGE...</td>\n",
374
  " <td>O=[N+]([O-])c1cccc(OC2OC(CO)C(O)C(O)C2O)c1</td>\n",
375
+ " <td>[513, 517, 519, 520, 521, 522, 524, 525, 545, ...</td>\n",
376
  " </tr>\n",
377
  " <tr>\n",
378
  " <th>2</th>\n",
379
  " <td>4lwi</td>\n",
380
  " <td>VETFAFQAEIAQLMSLIINTFYSNKEIFLRELISNSSDALDKIRYE...</td>\n",
381
  " <td>COc1ccc(-c2c(-c3cc(C(C)C)c(O)cc3O)noc2NC(=O)C2...</td>\n",
382
+ " <td>[520, 522, 525, 541, 543, 545, 546, 547, 1038,...</td>\n",
383
  " </tr>\n",
384
  " <tr>\n",
385
  " <th>3</th>\n",
386
  " <td>6oyz</td>\n",
387
  " <td>VQLQESGGGLVQTGGSLTLSCATSGRSFSLYAMAWFRQAPGKEREF...</td>\n",
388
  " <td>COC1C(O)C(n2ccc(=O)[nH]c2=O)OC1C(OC1OC(C(=O)NC...</td>\n",
389
+ " <td>[35195, 35197, 35199, 35201, 35205, 35210, 352...</td>\n",
390
  " </tr>\n",
391
  " <tr>\n",
392
  " <th>4</th>\n",
393
  " <td>4i11</td>\n",
394
  " <td>GSFVEMVDNLRGKSGQGYYVEMTVGSPPQTLNILVDTGSSNFAVGA...</td>\n",
395
  " <td>CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1</td>\n",
396
+ " <td>[36231, 36232, 36234, 36235, 36236, 36237, 362...</td>\n",
397
  " </tr>\n",
398
  " </tbody>\n",
399
  "</table>\n",
 
415
  "4 CC1(C)Cc2ccccc2C(NC(Cc2ccccc2)C(=O)O)=N1 \n",
416
  "\n",
417
  " contacts \n",
418
+ "0 [1043, 2569, 2570, 2573, 2575, 6121, 6122, 612... \n",
419
+ "1 [513, 517, 519, 520, 521, 522, 524, 525, 545, ... \n",
420
+ "2 [520, 522, 525, 541, 543, 545, 546, 547, 1038,... \n",
421
+ "3 [35195, 35197, 35199, 35201, 35205, 35210, 352... \n",
422
+ "4 [36231, 36232, 36234, 36235, 36236, 36237, 362... "
423
  ]
424
  },
425
  "execution_count": 20,
 
443
  },
444
  {
445
  "cell_type": "code",
446
+ "execution_count": 22,
447
  "id": "f6cdee43-33c6-445c-8619-ace20f90638c",
448
  "metadata": {},
449
  "outputs": [],
 
453
  },
454
  {
455
  "cell_type": "code",
456
+ "execution_count": 23,
457
  "id": "8f49f871-76f6-4fb2-b2db-c0794d4c07bf",
458
  "metadata": {},
459
  "outputs": [
 
461
  "name": "stdout",
462
  "output_type": "stream",
463
  "text": [
464
+ "CPU times: user 2min 8s, sys: 3min 26s, total: 5min 35s\n",
465
+ "Wall time: 2min 12s\n"
466
  ]
467
  }
468
  ],
 
473
  },
474
  {
475
  "cell_type": "code",
476
+ "execution_count": 24,
477
  "id": "45e4b4fa-6338-4abe-bd6e-8aea46e2a09c",
478
  "metadata": {},
479
  "outputs": [],
 
483
  },
484
  {
485
  "cell_type": "code",
486
+ "execution_count": 25,
487
  "id": "7c3db301-6565-4053-bbd4-139bb41dd1c4",
488
  "metadata": {},
489
  "outputs": [
 
493
  "(array([6.3455065]), array([3.57430038]))"
494
  ]
495
  },
496
+ "execution_count": 25,
497
  "metadata": {},
498
  "output_type": "execute_result"
499
  }
 
507
  },
508
  {
509
  "cell_type": "code",
510
+ "execution_count": 26,
511
  "id": "c9d674bb-d6a2-4810-aa2b-e3bc3b4bbc98",
512
  "metadata": {},
513
  "outputs": [],
514
  "source": [
515
+ "# save to parquet\n",
516
  "df_all_contacts.drop(columns=['name','affinity_quantity']).astype({'affinity': 'float32','neg_log10_affinity_M': 'float32'}).to_parquet('data/pdbbind_with_contacts.parquet',index=False)"
517
  ]
518
  },
pdbbind.py CHANGED
@@ -21,8 +21,8 @@ punctuation_regex = r"""(\(|\)|\.|=|#|-|\+|\\|\/|:|~|@|\?|>>?|\*|\$|\%[0-9]{2}|
21
  molecule_regex = r"""(\[[^\]]+]|Br?|Cl?|N|O|S|P|F|I|b|c|n|o|s|p|\(|\)|\.|=|#|-|\+|\\|\/|:|~|@|\?|>>?|\*|\$|\%[0-9]{2}|[0-9])"""
22
 
23
  cutoff = 5
24
- max_seq = 2048
25
- max_smiles = 512
26
  chunk_size = '1G'
27
 
28
  def parse_complex(fn):
@@ -48,7 +48,6 @@ def parse_complex(fn):
48
  smi = Chem.MolToSmiles(mol)
49
 
50
  # position of atoms in SMILES (not counting punctuation)
51
- atom_order = mol.GetProp("_smilesAtomOutputOrder")
52
  atom_order = [int(s) for s in list(filter(None,re.sub(r'[\[\]]','',mol.GetProp("_smilesAtomOutputOrder")).split(',')))]
53
 
54
  # tokenize the SMILES
 
21
  molecule_regex = r"""(\[[^\]]+]|Br?|Cl?|N|O|S|P|F|I|b|c|n|o|s|p|\(|\)|\.|=|#|-|\+|\\|\/|:|~|@|\?|>>?|\*|\$|\%[0-9]{2}|[0-9])"""
22
 
23
  cutoff = 5
24
+ max_seq = 2046 # = 2048 - 2 (accounting for [CLS] and [SEP])
25
+ max_smiles = 510 # = 512 - 2
26
  chunk_size = '1G'
27
 
28
  def parse_complex(fn):
 
48
  smi = Chem.MolToSmiles(mol)
49
 
50
  # position of atoms in SMILES (not counting punctuation)
 
51
  atom_order = [int(s) for s in list(filter(None,re.sub(r'[\[\]]','',mol.GetProp("_smilesAtomOutputOrder")).split(',')))]
52
 
53
  # tokenize the SMILES