refactor: naming/task type
Browse files- agro-nt-tasks.py +31 -21
agro-nt-tasks.py
CHANGED
@@ -35,19 +35,23 @@ predicting regulatory features, RNA processing sites, and gene expression values
|
|
35 |
# TODO: Add the licence for the dataset here if you can find it
|
36 |
_LICENSE = ""
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
class AgroNtTasksConfig(datasets.BuilderConfig):
|
48 |
"""BuilderConfig for the Agro NT supervised learning tasks dataset."""
|
49 |
|
50 |
-
def __init__(self, *args,
|
51 |
"""BuilderConfig downstream tasks dataset.
|
52 |
Args:
|
53 |
task (:obj:`str`): Task name.
|
@@ -55,27 +59,31 @@ class AgroNtTasksConfig(datasets.BuilderConfig):
|
|
55 |
"""
|
56 |
super().__init__(
|
57 |
*args,
|
58 |
-
name=f"{
|
59 |
**kwargs,
|
60 |
)
|
61 |
-
self.task =
|
|
|
|
|
62 |
|
63 |
class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
64 |
"""GeneratorBasedBuilder for the Agro NT supervised learning tasks dataset."""
|
65 |
|
66 |
-
BUILDER_CONFIGS = [AgroNtTasksConfig(
|
|
|
67 |
|
68 |
-
DEFAULT_CONFIG_NAME =
|
69 |
|
70 |
def _info(self):
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
|
80 |
return datasets.DatasetInfo(
|
81 |
# This is the description that will appear on the datasets page.
|
@@ -90,8 +98,10 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
|
90 |
|
91 |
def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
|
92 |
|
93 |
-
train_file = dl_manager.download_and_extract(
|
94 |
-
|
|
|
|
|
95 |
|
96 |
return [
|
97 |
datasets.SplitGenerator(
|
|
|
35 |
# TODO: Add the licence for the dataset here if you can find it
|
36 |
_LICENSE = ""
|
37 |
|
38 |
+
_TASK_NAMES = ['poly_a|arabidopsis_thaliana',
|
39 |
+
'poly_a|oryza_sativa_indica_group',
|
40 |
+
'poly_a|trifolium_pratense',
|
41 |
+
'poly_a|medicago_truncatula',
|
42 |
+
'poly_a|chlamydomonas_reinhardtii',
|
43 |
+
'poly_a|oryza_sativa_japonica_group']
|
44 |
+
|
45 |
+
|
46 |
+
_TASK_NAME_TO_TYPE = {'poly_a':'binary',
|
47 |
+
'lncrna':'binary',
|
48 |
+
'splice_site':'binary',}
|
49 |
|
50 |
|
51 |
class AgroNtTasksConfig(datasets.BuilderConfig):
|
52 |
"""BuilderConfig for the Agro NT supervised learning tasks dataset."""
|
53 |
|
54 |
+
def __init__(self, *args, task_name: str, **kwargs):
|
55 |
"""BuilderConfig downstream tasks dataset.
|
56 |
Args:
|
57 |
task (:obj:`str`): Task name.
|
|
|
59 |
"""
|
60 |
super().__init__(
|
61 |
*args,
|
62 |
+
name=f"{task_name}",
|
63 |
**kwargs,
|
64 |
)
|
65 |
+
self.task,self.name = task_name.split("|")
|
66 |
+
self.task_type = _TASK_NAME_TO_TYPE[self.task]
|
67 |
+
|
68 |
|
69 |
class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
70 |
"""GeneratorBasedBuilder for the Agro NT supervised learning tasks dataset."""
|
71 |
|
72 |
+
BUILDER_CONFIGS = [AgroNtTasksConfig(task_name=TASK_NAME) for TASK_NAME
|
73 |
+
in _TASK_NAMES]
|
74 |
|
75 |
+
DEFAULT_CONFIG_NAME = _TASK_NAMES[0]
|
76 |
|
77 |
def _info(self):
|
78 |
|
79 |
+
if self.task_type == 'binary':
|
80 |
+
features = datasets.Features(
|
81 |
+
{
|
82 |
+
"sequence": datasets.Value("string"),
|
83 |
+
"name": datasets.Value("string"),
|
84 |
+
"labels": datasets.Value("int8"),
|
85 |
+
}
|
86 |
+
)
|
87 |
|
88 |
return datasets.DatasetInfo(
|
89 |
# This is the description that will appear on the datasets page.
|
|
|
98 |
|
99 |
def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
|
100 |
|
101 |
+
train_file = dl_manager.download_and_extract(
|
102 |
+
os.path.join(self.config.task, self.config.name + "_train.fa"))
|
103 |
+
test_file = dl_manager.download_and_extract(
|
104 |
+
os.path.join(self.config.task, self.config.name + "_test.fa"))
|
105 |
|
106 |
return [
|
107 |
datasets.SplitGenerator(
|