DeepBindWeight / deepbindweight.py
thewall's picture
Update deepbindweight.py
02e1a45
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")