epigenetic_marks_pham2005 / epigenetic_marks_pham2005.py
othertea's picture
First version of epigenetic_marks_pham2005 dataset
0ffadef
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO: Address all TODOs and remove all explanatory comments
"""TODO: Add a description here."""
import csv
import json
import os
import datasets
_CITATION = """\
@article{pham2005qualitatively,
title={Qualitatively predicting acetylation and methylation areas in dna sequences},
author={Pham, Tho Hoan and Tran, Dang Hung and Ho, Tu Bao and Satou, Kenji and Valiente, Gabriel},
journal={Genome Informatics},
volume={16},
number={2},
pages={3--11},
year={2005},
publisher={Japanese Society for Bioinformatics}
}
"""
_LICENSE = ""
_DESCRIPTION = """\
This contains datasets of histone occupancy, acetylation, and methylation by ChiP-Chip protocol in vivo from Pham et al., as retrieved from https://www.jaist.ac.jp/~tran/nucleosome/members.htm in January 2023.
"""
_HOMEPAGE = "https://www.jaist.ac.jp/~tran/nucleosome/"
FILES = {
"h3": [
"data/processed/h3/fold_0.csv",
"data/processed/h3/fold_1.csv",
"data/processed/h3/fold_2.csv",
],
"h3k14ac": [
"data/processed/h3k14ac/fold_0.csv",
"data/processed/h3k14ac/fold_1.csv",
"data/processed/h3k14ac/fold_2.csv",
],
"h3k36me3": [
"data/processed/h3k36me3/fold_0.csv",
"data/processed/h3k36me3/fold_1.csv",
"data/processed/h3k36me3/fold_2.csv",
],
"h3k4me1": [
"data/processed/h3k4me1/fold_0.csv",
"data/processed/h3k4me1/fold_1.csv",
"data/processed/h3k4me1/fold_2.csv",
],
"h3k4me2": [
"data/processed/h3k4me2/fold_0.csv",
"data/processed/h3k4me2/fold_1.csv",
"data/processed/h3k4me2/fold_2.csv",
],
"h3k79me3": [
"data/processed/h3k79me3/fold_0.csv",
"data/processed/h3k79me3/fold_1.csv",
"data/processed/h3k79me3/fold_2.csv",
],
"h3k9ac": [
"data/processed/h3k9ac/fold_0.csv",
"data/processed/h3k9ac/fold_1.csv",
"data/processed/h3k9ac/fold_2.csv",
],
"h4": [
"data/processed/h4/fold_0.csv",
"data/processed/h4/fold_1.csv",
"data/processed/h4/fold_2.csv",
],
}
class EpigeneticMarks(datasets.GeneratorBasedBuilder):
"""
This contains datasets of histone occupancy, acetylation, and methylation by ChiP-Chip protocol in vivo from Pham et al., as retrieved from https://www.jaist.ac.jp/~tran/nucleosome/members.htm in January 2023.
"""
VERSION = datasets.Version("0.0.1")
# data = datasets.load_dataset('my_dataset', 'first_domain')
# data = datasets.load_dataset('my_dataset', 'second_domain')
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="h3",
version=VERSION,
description="H3 occupancy",
),
datasets.BuilderConfig(
name="h4",
version=VERSION,
description="H4 occupancy",
),
datasets.BuilderConfig(
name="h3k9ac",
version=VERSION,
description="H3K9 acetylation relative to H3",
),
datasets.BuilderConfig(
name="h3k14ac",
version=VERSION,
description="H3K14 acetylation relative to H3",
),
# datasets.BuilderConfig(
# name="h4ac",
# version=VERSION,
# description="H4 acetylation relative to H3",
# ),
datasets.BuilderConfig(
name="h3k4me1",
version=VERSION,
description="H3K4 monomethylation relative to H3",
),
datasets.BuilderConfig(
name="h3k4me2",
version=VERSION,
description="H3K4 dimethylation relative to H3",
),
# datasets.BuilderConfig(
# name="h3k4me3",
# version=VERSION,
# description="H3K4 trimethylation relative to H3",
# ),
datasets.BuilderConfig(
name="h3k36me3",
version=VERSION,
description="H3K36 trimethylation relative to H3",
),
datasets.BuilderConfig(
name="h3k79me3",
version=VERSION,
description="H3K79 trimethylation relative to H3",
),
]
DEFAULT_CONFIG_NAME = "h3"
def _info(self):
features = datasets.Features(
{
"description": datasets.Value("string"),
"sequence": datasets.Value("string"),
"label": datasets.Value("int32"),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=("sequence", "label"),
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
dataset = self.config.name
downloaded_files = dl_manager.download(FILES[dataset])
return [
datasets.SplitGenerator(
name=datasets.NamedSplit("fold0"),
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": downloaded_files[0],
},
),
datasets.SplitGenerator(
name=datasets.NamedSplit("fold1"),
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": downloaded_files[1],
},
),
datasets.SplitGenerator(
name=datasets.NamedSplit("fold2"),
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": downloaded_files[2],
},
),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, filepath):
with open(filepath) as f:
reader = csv.DictReader(f)
for key, data in enumerate(reader):
yield key, {
"description": data["description"],
"sequence": data["sequence"],
"label": data["label"],
}