Skip to content

feat: widen chain IDs from u8 to String for multi-char CIF support - #44

Open
adobles96 wants to merge 1 commit into
steineggerlab:masterfrom
genesistherapeutics:upstream/widen-chain-ids
Open

feat: widen chain IDs from u8 to String for multi-char CIF support#44
adobles96 wants to merge 1 commit into
steineggerlab:masterfrom
genesistherapeutics:upstream/widen-chain-ids

Conversation

@adobles96

Copy link
Copy Markdown
Contributor

Summary

  • Widens chain ID storage from u8 to String throughout the pipeline to support multi-character chain IDs (e.g. "10" in auth_asym_id from large cryo-EM structures like PDB 9A1O)
  • Updates AtomVector, Structure, CompactStructure chain fields and ResidueMatch type accordingly
  • CIF parser: replaces get_one_char with get_text_string to preserve full chain names
  • PDB/FCZ parsers: convert at boundary, Atom struct unchanged for FFI compat
  • Query format: underscore separator (e.g. AA_250) for unambiguous multi-char chains, with backward compat for single-char legacy format (A250)

Test plan

  • Tested with large cryo-EM structures (PDB 9A1O) that have multi-char chain IDs
  • Verified backward compatibility with single-char chain ID queries

🤖 Generated with Claude Code

Large cryo-EM structures (e.g. PDB 9A1O) have multi-character chain IDs
like "10" in auth_asym_id. Previously these were truncated to a single
byte. This commit widens chain storage to String throughout the pipeline:

- AtomVector, Structure, CompactStructure chain fields: u8 -> String
- ResidueMatch type: (u8, u64) -> (String, u64)
- CIF parser: replace get_one_char with get_text_string (preserves full chain name)
- PDB/FCZ parsers: convert at boundary, Atom struct unchanged for FFI compat
- Query format: underscore separator (e.g. "AA_250") for unambiguous multi-char chains,
  with backward compat for single-char legacy format ("A250")
- All output formatting uses CHAIN_RESIDUE separator

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@adobles96

Copy link
Copy Markdown
Contributor Author

Probably need to propagate the new motif format through documentation if approved. I can do that after/if you green light. I introduced the separator b/c there may be multichar chain IDs with numbers (eg A1_250), I think eg gemmi does this sometimes.

@khb7840

khb7840 commented Apr 16, 2026

Copy link
Copy Markdown
Member

Ah I was thinking of the same query format with underscore separator with backward compatibility.
Thank you for PR. I'll review this version.

@adobles96

Copy link
Copy Markdown
Contributor Author

@khb7840 just bumping this. Are you still interested in merging this?

@khb7840

khb7840 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Yes. Sorry for the delaying.

@khb7840

khb7840 commented Jul 10, 2026

Copy link
Copy Markdown
Member

I found the default output format has been changed with your fork and the underscore between the chain ID and the residue indices is not compatible with the query grammar. To keep backward compatibility, I think the output formatting can be kept as the old version by default & new formatting activated with flags or numeric ID discovered. I'm also considering both format to be enabled in querying grammer. Could you make a pull request to widen-chain-ids instead of master?

// BEFORE
AF-O15391-F1-model_v4.pdb	4	84.0118	0.2132	A313,A318,A331,A335	F207,F212,F225,F229
// AFTER
AF-O15391-F1-model_v4.pdb	4	84.0118	0.2132	A_313,A_318,A_331,A_335	F_207,F_212,F_225,F_229

And thank you for the contribution.

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.

2 participants