smostafanejad commited on
Commit
93ab62f
·
verified ·
1 Parent(s): 10b8542

adds load script

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