Download ppb_affinity.py from proteinea/ppb_affinity: direct link, hf CLI and curl.
- Browser
- Download file 1.9 kB
-
https://huggingface.co/datasets/proteinea/ppb_affinity/resolve/8e3e3028b5256c89d867429c8709910d9a59ecaa/ppb_affinity.py
- Command line
-
hf download hf://datasets/proteinea/ppb_affinity@8e3e3028b5256c89d867429c8709910d9a59ecaa/ppb_affinity.py
-
curl -L -o ppb_affinity.py https://huggingface.co/datasets/proteinea/ppb_affinity/resolve/8e3e3028b5256c89d867429c8709910d9a59ecaa/ppb_affinity.py
1.9 kB
| import datasets | |
| import csv | |
| class ppb_affinity(datasets.GeneratorBasedBuilder): | |
| VERSION = datasets.Version("1.0.0") | |
| BUILDER_CONFIGS = [ | |
| datasets.BuilderConfig(name="raw", description="Raw parsed PDBs dataset with critical filtrations only."), | |
| datasets.BuilderConfig(name="filtered", description="Raw dataset with additional cleaning and train/val/test splits."), | |
| ] | |
| def _info(self): | |
| return datasets.DatasetInfo() | |
| def _split_generators(self, dl_manager): | |
| if self.config.name == "raw": | |
| filepath = dl_manager.download_and_extract("raw.csv") | |
| return [datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"filepath": filepath} | |
| )] | |
| else: | |
| filepath = dl_manager.download_and_extract("filtered.csv") | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"filepath": filepath, "split": "train"}, | |
| ), | |
| datasets.SplitGenerator( | |
| name=datasets.Split.VALIDATION, | |
| gen_kwargs={"filepath": filepath, "split": "val"}, | |
| ), | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TEST, | |
| gen_kwargs={"filepath": filepath, "split": "test"}, | |
| ), | |
| ] | |
| def _generate_examples(self, filepath, split=None): | |
| with open(filepath, encoding="utf-8") as f: | |
| reader = csv.DictReader(f) | |
| for idx, row in enumerate(reader): | |
| if self.config.name == "raw": | |
| yield idx, row | |
| else: | |
| if row["split"] == split: | |
| del row["split"] # Remove split column from examples | |
| yield idx, row | |