Skip to content

[Feat] Enhanced MSA Scripts #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 3, 2025
22 changes: 18 additions & 4 deletions scripts/msa/step1-get_prot_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import json
from datetime import datetime
from pathlib import Path

import biotite.structure as struc
Expand Down Expand Up @@ -57,8 +58,15 @@ def get_seqs(mmcif_file):
if "pdbx_audit_revision_history" in mmcif_parser.cif.block:
history = mmcif_parser.cif.block["pdbx_audit_revision_history"]
info_df["release_date"] = history["revision_date"].as_array()[0]
else:
# Handle non-official mmcif file which transform from pdb file
info_df["release_date"] = datetime.now().strftime("%Y-%m-%d")

info_df["release_date_retrace_obsolete"] = mmcif_parser.release_date
if mmcif_parser.release_date:
info_df["release_date_retrace_obsolete"] = mmcif_parser.release_date
else:
# Handle non-official mmcif file which transform from pdb file
info_df["release_date_retrace_obsolete"] = datetime.now().strftime("%Y-%m-%d")

entity_poly_seq = mmcif_parser.get_category_table("entity_poly_seq")

Expand Down Expand Up @@ -189,8 +197,14 @@ def mapping_seqs_to_integer_identifiers(


if __name__ == "__main__":
# It's a demo here
cif_dir = Path("./scripts/msa/data/mmcif")
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--cif_dir", type=str, default="./scripts/msa/data/mmcif")
parser.add_argument("--out_dir", type=str, default="./scripts/msa/data/pdb_seqs")
args = parser.parse_args()

cif_dir = Path(args.cif_dir)
cif_files = [x for x in cif_dir.iterdir() if x.is_file()]

info_dfs = []
Expand All @@ -208,7 +222,7 @@ def mapping_seqs_to_integer_identifiers(
out_df = pd.concat(info_dfs)
out_df = out_df.sort_values(["pdb_id", "entity_id"])

out_dir = Path("./scripts/msa/data/pdb_seqs")
out_dir = Path(args.out_dir)
if not out_dir.exists():
out_dir.mkdir(parents=True)
# 1. extract pdb sequence info
Expand Down
Loading