Download src/download_and_process_data.py from bloyal/oas-paired-sequence-data: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/datasets/bloyal/oas-paired-sequence-data/resolve/8e17b213811fdd6bbb2da470ac87405ea66467ec/src/download_and_process_data.py
- Command line
-
hf download hf://datasets/bloyal/oas-paired-sequence-data@8e17b213811fdd6bbb2da470ac87405ea66467ec/src/download_and_process_data.py
-
curl -L -o download_and_process_data.py https://huggingface.co/datasets/bloyal/oas-paired-sequence-data/resolve/8e17b213811fdd6bbb2da470ac87405ea66467ec/src/download_and_process_data.py
1.43 kB
| 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") | |
| species_df = pd.DataFrame( | |
| columns=["run_id", "sequence_alignment_aa_heavy", "sequence_alignment_aa_light"] | |
| ) | |
| 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", | |
| "sequence_alignment_aa_light", | |
| ] | |
| ] | |
| run_data.insert(0, "run_id", run_id) | |
| species_df = pd.concat([species_df, run_data]) | |
| print(f"{species} output summary:") | |
| print(species_df.head()) | |
| print(species_df.shape) | |
| output_file_name = os.path.join(output_path, species + ".parquet") | |
| print(f"Creating {output_file_name}") | |
| species_df.to_parquet(output_file_name, compression="gzip") | |