| import pandas as pd |
| import numpy as np |
|
|
| |
| saaint_db = pd.read_csv('saaintdb_20260226_all.csv') |
|
|
|
|
| |
| |
|
|
| def chain_ok(x): |
| |
| if pd.isna(x): |
| return False |
| x = str(x).strip() |
| return (x != "") and (x.upper() not in {"N.A."}) |
|
|
| def hl_label_from_row(row): |
| |
| h_ok = chain_ok(row["H_chain_ID"]) |
| l_ok = chain_ok(row["L_chain_ID"]) |
|
|
| if h_ok and l_ok: |
| return "HL" |
| elif h_ok and (not l_ok): |
| return "H_only" |
| elif (not h_ok) and l_ok: |
| return "L_only" |
| else: |
| return "none" |
|
|
| def make_unique_id(row): |
| |
| pdb_id = str(row["PDB_ID"]).strip() |
| heavy = str(row["H_chain_ID"]).strip() if not pd.isna(row["H_chain_ID"]) else "" |
| light = str(row["L_chain_ID"]).strip() if not pd.isna(row["L_chain_ID"]) else "" |
|
|
| h_ok = chain_ok(heavy) |
| l_ok = chain_ok(light) |
|
|
| if h_ok and l_ok: |
| return f"{pdb_id}_{heavy}_{light}" |
| elif h_ok: |
| return f"{pdb_id}_{heavy}" |
| elif l_ok: |
| return f"{pdb_id}_{light}" |
| else: |
| return pdb_id |
|
|
|
|
| |
| saaint_db["PDB_ID_chain"] = saaint_db.apply(make_unique_id, axis=1) |
|
|
| |
| saaint_db["hl_label"] = saaint_db.apply(hl_label_from_row, axis=1) |
|
|
| |
| pdb_summary = ( |
| saaint_db[["PDB_ID", "hl_label"]] |
| .drop_duplicates(subset=["PDB_ID"]) |
| .copy() |
| ) |
|
|
| |
| print("=== Number of unique PDBs per hl_label ===") |
| print(pdb_summary["hl_label"].value_counts(dropna=False).to_string()) |
|
|
|
|
|
|