shaffei commited on
Commit
870b700
·
verified ·
1 Parent(s): bf2181f

Upload ppb_affinity.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ppb_affinity.py +48 -0
ppb_affinity.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import csv
3
+
4
+ class ppb_affinity(datasets.GeneratorBasedBuilder):
5
+ VERSION = datasets.Version("1.0.0")
6
+
7
+ BUILDER_CONFIGS = [
8
+ datasets.BuilderConfig(name="raw", description="Raw parsed PDBs dataset with critical filtrations only."),
9
+ datasets.BuilderConfig(name="filtered", description="Raw dataset with additional cleaning and train/val/test splits."),
10
+ ]
11
+
12
+ def _info(self):
13
+ return datasets.DatasetInfo()
14
+
15
+ def _split_generators(self, dl_manager):
16
+ if self.config.name == "raw":
17
+ filepath = dl_manager.download_and_extract("raw.csv")
18
+ return [datasets.SplitGenerator(
19
+ name=datasets.Split.TRAIN,
20
+ gen_kwargs={"filepath": filepath}
21
+ )]
22
+ else:
23
+ filepath = dl_manager.download_and_extract("filtered.csv")
24
+ return [
25
+ datasets.SplitGenerator(
26
+ name=datasets.Split.TRAIN,
27
+ gen_kwargs={"filepath": filepath, "split": "train"},
28
+ ),
29
+ datasets.SplitGenerator(
30
+ name=datasets.Split.VALIDATION,
31
+ gen_kwargs={"filepath": filepath, "split": "val"},
32
+ ),
33
+ datasets.SplitGenerator(
34
+ name=datasets.Split.TEST,
35
+ gen_kwargs={"filepath": filepath, "split": "test"},
36
+ ),
37
+ ]
38
+
39
+ def _generate_examples(self, filepath, split=None):
40
+ with open(filepath, encoding="utf-8") as f:
41
+ reader = csv.DictReader(f)
42
+ for idx, row in enumerate(reader):
43
+ if self.config.name == "raw":
44
+ yield idx, row
45
+ else:
46
+ if row["split"] == split:
47
+ del row["split"] # Remove split column from examples
48
+ yield idx, row