oas-paired-sequence-data / oas-data-cleaning.py
EC2 Default User
Remove index
cd2add9
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