Datasets:

DOI:
License:
etrop commited on
Commit
28ad444
1 Parent(s): c7493ea

refactor: var naming

Browse files
Files changed (1) hide show
  1. agro-nt-tasks.py +12 -9
agro-nt-tasks.py CHANGED
@@ -40,12 +40,15 @@ _TASK_NAMES = ['poly_a.arabidopsis_thaliana',
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):
@@ -58,7 +61,7 @@ class AgroNtTasksConfig(datasets.BuilderConfig):
58
  **kwargs: keyword arguments forwarded to super.
59
  """
60
 
61
- self.task,self.specie = task_name.split(".")
62
  self.task_type = _TASK_NAME_TO_TYPE[self.task]
63
 
64
  super().__init__(
@@ -84,7 +87,7 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
84
  {
85
  "sequence": datasets.Value("string"),
86
  "name": datasets.Value("string"),
87
- "labels": datasets.Value("int8"),
88
  }
89
  )
90
 
@@ -102,9 +105,9 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
102
  def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
103
 
104
  train_file = dl_manager.download_and_extract(
105
- os.path.join(self.config.task, self.config.specie + "_train.fa"))
106
  test_file = dl_manager.download_and_extract(
107
- os.path.join(self.config.task, self.config.specie + "_test.fa"))
108
 
109
  return [
110
  datasets.SplitGenerator(
@@ -134,11 +137,11 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
134
  ]
135
 
136
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
137
- def _generate_examples(self, filepath, split):
138
  with open(filepath, 'r') as f:
139
  key = 0
140
  for record in SeqIO.parse(f,'fasta'):
141
- # Yields examples as (key, example) tuples
142
 
143
  split_name = record.name.split("|")
144
  name = split_name[0]
@@ -147,6 +150,6 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
147
  yield key, {
148
  "sequence": str(record.seq),
149
  "name": name,
150
- "labels": labels,
151
  }
152
  key += 1
 
40
  'poly_a.trifolium_pratense',
41
  'poly_a.medicago_truncatula',
42
  'poly_a.chlamydomonas_reinhardtii',
43
+ 'poly_a.oryza_sativa_japonica_group',
44
+ 'splicing.arabidopsis_thaliana_donor',
45
+ 'splicing.arabidopsis_thaliana_acceptor'
46
+ ]
47
 
48
 
49
  _TASK_NAME_TO_TYPE = {'poly_a':'binary',
50
  'lncrna':'binary',
51
+ 'splicing':'binary',}
52
 
53
 
54
  class AgroNtTasksConfig(datasets.BuilderConfig):
 
61
  **kwargs: keyword arguments forwarded to super.
62
  """
63
 
64
+ self.task,self.sub_task = task_name.split(".")
65
  self.task_type = _TASK_NAME_TO_TYPE[self.task]
66
 
67
  super().__init__(
 
87
  {
88
  "sequence": datasets.Value("string"),
89
  "name": datasets.Value("string"),
90
+ "label": datasets.Value("int8"),
91
  }
92
  )
93
 
 
105
  def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
106
 
107
  train_file = dl_manager.download_and_extract(
108
+ os.path.join(self.config.task, self.config.sub_task + "_train.fa"))
109
  test_file = dl_manager.download_and_extract(
110
+ os.path.join(self.config.task, self.config.sub_task + "_test.fa"))
111
 
112
  return [
113
  datasets.SplitGenerator(
 
137
  ]
138
 
139
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
140
+ def _generate_examples(self, filepath):
141
  with open(filepath, 'r') as f:
142
  key = 0
143
  for record in SeqIO.parse(f,'fasta'):
144
+ # Yields examples as (key, example) tuples
145
 
146
  split_name = record.name.split("|")
147
  name = split_name[0]
 
150
  yield key, {
151
  "sequence": str(record.seq),
152
  "name": name,
153
+ "label": labels,
154
  }
155
  key += 1