|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import json |
|
import random |
|
|
|
import datasets |
|
|
|
|
|
_DESCRIPTION = """\ |
|
A dataset of all autosomal and sex chromosomes sequences from reference assembly GRCh38/hg38 1 and reached a total of 3.2 billion nucleotides. |
|
""" |
|
|
|
_HOMEPAGE = "https://www.ncbi.nlm.nih.gov/assembly/GCF_000001405.26" |
|
|
|
FILES = ["intervals.jsonl"] |
|
|
|
class PubchemSelfies(datasets.GeneratorBasedBuilder): |
|
"""A dataset of all autosomal and sex chromosomes sequences from reference assembly GRCh38/hg38 and reached a total of 3.2 billion nucleotides.""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
|
|
BUILDER_CONFIG = datasets.BuilderConfig( |
|
version=VERSION, description="A dataset of all autosomal and sex chromosomes sequences from reference assembly GRCh38/hg38 and reached a total of 3.2 billion nucleotides." |
|
) |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=datasets.Features( |
|
{ |
|
"chr": datasets.Value("string"), |
|
"description": datasets.Value("string"), |
|
"seq": datasets.Value("string"), |
|
"split": datasets.Value("string"), |
|
} |
|
), |
|
|
|
homepage=_HOMEPAGE, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
downloaded_files = dl_manager.download(FILES) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filename": downloaded_files[0] |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filename): |
|
|
|
with open(filename) as jsonl_file: |
|
for row, line in enumerate(jsonl_file): |
|
data = json.loads(line) |
|
|
|
|
|
|
|
split = "valid" if random.random() < 0.05 else "train" |
|
|
|
yield row, { |
|
"chr": data["chr"], |
|
"description": data["description"], |
|
"seq": data["seq"], |
|
"split": split, |
|
} |