hdallatorre commited on
Commit
19ce63e
·
1 Parent(s): f22553f

feat: Add deepstarr dataset

Browse files
.gitattributes CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ *.fna filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ---
2
+ # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/datasetcard.md?plain=1
3
+ # Doc / guide: https://huggingface.co/docs/hub/datasets-cards
4
+ {}
5
+ ---
6
+
7
+
deepstarr/test.fna ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40fbc405ea0041cabd82946fb6486f6b2835e3f75246b8a9c9225a3fffb84d73
3
+ size 16498412
deepstarr/train.fna ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afdd362a17bae77f1d7e4ba87a8b8fe2bb7a533b2bce14a67c153ac991d8e80c
3
+ size 160497156
nucleotide_transformer_downstream_tasks_multilabel.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script
2
+ # contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Script for the dataset containing the "promoter_all" and "enhancers" downstream tasks from the Nucleotide
16
+ Transformer paper."""
17
+
18
+ from typing import List
19
+
20
+ import datasets
21
+ from Bio import SeqIO
22
+
23
+ # Find for instance the citation on arxiv or on the dataset repo/website
24
+ _CITATION = """\
25
+ @article{dalla2023nucleotide,
26
+ title={The Nucleotide Transformer: Building and Evaluating Robust Foundation Models for Human Genomics},
27
+ author={Dalla-Torre, Hugo and Gonzalez, Liam and Mendoza-Revilla, Javier and Carranza, Nicolas Lopez and Grzywaczewski, Adam Henryk and Oteri, Francesco and Dallago, Christian and Trop, Evan and Sirelkhatim, Hassan and Richard, Guillaume and others},
28
+ journal={bioRxiv},
29
+ pages={2023--01},
30
+ year={2023},
31
+ publisher={Cold Spring Harbor Laboratory}
32
+ }
33
+ """
34
+
35
+ # You can copy an official description
36
+ _DESCRIPTION = """\
37
+ Multilabel datasets used in the Nucleotide Transformer paper.
38
+ """
39
+
40
+ _HOMEPAGE = "https://github.com/instadeepai/nucleotide-transformer"
41
+
42
+ _LICENSE = "https://github.com/instadeepai/nucleotide-transformer/LICENSE.md"
43
+
44
+ _TASKS = [
45
+ "deepstarr",
46
+ ]
47
+
48
+
49
+ class NucleotideTransformerDownstreamTasksConfig(datasets.BuilderConfig):
50
+ """BuilderConfig for The Nucleotide Transformer downstream taks dataset."""
51
+
52
+ def __init__(self, *args, task: str, **kwargs):
53
+ """BuilderConfig downstream tasks dataset.
54
+ Args:
55
+ task (:obj:`str`): Task name.
56
+ **kwargs: keyword arguments forwarded to super.
57
+ """
58
+ super().__init__(
59
+ *args,
60
+ name=f"{task}",
61
+ **kwargs,
62
+ )
63
+ self.task = task
64
+
65
+
66
+ class NucleotideTransformerDownstreamTasks(datasets.GeneratorBasedBuilder):
67
+ VERSION = datasets.Version("1.1.0")
68
+ BUILDER_CONFIG_CLASS = NucleotideTransformerDownstreamTasksConfig
69
+ BUILDER_CONFIGS = [
70
+ NucleotideTransformerDownstreamTasksConfig(task=task) for task in _TASKS
71
+ ]
72
+ DEFAULT_CONFIG_NAME = "deepstarr"
73
+
74
+ def _info(self):
75
+
76
+ features = datasets.Features(
77
+ {
78
+ "sequence": datasets.Value("string"),
79
+ "name": datasets.Value("string"),
80
+ "labels": datasets.Sequence(
81
+ feature={"label": datasets.Value(dtype="float32", id=None)}
82
+ ),
83
+ }
84
+ )
85
+ return datasets.DatasetInfo(
86
+ # This is the description that will appear on the datasets page.
87
+ description=_DESCRIPTION,
88
+ # This defines the different columns of the dataset and their types
89
+ features=features,
90
+ # Homepage of the dataset for documentation
91
+ homepage=_HOMEPAGE,
92
+ # License for the dataset if available
93
+ license=_LICENSE,
94
+ # Citation for the dataset
95
+ citation=_CITATION,
96
+ )
97
+
98
+ def _split_generators(
99
+ self, dl_manager: datasets.DownloadManager
100
+ ) -> List[datasets.SplitGenerator]:
101
+
102
+ train_file = dl_manager.download_and_extract(self.config.task + "/train.fna")
103
+ test_file = dl_manager.download_and_extract(self.config.task + "/test.fna")
104
+
105
+ return [
106
+ datasets.SplitGenerator(
107
+ name=datasets.Split.TRAIN, gen_kwargs={"file": train_file}
108
+ ),
109
+ datasets.SplitGenerator(
110
+ name=datasets.Split.TEST, gen_kwargs={"file": test_file}
111
+ ),
112
+ ]
113
+
114
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
115
+ def _generate_examples(self, file):
116
+ key = 0
117
+ with open(file, "rt") as f:
118
+ fasta_sequences = SeqIO.parse(f, "fasta")
119
+
120
+ for record in fasta_sequences:
121
+
122
+ # parse descriptions in the fasta file
123
+ sequence, name = str(record.seq), str(record.name)
124
+ labels = [float(label) for label in name.split("|")[1:]]
125
+
126
+ # yield example
127
+ yield key, {
128
+ "sequence": sequence,
129
+ "name": name,
130
+ "labels": labels,
131
+ }
132
+ key += 1