File size: 2,112 Bytes
3b416a3
 
 
 
 
 
 
73477fb
3b416a3
a15bf60
88699e2
c8f2584
3b416a3
 
88699e2
3b416a3
88699e2
3b416a3
 
1f225f3
3b416a3
 
 
 
 
 
289235c
f4717e7
 
3b416a3
 
 
 
 
 
1f225f3
f4717e7
 
a15bf60
02e1a45
1f225f3
02e1a45
3b416a3
 
 
 
 
 
 
ee027c7
 
 
 
73477fb
ee027c7
f4717e7
 
3b416a3
 
 
 
88699e2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import datasets


logger = datasets.logging.get_logger(__name__)

ID_POOL = ()
URL = "https://huggingface.co/datasets/thewall/DeepBindWeight/resolve/main"


class DeepBindWeightConfig(datasets.BuilderConfig):
    pass


class DeepBindWeight(datasets.GeneratorBasedBuilder):
    BUILDER_CONFIGS = [
        DeepBindWeightConfig(name=key) for key in ID_POOL
    ]

    DEFAULT_CONFIG_NAME = "params"

    def _info(self):
        return datasets.DatasetInfo(
            features=datasets.Features(
                {
                    "config": datasets.Value("string"),
                    "existed": datasets.Value("bool"),
                    "selex": datasets.Value("string"),
                    "tf": datasets.Value("string")
                }
            ),
            homepage="http://tools.genes.toronto.edu/deepbind",
        )

    def _split_generators(self, dl_manager):
        param_url = f"{URL}/params.tar.gz"
        selex_url = f"{URL}/ERP001824-deepbind.xlsx"
        tf_url = f"{URL}/ERP001824-UniprotKB.xlsx"
        aptani2_url = f"{URL}/aptani2_config.tar.gz"
        downloaded_files = [os.path.join(f"{dl_manager.download_and_extract(param_url)}", "params")]
        downloaded_files.extend(dl_manager.download([selex_url, tf_url]))
        downloaded_files.append(f"{dl_manager.download_and_extract(aptani2_url)}")
        return [
            datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}),
        ]

    def _generate_examples(self, filepath):
        """This function returns the examples in the raw (text) form."""
        logger.info("generating examples from = %s", filepath)
        flag = True
        for file in filepath:
            flag = flag and os.path.exists(file)
        
        yield 0, {"config": filepath[0],
                  "existed": flag,
                  "selex": filepath[1],
                  'tf': filepath[2]}


if __name__=="__main__":
    from datasets import load_dataset
    dataset = load_dataset("thewall/deepbindweight", split="all")
    # dataset.push_to_hub("thewall/DeepBindWeight")