Skip to content

fix(utils): assign unique chain IDs when parsing multi-record FASTAs - #59

Open
omar-A-hassan wants to merge 1 commit into
apple:mainfrom
omar-A-hassan:fix-multichain-fasta-parsing
Open

fix(utils): assign unique chain IDs when parsing multi-record FASTAs#59
omar-A-hassan wants to merge 1 commit into
apple:mainfrom
omar-A-hassan:fix-multichain-fasta-parsing

Conversation

@omar-A-hassan

@omar-A-hassan omar-A-hassan commented Aug 6, 2026

Copy link
Copy Markdown

Summary of Changes

Fixes a silent chain-truncation bug in parse_fasta (src/simplefold/utils/fasta_utils.py).

Currently, parse_fasta hardcodes "id": "A" for every record in a multi-record FASTA:

for seq_record in records:
    molecule = {
        "protein": {
            "id": "A",  # Hardcoded default
            ...
        }
    }

When parsing a multi-record FASTA (e.g., Heavy Chain + Light Chain), parse_boltz_schema stores parsed chains in a dictionary keyed by "id". Because every record gets id: "A", subsequent records overwrite preceding records under key "A". This causes parse_fasta to silently drop all chains except the last record without raising an error.

Proposed Fix

Enumerate record indices and assign unique chain identifiers ("A", "B", "C", ...):

for i, seq_record in enumerate(records):
    seq = str(seq_record.seq)
    chain_id = chr(ord("A") + i) if i < 26 else f"A{i}"

Verification

Verified using parse_fasta on a 2-record FASTA (Heavy + Light chains):

  • Before Fix: Parsed 1 chain (Chain A, 23 residues). Heavy chain dropped.
  • After Fix: Parsed 2 chains (Chain A, 26 residues; Chain B, 23 residues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant