Update Genome_database.py
Browse files- Genome_database.py +10 -0
Genome_database.py
CHANGED
|
@@ -6,7 +6,13 @@ import os
|
|
| 6 |
import gzip
|
| 7 |
import re
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
class GenomeDataset(datasets.GeneratorBasedBuilder):
|
|
|
|
| 10 |
VERSION = datasets.Version("1.1.0")
|
| 11 |
|
| 12 |
def _info(self):
|
|
@@ -30,6 +36,9 @@ class GenomeDataset(datasets.GeneratorBasedBuilder):
|
|
| 30 |
urls_filepath = dl_manager.download_and_extract('urlfile.txt')
|
| 31 |
with open(urls_filepath) as urls_file:
|
| 32 |
downloaded_files = [line.rstrip() for line in urls_file]
|
|
|
|
|
|
|
|
|
|
| 33 |
train_files = downloaded_files[:int(len(downloaded_files) * 0.8)] # first 80% for training
|
| 34 |
test_files = downloaded_files[int(len(downloaded_files) * 0.8):] # last 20% for testing
|
| 35 |
|
|
@@ -98,3 +107,4 @@ class GenomeDataset(datasets.GeneratorBasedBuilder):
|
|
| 98 |
'end_position': end_position
|
| 99 |
}
|
| 100 |
id_+= 1
|
|
|
|
|
|
| 6 |
import gzip
|
| 7 |
import re
|
| 8 |
|
| 9 |
+
class GenomeDatasetConfig(datasets.BuilderConfig):
|
| 10 |
+
def __init__(self, num_urls=None, **kwargs):
|
| 11 |
+
super(GenomeDatasetConfig, self).__init__(**kwargs)
|
| 12 |
+
self.num_urls = num_urls if num_urls is not None else 937 # default value
|
| 13 |
+
|
| 14 |
class GenomeDataset(datasets.GeneratorBasedBuilder):
|
| 15 |
+
BUILDER_CONFIG_CLASS = GenomeDatasetConfig
|
| 16 |
VERSION = datasets.Version("1.1.0")
|
| 17 |
|
| 18 |
def _info(self):
|
|
|
|
| 36 |
urls_filepath = dl_manager.download_and_extract('urlfile.txt')
|
| 37 |
with open(urls_filepath) as urls_file:
|
| 38 |
downloaded_files = [line.rstrip() for line in urls_file]
|
| 39 |
+
|
| 40 |
+
downloaded_files = downloaded_files[:self.config.num_urls]
|
| 41 |
+
|
| 42 |
train_files = downloaded_files[:int(len(downloaded_files) * 0.8)] # first 80% for training
|
| 43 |
test_files = downloaded_files[int(len(downloaded_files) * 0.8):] # last 20% for testing
|
| 44 |
|
|
|
|
| 107 |
'end_position': end_position
|
| 108 |
}
|
| 109 |
id_+= 1
|
| 110 |
+
|