smostafanejad commited on
Commit
a95c7e5
·
verified ·
1 Parent(s): 56071ad

adds the loading script

Browse files
Files changed (1) hide show
  1. pubchem-10-15-2024-selfies.py +599 -0
pubchem-10-15-2024-selfies.py ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """loading script for the pubchem-10-15-2024-selfies data"""
15
+
16
+ import ijson
17
+ import datasets
18
+
19
+
20
+ _CITATION = """\
21
+ @article{Kim:2022:D1373,
22
+ author = {Kim, Sunghwan and Chen, Jie and Cheng, Tiejun and Gindulyte, Asta and He, Jia and He, Siqian and Li, Qingliang and Shoemaker, Benjamin A and Thiessen, Paul A and Yu, Bo and Zaslavsky, Leonid and Zhang, Jian and Bolton, Evan E},
23
+ title = "{PubChem 2023 update}",
24
+ journal = {Nucleic Acids Research},
25
+ volume = {51},
26
+ pages = {D1373-D1380},
27
+ year = {2022},
28
+ doi = {10.1093/nar/gkac956}
29
+ }
30
+ """
31
+
32
+ _DESCRIPTION = """\
33
+ PubChem (https://pubchem.ncbi.nlm.nih.gov) is a popular chemical information \
34
+ resource that serves a wide range of use cases. In the past \
35
+ two years, a number of changes were made to PubChem. Data from more than 120 \
36
+ data sources was added to PubChem. Some major highlights include: the \
37
+ integration of Google Patents data into PubChem, which greatly expanded the \
38
+ coverage of the PubChem Patent data collection; the creation of the Cell Line \
39
+ and Taxonomy data collections, which provide quick and easy access to chemical \
40
+ information for a given cell line and taxon, respectively; and the update of \
41
+ the bioassay data model. In addition, new functionalities were added to the \
42
+ PubChem programmatic access protocols, PUG-REST and PUG-View, including support \
43
+ for target-centric data download for a given protein, gene, pathway, cell line, \
44
+ and taxon and the addition of the `standardize` option to PUG-REST, which \
45
+ returns the standardized form of an input chemical structure. A significant \
46
+ update was also made to PubChemRDF. The present paper provides an overview of \
47
+ these changes.
48
+
49
+ We have added the SELFIES strings to the PubChem dataset (ver. 10-15-2024).
50
+ The canonical SMILES (from the ``PUBCHEM_OPENEYE_CAN_SMILES`` entry) were
51
+ adopted as the input for generating the SELFIES strings stored in the ``SELFIES``
52
+ entry. The SELFIES strings were generated using the [SELFIES Python package](https://github.com/aspuru-guzik-group/selfies).
53
+ """
54
+
55
+ _HOMEPAGE = "https://pubchem.ncbi.nlm.nih.gov"
56
+
57
+ _LICENSE = "https://www.ncbi.nlm.nih.gov/home/about/policies/#data"
58
+
59
+ _BASE_DATA_URL_FORMAT_STR = "https://huggingface.co/datasets/molssiai-hub/pubchem-10-15-2024-selfies/resolve/main/data/train/Compound_{range}.json"
60
+
61
+ _CONFIG_NAMES = [
62
+ "pubchem-10-15-2024-selfies"
63
+ ]
64
+
65
+ _FEATURE_KEYS = [
66
+ 'PUBCHEM_COMPOUND_CID',
67
+ 'PUBCHEM_COMPOUND_CANONICALIZED',
68
+ 'PUBCHEM_CACTVS_COMPLEXITY',
69
+ 'PUBCHEM_CACTVS_HBOND_ACCEPTOR',
70
+ 'PUBCHEM_CACTVS_HBOND_DONOR',
71
+ 'PUBCHEM_CACTVS_ROTATABLE_BOND',
72
+ 'PUBCHEM_CACTVS_SUBSKEYS',
73
+ 'PUBCHEM_IUPAC_OPENEYE_NAME',
74
+ 'PUBCHEM_IUPAC_CAS_NAME',
75
+ 'PUBCHEM_IUPAC_NAME_MARKUP',
76
+ 'PUBCHEM_IUPAC_NAME',
77
+ 'PUBCHEM_IUPAC_SYSTEMATIC_NAME',
78
+ 'PUBCHEM_IUPAC_TRADITIONAL_NAME',
79
+ 'PUBCHEM_IUPAC_INCHI',
80
+ 'PUBCHEM_IUPAC_INCHIKEY',
81
+ 'PUBCHEM_XLOGP3_AA',
82
+ 'PUBCHEM_EXACT_MASS',
83
+ 'PUBCHEM_MOLECULAR_FORMULA',
84
+ 'PUBCHEM_MOLECULAR_WEIGHT',
85
+ 'PUBCHEM_OPENEYE_CAN_SMILES',
86
+ 'PUBCHEM_OPENEYE_ISO_SMILES',
87
+ 'PUBCHEM_CACTVS_TPSA',
88
+ 'PUBCHEM_MONOISOTOPIC_WEIGHT',
89
+ 'PUBCHEM_TOTAL_CHARGE',
90
+ 'PUBCHEM_HEAVY_ATOM_COUNT',
91
+ 'PUBCHEM_ATOM_DEF_STEREO_COUNT',
92
+ 'PUBCHEM_ATOM_UDEF_STEREO_COUNT',
93
+ 'PUBCHEM_BOND_DEF_STEREO_COUNT',
94
+ 'PUBCHEM_BOND_UDEF_STEREO_COUNT',
95
+ 'PUBCHEM_ISOTOPIC_ATOM_COUNT',
96
+ 'PUBCHEM_COMPONENT_COUNT',
97
+ 'PUBCHEM_CACTVS_TAUTO_COUNT',
98
+ 'PUBCHEM_COORDINATE_TYPE',
99
+ 'PUBCHEM_BONDANNOTATIONS',
100
+ 'COORDS',
101
+ 'ATOMIC_INDICES',
102
+ 'ATOMIC_SYMBOLS',
103
+ 'ATOMIC_NUMBERS',
104
+ 'ATOMIC_FORMAL_CHARGES',
105
+ 'BOND_ORDERS',
106
+ 'PUBCHEM_XLOGP3',
107
+ 'PUBCHEM_NONSTANDARDBOND',
108
+ 'PUBCHEM_REFERENCE_STANDARDIZATION',
109
+ 'SELFIES'
110
+ ]
111
+
112
+ _FEATURE_TYPES = datasets.Features(
113
+ {
114
+ 'PUBCHEM_COMPOUND_CID': datasets.Value(dtype='string', id=None),
115
+ 'PUBCHEM_COMPOUND_CANONICALIZED': datasets.Value(dtype='string', id=None),
116
+ 'PUBCHEM_CACTVS_COMPLEXITY': datasets.Value(dtype='float64', id=None),
117
+ 'PUBCHEM_CACTVS_HBOND_ACCEPTOR': datasets.Value(dtype='int64', id=None),
118
+ 'PUBCHEM_CACTVS_HBOND_DONOR': datasets.Value(dtype='int64', id=None),
119
+ 'PUBCHEM_CACTVS_ROTATABLE_BOND': datasets.Value(dtype='int64', id=None),
120
+ 'PUBCHEM_CACTVS_SUBSKEYS': datasets.Value(dtype='string', id=None),
121
+ 'PUBCHEM_IUPAC_OPENEYE_NAME': datasets.Value(dtype='string', id=None),
122
+ 'PUBCHEM_IUPAC_CAS_NAME': datasets.Value(dtype='string', id=None),
123
+ 'PUBCHEM_IUPAC_NAME_MARKUP': datasets.Value(dtype='string', id=None),
124
+ 'PUBCHEM_IUPAC_NAME': datasets.Value(dtype='string', id=None),
125
+ 'PUBCHEM_IUPAC_SYSTEMATIC_NAME': datasets.Value(dtype='string', id=None),
126
+ 'PUBCHEM_IUPAC_TRADITIONAL_NAME': datasets.Value(dtype='string', id=None),
127
+ 'PUBCHEM_IUPAC_INCHI': datasets.Value(dtype='string', id=None),
128
+ 'PUBCHEM_IUPAC_INCHIKEY': datasets.Value(dtype='string', id=None),
129
+ 'PUBCHEM_XLOGP3_AA': datasets.Value(dtype='float64', id=None),
130
+ 'PUBCHEM_EXACT_MASS': datasets.Value(dtype='float64', id=None),
131
+ 'PUBCHEM_MOLECULAR_FORMULA': datasets.Value(dtype='string', id=None),
132
+ 'PUBCHEM_MOLECULAR_WEIGHT': datasets.Value(dtype='float64', id=None),
133
+ 'PUBCHEM_OPENEYE_CAN_SMILES': datasets.Value(dtype='string', id=None),
134
+ 'PUBCHEM_OPENEYE_ISO_SMILES': datasets.Value(dtype='string', id=None),
135
+ 'PUBCHEM_CACTVS_TPSA': datasets.Value(dtype='float64', id=None),
136
+ 'PUBCHEM_MONOISOTOPIC_WEIGHT': datasets.Value(dtype='float64', id=None),
137
+ 'PUBCHEM_TOTAL_CHARGE': datasets.Value(dtype='int64', id=None),
138
+ 'PUBCHEM_HEAVY_ATOM_COUNT': datasets.Value(dtype='int64', id=None),
139
+ 'PUBCHEM_ATOM_DEF_STEREO_COUNT': datasets.Value(dtype='int64', id=None),
140
+ 'PUBCHEM_ATOM_UDEF_STEREO_COUNT': datasets.Value(dtype='int64', id=None),
141
+ 'PUBCHEM_BOND_DEF_STEREO_COUNT': datasets.Value(dtype='int64', id=None),
142
+ 'PUBCHEM_BOND_UDEF_STEREO_COUNT': datasets.Value(dtype='int64', id=None),
143
+ 'PUBCHEM_ISOTOPIC_ATOM_COUNT': datasets.Value(dtype='int64', id=None),
144
+ 'PUBCHEM_COMPONENT_COUNT': datasets.Value(dtype='int64', id=None),
145
+ 'PUBCHEM_CACTVS_TAUTO_COUNT': datasets.Value(dtype='int64', id=None),
146
+ 'PUBCHEM_COORDINATE_TYPE': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
147
+ 'PUBCHEM_BONDANNOTATIONS': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
148
+ 'COORDS': datasets.Sequence(feature=datasets.Value(dtype='float64', id=None), length=-1, id=None),
149
+ 'ATOMIC_INDICES': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
150
+ 'ATOMIC_SYMBOLS': datasets.Sequence(feature=datasets.Value(dtype='string', id=None), length=-1, id=None),
151
+ 'ATOMIC_NUMBERS': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
152
+ 'ATOMIC_FORMAL_CHARGES': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
153
+ 'BOND_ORDERS': datasets.Sequence(feature=datasets.Value(dtype='int64', id=None), length=-1, id=None),
154
+ 'PUBCHEM_XLOGP3': datasets.Value(dtype='string', id=None),
155
+ 'PUBCHEM_NONSTANDARDBOND': datasets.Value(dtype='string', id=None),
156
+ 'PUBCHEM_REFERENCE_STANDARDIZATION': datasets.Value(dtype='string', id=None),
157
+ 'SELFIES': datasets.Value(dtype='string', id=None),
158
+ }
159
+ )
160
+
161
+ _ID_RANGES = [
162
+ '000000001_000500000',
163
+ '000500001_001000000',
164
+ '001000001_001500000',
165
+ '001500001_002000000',
166
+ '002000001_002500000',
167
+ '002500001_003000000',
168
+ '003000001_003500000',
169
+ '003500001_004000000',
170
+ '004000001_004500000',
171
+ '004500001_005000000',
172
+ '005000001_005500000',
173
+ '005500001_006000000',
174
+ '006000001_006500000',
175
+ '006500001_007000000',
176
+ '007000001_007500000',
177
+ '007500001_008000000',
178
+ '008000001_008500000',
179
+ '008500001_009000000',
180
+ '009000001_009500000',
181
+ '009500001_010000000',
182
+ '010000001_010500000',
183
+ '010500001_011000000',
184
+ '011000001_011500000',
185
+ '011500001_012000000',
186
+ '012000001_012500000',
187
+ '012500001_013000000',
188
+ '013000001_013500000',
189
+ '013500001_014000000',
190
+ '014000001_014500000',
191
+ '014500001_015000000',
192
+ '015000001_015500000',
193
+ '015500001_016000000',
194
+ '016000001_016500000',
195
+ '016500001_017000000',
196
+ '017000001_017500000',
197
+ '017500001_018000000',
198
+ '018000001_018500000',
199
+ '018500001_019000000',
200
+ '019000001_019500000',
201
+ '019500001_020000000',
202
+ '020000001_020500000',
203
+ '020500001_021000000',
204
+ '021000001_021500000',
205
+ '021500001_022000000',
206
+ '022000001_022500000',
207
+ '022500001_023000000',
208
+ '023000001_023500000',
209
+ '023500001_024000000',
210
+ '024000001_024500000',
211
+ '024500001_025000000',
212
+ '025000001_025500000',
213
+ '025500001_026000000',
214
+ '026000001_026500000',
215
+ '026500001_027000000',
216
+ '027000001_027500000',
217
+ '027500001_028000000',
218
+ '028000001_028500000',
219
+ '028500001_029000000',
220
+ '029000001_029500000',
221
+ '029500001_030000000',
222
+ '030000001_030500000',
223
+ '030500001_031000000',
224
+ '031000001_031500000',
225
+ '031500001_032000000',
226
+ '032000001_032500000',
227
+ '032500001_033000000',
228
+ '033000001_033500000',
229
+ '033500001_034000000',
230
+ '034000001_034500000',
231
+ '034500001_035000000',
232
+ '035000001_035500000',
233
+ '035500001_036000000',
234
+ '036000001_036500000',
235
+ '036500001_037000000',
236
+ '037000001_037500000',
237
+ '037500001_038000000',
238
+ '038000001_038500000',
239
+ '038500001_039000000',
240
+ '039000001_039500000',
241
+ '039500001_040000000',
242
+ '040000001_040500000',
243
+ '040500001_041000000',
244
+ '041000001_041500000',
245
+ '041500001_042000000',
246
+ '042000001_042500000',
247
+ '042500001_043000000',
248
+ '043000001_043500000',
249
+ '043500001_044000000',
250
+ '044000001_044500000',
251
+ '044500001_045000000',
252
+ '045000001_045500000',
253
+ '045500001_046000000',
254
+ '046000001_046500000',
255
+ '046500001_047000000',
256
+ '047000001_047500000',
257
+ '047500001_048000000',
258
+ '048000001_048500000',
259
+ '048500001_049000000',
260
+ '049000001_049500000',
261
+ '049500001_050000000',
262
+ '050000001_050500000',
263
+ '050500001_051000000',
264
+ '051000001_051500000',
265
+ '051500001_052000000',
266
+ '052000001_052500000',
267
+ '052500001_053000000',
268
+ '053000001_053500000',
269
+ '053500001_054000000',
270
+ '054000001_054500000',
271
+ '054500001_055000000',
272
+ '055000001_055500000',
273
+ '055500001_056000000',
274
+ '056000001_056500000',
275
+ '056500001_057000000',
276
+ '057000001_057500000',
277
+ '057500001_058000000',
278
+ '058000001_058500000',
279
+ '058500001_059000000',
280
+ '059000001_059500000',
281
+ '059500001_060000000',
282
+ '060000001_060500000',
283
+ '060500001_061000000',
284
+ '061000001_061500000',
285
+ '061500001_062000000',
286
+ '062000001_062500000',
287
+ '062500001_063000000',
288
+ '063000001_063500000',
289
+ '063500001_064000000',
290
+ '064000001_064500000',
291
+ '064500001_065000000',
292
+ '065000001_065500000',
293
+ '065500001_066000000',
294
+ '066000001_066500000',
295
+ '066500001_067000000',
296
+ '067000001_067500000',
297
+ '067500001_068000000',
298
+ '068000001_068500000',
299
+ '068500001_069000000',
300
+ '069000001_069500000',
301
+ '069500001_070000000',
302
+ '070000001_070500000',
303
+ '070500001_071000000',
304
+ '071000001_071500000',
305
+ '071500001_072000000',
306
+ '072000001_072500000',
307
+ '072500001_073000000',
308
+ '073000001_073500000',
309
+ '073500001_074000000',
310
+ '074000001_074500000',
311
+ '074500001_075000000',
312
+ '075000001_075500000',
313
+ '075500001_076000000',
314
+ '076000001_076500000',
315
+ '076500001_077000000',
316
+ '077000001_077500000',
317
+ '077500001_078000000',
318
+ '078000001_078500000',
319
+ '078500001_079000000',
320
+ '079000001_079500000',
321
+ '079500001_080000000',
322
+ '080000001_080500000',
323
+ '080500001_081000000',
324
+ '081000001_081500000',
325
+ '081500001_082000000',
326
+ '082000001_082500000',
327
+ '082500001_083000000',
328
+ '083000001_083500000',
329
+ '083500001_084000000',
330
+ '084000001_084500000',
331
+ '084500001_085000000',
332
+ '085000001_085500000',
333
+ '085500001_086000000',
334
+ '086000001_086500000',
335
+ '086500001_087000000',
336
+ '087000001_087500000',
337
+ '087500001_088000000',
338
+ '088000001_088500000',
339
+ '088500001_089000000',
340
+ '089000001_089500000',
341
+ '089500001_090000000',
342
+ '090000001_090500000',
343
+ '090500001_091000000',
344
+ '091000001_091500000',
345
+ '091500001_092000000',
346
+ '092000001_092500000',
347
+ '092500001_093000000',
348
+ '093000001_093500000',
349
+ '093500001_094000000',
350
+ '094000001_094500000',
351
+ '094500001_095000000',
352
+ '095000001_095500000',
353
+ '095500001_096000000',
354
+ '096000001_096500000',
355
+ '096500001_097000000',
356
+ '097000001_097500000',
357
+ '097500001_098000000',
358
+ '098000001_098500000',
359
+ '098500001_099000000',
360
+ '099000001_099500000',
361
+ '099500001_100000000',
362
+ '100000001_100500000',
363
+ '100500001_101000000',
364
+ '101000001_101500000',
365
+ '101500001_102000000',
366
+ '102000001_102500000',
367
+ '102500001_103000000',
368
+ '103000001_103500000',
369
+ '103500001_104000000',
370
+ '104000001_104500000',
371
+ '104500001_105000000',
372
+ '105000001_105500000',
373
+ '105500001_106000000',
374
+ '106000001_106500000',
375
+ '106500001_107000000',
376
+ '107000001_107500000',
377
+ '107500001_108000000',
378
+ '108000001_108500000',
379
+ '108500001_109000000',
380
+ '109000001_109500000',
381
+ '109500001_110000000',
382
+ '110000001_110500000',
383
+ '110500001_111000000',
384
+ '111000001_111500000',
385
+ '111500001_112000000',
386
+ '112000001_112500000',
387
+ '112500001_113000000',
388
+ '113000001_113500000',
389
+ '113500001_114000000',
390
+ '114000001_114500000',
391
+ '114500001_115000000',
392
+ '115000001_115500000',
393
+ '115500001_116000000',
394
+ '116000001_116500000',
395
+ '116500001_117000000',
396
+ '117000001_117500000',
397
+ '117500001_118000000',
398
+ '118000001_118500000',
399
+ '118500001_119000000',
400
+ '119000001_119500000',
401
+ '119500001_120000000',
402
+ '120000001_120500000',
403
+ '120500001_121000000',
404
+ '121000001_121500000',
405
+ '121500001_122000000',
406
+ '122000001_122500000',
407
+ '122500001_123000000',
408
+ '123000001_123500000',
409
+ '123500001_124000000',
410
+ '124000001_124500000',
411
+ '124500001_125000000',
412
+ '125000001_125500000',
413
+ '125500001_126000000',
414
+ '126000001_126500000',
415
+ '126500001_127000000',
416
+ '127000001_127500000',
417
+ '127500001_128000000',
418
+ '128000001_128500000',
419
+ '128500001_129000000',
420
+ '129000001_129500000',
421
+ '129500001_130000000',
422
+ '130000001_130500000',
423
+ '130500001_131000000',
424
+ '131000001_131500000',
425
+ '131500001_132000000',
426
+ '132000001_132500000',
427
+ '132500001_133000000',
428
+ '133000001_133500000',
429
+ '133500001_134000000',
430
+ '134000001_134500000',
431
+ '134500001_135000000',
432
+ '135000001_135500000',
433
+ '135500001_136000000',
434
+ '136000001_136500000',
435
+ '136500001_137000000',
436
+ '137000001_137500000',
437
+ '137500001_138000000',
438
+ '138000001_138500000',
439
+ '138500001_139000000',
440
+ '139000001_139500000',
441
+ '139500001_140000000',
442
+ '140000001_140500000',
443
+ '140500001_141000000',
444
+ '141000001_141500000',
445
+ '141500001_142000000',
446
+ '142000001_142500000',
447
+ '142500001_143000000',
448
+ '143000001_143500000',
449
+ '143500001_144000000',
450
+ '144000001_144500000',
451
+ '144500001_145000000',
452
+ '145000001_145500000',
453
+ '145500001_146000000',
454
+ '146000001_146500000',
455
+ '146500001_147000000',
456
+ '147000001_147500000',
457
+ '147500001_148000000',
458
+ '148000001_148500000',
459
+ '148500001_149000000',
460
+ '149000001_149500000',
461
+ '149500001_150000000',
462
+ '150000001_150500000',
463
+ '150500001_151000000',
464
+ '151000001_151500000',
465
+ '151500001_152000000',
466
+ '152000001_152500000',
467
+ '152500001_153000000',
468
+ '153000001_153500000',
469
+ '153500001_154000000',
470
+ '154000001_154500000',
471
+ '154500001_155000000',
472
+ '155000001_155500000',
473
+ '155500001_156000000',
474
+ '156000001_156500000',
475
+ '156500001_157000000',
476
+ '157000001_157500000',
477
+ '157500001_158000000',
478
+ '158000001_158500000',
479
+ '158500001_159000000',
480
+ '159000001_159500000',
481
+ '159500001_160000000',
482
+ '160000001_160500000',
483
+ '160500001_161000000',
484
+ '161000001_161500000',
485
+ '161500001_162000000',
486
+ '162000001_162500000',
487
+ '162500001_163000000',
488
+ '163000001_163500000',
489
+ '163500001_164000000',
490
+ '164000001_164500000',
491
+ '164500001_165000000',
492
+ '165000001_165500000',
493
+ '165500001_166000000',
494
+ '166000001_166500000',
495
+ '166500001_167000000',
496
+ '167000001_167500000',
497
+ '167500001_168000000',
498
+ '168000001_168500000',
499
+ '168500001_169000000',
500
+ '169000001_169500000',
501
+ '169500001_170000000',
502
+ '170000001_170500000',
503
+ '170500001_171000000',
504
+ '171000001_171500000',
505
+ '171500001_172000000',
506
+ '172000001_172500000'
507
+ ]
508
+
509
+
510
+ class PubChemConfig(datasets.BuilderConfig):
511
+ """
512
+ Configuration class for the PubChem dataset.
513
+ Args:
514
+ features (dict): A dictionary specifying the features of the dataset.
515
+ data_url (str): The URL to download the dataset.
516
+ url (str): The URL to the dataset homepage.
517
+ citation (str): The citation for the dataset.
518
+ **kwargs: Additional keyword arguments.
519
+ Attributes:
520
+ version (datasets.Version): The version of the dataset.
521
+ """
522
+
523
+ def __init__(self, features, url, citation, id_range, **kwargs):
524
+ super(PubChemConfig, self).__init__(
525
+ version=datasets.Version("0.0.0"), **kwargs
526
+ )
527
+ self.features = features
528
+ self.url = url
529
+ self.citation = citation
530
+ self.id_range = id_range
531
+
532
+
533
+ class PubChem(datasets.GeneratorBasedBuilder):
534
+
535
+ BUILDER_CONFIG_CLASS = PubChemConfig
536
+
537
+ DEFAULT_CONFIG_NAME = "pubchem-10-15-2024-selfies"
538
+
539
+ VERSION = datasets.Version("0.0.0")
540
+
541
+ url = "https://huggingface.co/datasets/molssiai-hub/pubchem-10-15-2024-selfies"
542
+
543
+ BUILDER_CONFIGS = [
544
+ PubChemConfig(
545
+ name="pubchem-10-15-2024-selfies",
546
+ description=_DESCRIPTION,
547
+ features=_FEATURE_KEYS,
548
+ url=url,
549
+ citation=_CITATION,
550
+ id_range=_ID_RANGES,
551
+ )
552
+ ]
553
+
554
+ def _info(self):
555
+ if self.config.name in _CONFIG_NAMES:
556
+ features = _FEATURE_TYPES
557
+ else:
558
+ raise NotImplementedError("Unknown configuration in _info")
559
+
560
+ return datasets.DatasetInfo(
561
+ description=_DESCRIPTION,
562
+ features=features,
563
+ homepage=_HOMEPAGE,
564
+ supervised_keys=None,
565
+ license=_LICENSE,
566
+ citation=_CITATION,
567
+ )
568
+
569
+ def _split_generators(self, dl_manager):
570
+ if self.config.name in _CONFIG_NAMES:
571
+ file_list = []
572
+ for range in self.config.id_range:
573
+ file_list.append(_BASE_DATA_URL_FORMAT_STR.format(
574
+ name=self.config.name, range=range))
575
+ else:
576
+ raise NotImplementedError(
577
+ "Unknown configuration in _split_generators")
578
+
579
+ return [
580
+ datasets.SplitGenerator(
581
+ name=datasets.Split.TRAIN,
582
+ gen_kwargs={
583
+ "filepaths": dl_manager.download(sorted(file_list)),
584
+ },
585
+ )
586
+ ]
587
+
588
+ def _generate_examples(self, filepaths):
589
+ if self.config.name in _CONFIG_NAMES:
590
+ idx = 0
591
+ for filepath in filepaths:
592
+ with open(filepath, "rb") as f:
593
+ items = ijson.items(f, "item", use_float=True)
594
+ for data in items:
595
+ yield idx, data
596
+ idx += 1
597
+ else:
598
+ raise NotImplementedError(
599
+ "Unknown configuration in _generate_examples")