File size: 1,649 Bytes
373eddf 8e17b21 373eddf 8e17b21 373eddf 50f055e 373eddf 8e17b21 dd4dc1f 8e17b21 373eddf 8e17b21 373eddf 8e17b21 373eddf dd4dc1f 373eddf dd4dc1f 373eddf dd4dc1f 8e17b21 4e30a61 8e17b21 4e30a61 373eddf |
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 47 48 49 |
import os
import pandas as pd
import re
data_dir = os.getcwd()
output_path = os.getcwd()
species_list = ["human", "rat_SD", "mouse_BALB_c", "mouse_C57BL_6"]
for species in species_list:
print(f"Downloading {species} files")
list_of_df = []
species_url_file = os.path.join(data_dir, species + "_oas_paired.txt")
with open(species_url_file, "r") as f:
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])
run_data = pd.read_csv(
csv_file,
header=1,
compression="gzip",
on_bad_lines="warn",
)
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.insert(
0, "pair_id", run_id + "_" + run_data.reset_index().index.map(str)
)
list_of_df.append(run_data)
species_df = pd.concat(list_of_df, ignore_index=True)
print(f"{species} output summary:")
print(species_df.head())
print(species_df.shape)
output_file_name = os.path.join(output_path, species + ".csv")
print(f"Creating {output_file_name}")
species_df.to_csv(output_file_name, index=False)
|