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