Update jolma_split.py
Browse files- jolma_split.py +7 -3
jolma_split.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import re
|
| 2 |
import pandas as pd
|
| 3 |
import datasets
|
|
@@ -56,7 +57,6 @@ URL = "https://huggingface.co/datasets/thewall/jolma_split/resolve/main"
|
|
| 56 |
"""
|
| 57 |
p70c10s61087t100 p70:70种蛋白,c10:count>10的序列,s61087:总共61087条序列,t100:小于100条序列的蛋白质划分至训练集
|
| 58 |
"""
|
| 59 |
-
|
| 60 |
class JolmaSplitConfig(datasets.BuilderConfig):
|
| 61 |
def __init__(self, protein_prefix="", protein_suffix="", max_length=1000, max_gene_num=1,
|
| 62 |
aptamer_prefix="", aptamer_suffix="", **kwargs):
|
|
@@ -121,8 +121,12 @@ class JolmaSubset(datasets.GeneratorBasedBuilder):
|
|
| 121 |
return int(pattern.search(self.get_protein_info(sra_id)["Ligand"]).group(0))
|
| 122 |
|
| 123 |
def _split_generators(self, dl_manager):
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
return [
|
| 127 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_file},),
|
| 128 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_file}, ),
|
|
|
|
| 1 |
+
import os.path
|
| 2 |
import re
|
| 3 |
import pandas as pd
|
| 4 |
import datasets
|
|
|
|
| 57 |
"""
|
| 58 |
p70c10s61087t100 p70:70种蛋白,c10:count>10的序列,s61087:总共61087条序列,t100:小于100条序列的蛋白质划分至训练集
|
| 59 |
"""
|
|
|
|
| 60 |
class JolmaSplitConfig(datasets.BuilderConfig):
|
| 61 |
def __init__(self, protein_prefix="", protein_suffix="", max_length=1000, max_gene_num=1,
|
| 62 |
aptamer_prefix="", aptamer_suffix="", **kwargs):
|
|
|
|
| 121 |
return int(pattern.search(self.get_protein_info(sra_id)["Ligand"]).group(0))
|
| 122 |
|
| 123 |
def _split_generators(self, dl_manager):
|
| 124 |
+
if self.config.data_dir is not None and os.path.exists(self.config.data_dir):
|
| 125 |
+
train_file = os.path.join(self.config.data_dir, f"{self.config.name}_train.csv.gz")
|
| 126 |
+
test_file = os.path.join(self.config.data_dir, f"{self.config.name}_test.csv.gz")
|
| 127 |
+
else:
|
| 128 |
+
train_file = dl_manager.download(f"{URL}/{self.config.name}_train.csv.gz")
|
| 129 |
+
test_file = dl_manager.download(f"{URL}/{self.config.name}_test.csv.gz")
|
| 130 |
return [
|
| 131 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_file},),
|
| 132 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_file}, ),
|