Convert dataset to Parquet

#1
README.md CHANGED
@@ -10,6 +10,207 @@ tags:
10
  pretty_name: SaganMC
11
  size_categories:
12
  - 100K<n<1M
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
  # SaganMC: A Molecular Complexity Dataset with Mass Spectra
15
 
 
10
  pretty_name: SaganMC
11
  size_categories:
12
  - 100K<n<1M
13
+ dataset_info:
14
+ - config_name: sagan-mc-400k
15
+ features:
16
+ - name: inchi
17
+ dtype: string
18
+ - name: inchikey
19
+ dtype: string
20
+ - name: selfies
21
+ dtype: string
22
+ - name: smiles
23
+ dtype: string
24
+ - name: smiles_scaffold
25
+ dtype: string
26
+ - name: formula
27
+ dtype: string
28
+ - name: fingerprint_morgan
29
+ dtype: string
30
+ - name: num_atoms
31
+ dtype: int32
32
+ - name: num_atoms_all
33
+ dtype: int32
34
+ - name: num_bonds
35
+ dtype: int32
36
+ - name: num_bonds_all
37
+ dtype: int32
38
+ - name: num_rings
39
+ dtype: int32
40
+ - name: num_aromatic_rings
41
+ dtype: int32
42
+ - name: physchem_mol_weight
43
+ dtype: float32
44
+ - name: physchem_logp
45
+ dtype: float32
46
+ - name: physchem_tpsa
47
+ dtype: float32
48
+ - name: physchem_qed
49
+ dtype: float32
50
+ - name: physchem_h_acceptors
51
+ dtype: int32
52
+ - name: physchem_h_donors
53
+ dtype: int32
54
+ - name: physchem_rotatable_bonds
55
+ dtype: int32
56
+ - name: physchem_fraction_csp3
57
+ dtype: float32
58
+ - name: mass_spectrum_nist
59
+ dtype: string
60
+ - name: complex_ma_score
61
+ dtype: int32
62
+ - name: complex_ma_runtime
63
+ dtype: float32
64
+ - name: complex_bertz_score
65
+ dtype: float32
66
+ - name: complex_bertz_runtime
67
+ dtype: float32
68
+ - name: complex_boettcher_score
69
+ dtype: float32
70
+ - name: complex_boettcher_runtime
71
+ dtype: float32
72
+ - name: synth_sa_score
73
+ dtype: float32
74
+ - name: meta_cas_number
75
+ dtype: string
76
+ - name: meta_names
77
+ dtype: string
78
+ - name: meta_iupac_name
79
+ dtype: string
80
+ - name: meta_comment
81
+ dtype: string
82
+ - name: meta_origin
83
+ dtype: string
84
+ - name: meta_reference
85
+ dtype: string
86
+ - name: split
87
+ dtype:
88
+ class_label:
89
+ names:
90
+ '0': train
91
+ '1': val
92
+ '2': test
93
+ splits:
94
+ - name: train
95
+ num_bytes: 262218794
96
+ num_examples: 325392
97
+ - name: validation
98
+ num_bytes: 32619164
99
+ num_examples: 40521
100
+ - name: test
101
+ num_bytes: 32805389
102
+ num_examples: 40533
103
+ download_size: 121350317
104
+ dataset_size: 327643347
105
+ - config_name: sagan-mc-spectra-16k
106
+ features:
107
+ - name: inchi
108
+ dtype: string
109
+ - name: inchikey
110
+ dtype: string
111
+ - name: selfies
112
+ dtype: string
113
+ - name: smiles
114
+ dtype: string
115
+ - name: smiles_scaffold
116
+ dtype: string
117
+ - name: formula
118
+ dtype: string
119
+ - name: fingerprint_morgan
120
+ dtype: string
121
+ - name: num_atoms
122
+ dtype: int32
123
+ - name: num_atoms_all
124
+ dtype: int32
125
+ - name: num_bonds
126
+ dtype: int32
127
+ - name: num_bonds_all
128
+ dtype: int32
129
+ - name: num_rings
130
+ dtype: int32
131
+ - name: num_aromatic_rings
132
+ dtype: int32
133
+ - name: physchem_mol_weight
134
+ dtype: float32
135
+ - name: physchem_logp
136
+ dtype: float32
137
+ - name: physchem_tpsa
138
+ dtype: float32
139
+ - name: physchem_qed
140
+ dtype: float32
141
+ - name: physchem_h_acceptors
142
+ dtype: int32
143
+ - name: physchem_h_donors
144
+ dtype: int32
145
+ - name: physchem_rotatable_bonds
146
+ dtype: int32
147
+ - name: physchem_fraction_csp3
148
+ dtype: float32
149
+ - name: mass_spectrum_nist
150
+ dtype: string
151
+ - name: complex_ma_score
152
+ dtype: int32
153
+ - name: complex_ma_runtime
154
+ dtype: float32
155
+ - name: complex_bertz_score
156
+ dtype: float32
157
+ - name: complex_bertz_runtime
158
+ dtype: float32
159
+ - name: complex_boettcher_score
160
+ dtype: float32
161
+ - name: complex_boettcher_runtime
162
+ dtype: float32
163
+ - name: synth_sa_score
164
+ dtype: float32
165
+ - name: meta_cas_number
166
+ dtype: string
167
+ - name: meta_names
168
+ dtype: string
169
+ - name: meta_iupac_name
170
+ dtype: string
171
+ - name: meta_comment
172
+ dtype: string
173
+ - name: meta_origin
174
+ dtype: string
175
+ - name: meta_reference
176
+ dtype: string
177
+ - name: split
178
+ dtype:
179
+ class_label:
180
+ names:
181
+ '0': train
182
+ '1': val
183
+ '2': test
184
+ splits:
185
+ - name: train
186
+ num_bytes: 31175057
187
+ num_examples: 13297
188
+ - name: validation
189
+ num_bytes: 3829030
190
+ num_examples: 1634
191
+ - name: test
192
+ num_bytes: 4067843
193
+ num_examples: 1722
194
+ download_size: 17763908
195
+ dataset_size: 39071930
196
+ configs:
197
+ - config_name: sagan-mc-400k
198
+ data_files:
199
+ - split: train
200
+ path: sagan-mc-400k/train-*
201
+ - split: validation
202
+ path: sagan-mc-400k/validation-*
203
+ - split: test
204
+ path: sagan-mc-400k/test-*
205
+ default: true
206
+ - config_name: sagan-mc-spectra-16k
207
+ data_files:
208
+ - split: train
209
+ path: sagan-mc-spectra-16k/train-*
210
+ - split: validation
211
+ path: sagan-mc-spectra-16k/validation-*
212
+ - split: test
213
+ path: sagan-mc-spectra-16k/test-*
214
  ---
215
  # SaganMC: A Molecular Complexity Dataset with Mass Spectra
216
 
sagan-mc-spectra-16k.csv → sagan-mc-400k/test-00000-of-00001.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c13e984d9f6f75c7432b37b67ee7025456a4ac0e404690928d029cfc6bfee350
3
- size 40237369
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1dcb5598cdcf1a7628941f36197be5323bf6d559840f7f28f05954a074cb9f8f
3
+ size 12187096
sagan-mc-400k.csv → sagan-mc-400k/train-00000-of-00001.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:01039ed6435e02beec5e90cc13c85d37ba56fdf32a2275f900e1ece2553b454c
3
- size 356803750
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d915240d6646a5307b81e71c0c9a0beb2a1a18af7979068bd8ff343dc74bd263
3
+ size 97073154
sagan-mc-400k/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2c6c711949e4d7ec8608029c7bcf2ccc1b5f4e7379f92c085d2acfb489b78d9
3
+ size 12090067
sagan-mc-spectra-16k/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f37d79d7c857941db7e40cfe17d2a9db65890555f52308281e2be1986443e77
3
+ size 1865086
sagan-mc-spectra-16k/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a34bca85f946ba882c9e73eb756bd9c3a36e1fd6294d88f3c023a719ae86dec
3
+ size 14140579
sagan-mc-spectra-16k/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c35234c9839c99a3957030279669f980e9ede34be3be881d570c842be63e43e
3
+ size 1758243
sagan-mc.py DELETED
@@ -1,117 +0,0 @@
1
- import csv
2
- import json
3
- import os
4
- import datasets
5
-
6
- _CITATION = """
7
- @inproceedings{gebhard2022inferring,
8
- title={Inferring molecular complexity from mass spectrometry data using machine learning},
9
- author={Gebhard, Timothy D and Bell, Aaron C and Gong, Jian and Hastings, Jaden J. A. and Fricke, G. Matthew and Cabrol, Nathalie and Sandford, Scott and Phillips, Michael and Warren-Rhodes, Kimberley and Baydin, Atilim Gunes},
10
- booktitle={NeurIPS Workshop on Machine Learning and the Physical Sciences},
11
- year={2022}
12
- }
13
- """
14
-
15
- _DESCRIPTION = """
16
- SaganMC is a molecular dataset designed to support machine learning research in molecular complexity inference. It includes over 400,000 molecules with computed structural, physico-chemical, and complexity descriptors, and a subset of ~16k molecules that additionally include experimental mass spectra.
17
- """
18
-
19
- _HOMEPAGE = "https://huggingface.co/datasets/oxai4science/sagan-mc"
20
- _LICENSE = "CC-BY-4.0"
21
-
22
- _URLS = {
23
- "sagan-mc-400k": "https://huggingface.co/datasets/oxai4science/sagan-mc/resolve/main/sagan-mc-400k.csv",
24
- "sagan-mc-spectra-16k": "https://huggingface.co/datasets/oxai4science/sagan-mc/resolve/main/sagan-mc-spectra-16k.csv",
25
- }
26
-
27
- class SaganMC(datasets.GeneratorBasedBuilder):
28
- VERSION = datasets.Version("1.0.0")
29
-
30
- BUILDER_CONFIGS = [
31
- datasets.BuilderConfig(name="sagan-mc-400k", version=VERSION, description="Full dataset with ~400k molecules"),
32
- datasets.BuilderConfig(name="sagan-mc-spectra-16k", version=VERSION, description="Subset with mass spectra (~16k molecules)"),
33
- ]
34
-
35
- DEFAULT_CONFIG_NAME = "sagan-mc-400k"
36
-
37
- def _info(self):
38
- features = datasets.Features({
39
- "inchi": datasets.Value("string"),
40
- "inchikey": datasets.Value("string"),
41
- "selfies": datasets.Value("string"),
42
- "smiles": datasets.Value("string"),
43
- "smiles_scaffold": datasets.Value("string"),
44
- "formula": datasets.Value("string"),
45
- "fingerprint_morgan": datasets.Value("string"),
46
- "num_atoms": datasets.Value("int32"),
47
- "num_atoms_all": datasets.Value("int32"),
48
- "num_bonds": datasets.Value("int32"),
49
- "num_bonds_all": datasets.Value("int32"),
50
- "num_rings": datasets.Value("int32"),
51
- "num_aromatic_rings": datasets.Value("int32"),
52
- "physchem_mol_weight": datasets.Value("float"),
53
- "physchem_logp": datasets.Value("float"),
54
- "physchem_tpsa": datasets.Value("float"),
55
- "physchem_qed": datasets.Value("float"),
56
- "physchem_h_acceptors": datasets.Value("int32"),
57
- "physchem_h_donors": datasets.Value("int32"),
58
- "physchem_rotatable_bonds": datasets.Value("int32"),
59
- "physchem_fraction_csp3": datasets.Value("float"),
60
- "mass_spectrum_nist": datasets.Value("string"),
61
- "complex_ma_score": datasets.Value("int32"),
62
- "complex_ma_runtime": datasets.Value("float"),
63
- "complex_bertz_score": datasets.Value("float"),
64
- "complex_bertz_runtime": datasets.Value("float"),
65
- "complex_boettcher_score": datasets.Value("float"),
66
- "complex_boettcher_runtime": datasets.Value("float"),
67
- "synth_sa_score": datasets.Value("float"),
68
- "meta_cas_number": datasets.Value("string"),
69
- "meta_names": datasets.Value("string"),
70
- "meta_iupac_name": datasets.Value("string"),
71
- "meta_comment": datasets.Value("string"),
72
- "meta_origin": datasets.Value("string"),
73
- "meta_reference": datasets.Value("string"),
74
- "split": datasets.ClassLabel(names=["train", "val", "test"])
75
- })
76
- return datasets.DatasetInfo(
77
- description=_DESCRIPTION,
78
- features=features,
79
- homepage=_HOMEPAGE,
80
- license=_LICENSE,
81
- citation=_CITATION,
82
- )
83
-
84
- def _split_generators(self, dl_manager):
85
- url = _URLS[self.config.name]
86
- data_path = dl_manager.download_and_extract(url)
87
- return [
88
- datasets.SplitGenerator(
89
- name=datasets.Split.TRAIN,
90
- gen_kwargs={"filepath": data_path, "split_name": "train"},
91
- ),
92
- datasets.SplitGenerator(
93
- name=datasets.Split.VALIDATION,
94
- gen_kwargs={"filepath": data_path, "split_name": "val"},
95
- ),
96
- datasets.SplitGenerator(
97
- name=datasets.Split.TEST,
98
- gen_kwargs={"filepath": data_path, "split_name": "test"},
99
- ),
100
- ]
101
-
102
- def _generate_examples(self, filepath, split_name):
103
- numeric_fields = [
104
- "num_atoms", "num_atoms_all", "num_bonds", "num_bonds_all", "num_rings", "num_aromatic_rings",
105
- "physchem_mol_weight", "physchem_logp", "physchem_tpsa", "physchem_qed",
106
- "physchem_h_acceptors", "physchem_h_donors", "physchem_rotatable_bonds", "physchem_fraction_csp3",
107
- "complex_ma_score", "complex_ma_runtime", "complex_bertz_score", "complex_bertz_runtime",
108
- "complex_boettcher_score", "complex_boettcher_runtime", "synth_sa_score"
109
- ]
110
- with open(filepath, encoding="utf-8") as f:
111
- reader = csv.DictReader(f)
112
- for idx, row in enumerate(reader):
113
- if row["split"] == split_name:
114
- for field in numeric_fields:
115
- if field in row and row[field] == "":
116
- row[field] = None
117
- yield idx, row