File size: 1,507 Bytes
de6ec9e 5704bbf de6ec9e cd2add9 de6ec9e cd2add9 c45999c de6ec9e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import os
import pandas as pd
import re
data_dir = os.path.join(os.getcwd(), "data_units")
species_list = ["rat_SD", "mouse_BALB_c", "mouse_C57BL_6", "human"]
for species in species_list:
print(f"Downloading {species} files")
species_url_file = os.path.join(data_dir, species + ".txt")
with open(species_url_file, "r") as f:
i = 0
os.makedirs(species, exist_ok=True)
for csv_file in f.readlines():
print(csv_file)
filename = os.path.basename(csv_file)
run_id = str(re.search(r"^(.*)_[Pp]aired", filename)[1])
url = csv_file
run_data = pd.read_csv(
url,
header=1,
compression="gzip",
on_bad_lines="warn",
low_memory=False,
)
run_data = run_data[
[
"sequence_alignment_aa_heavy",
"cdr1_aa_heavy",
"cdr2_aa_heavy",
"cdr3_aa_heavy",
"sequence_alignment_aa_light",
"cdr1_aa_light",
"cdr2_aa_light",
"cdr3_aa_light",
]
]
run_data = run_data.dropna()
run_data.insert(0, "data_unit", run_id)
print(run_data.shape)
output_path = os.path.join(species, "train_" + str(i) + ".parquet")
run_data.to_parquet(output_path, index=False)
i += 1
|