Skip to content

Issue with CCD code string parsing when code starts with a digit (e.g., "29N" parsed as "2") #400

Closed

Description

@sansgordon-lang

Thank you for developing and sharing ESMFold2 / ESM3!
When passing a valid CCD code that begins with a number (such as "29N") to LigandInput(ccd="29N"), ESMFold2 fails during input preprocessing. The internal parser incorrectly truncates or parses the CCD string down to its leading digit ("2"), resulting in ValueError: CCD component 2 not found.
Additionally, when setting up covalent bonds using CovalentBond with string atom names, a secondary TypeError: '<' not supported between instances of 'str' and 'int' is triggered during compute_token_bonds.

Minimal Reproducible Example
from esm.models.esmfold2 import (
ProteinInput,
LigandInput,
StructurePredictionInput,
ESMFold2InputBuilder,
)
from esm.sdk.api import CovalentBond # or esm.utils.structure.input_builder

1. Define Protein Chain

protein = ProteinInput(
id="B",
sequence="CPFDCRWSTPCHWC"
)

2. Define Ligand with a CCD code starting with a number

ligand = LigandInput(
id="L",
ccd="29N" # Triggers "CCD component 2 not found"
)

3. Define Covalent Bond

covalent_bonds = [
CovalentBond("L", 1, "C1", "B", 1, "SG") # Triggers TypeError: '<' between str and int
]

spi = StructurePredictionInput(
sequences=[protein, ligand],
covalent_bonds=covalent_bonds
)

Predict

results = ESMFold2InputBuilder().fold(spi)

Error Traceback
Loading CCD dictionary from /data/ssd/esm-main/models/esmfold2/ccd.pkl
Traceback (most recent call last):
File "/home/gordon/run/ESMfold2/BT8009.py", line 181, in
main()
File "/home/gordon/run/ESMfold2/BT8009.py", line 129, in main
results = ESMFold2InputBuilder().fold(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/ssd/esm-main/esm_env/lib/python3.12/site-packages/esm/models/esmfold2/processor.py", line 412, in fold
features, chain_infos = self.prepare_input(
^^^^^^^^^^^^^^^^^^^
File "/data/ssd/esm-main/esm_env/lib/python3.12/site-packages/esm/models/esmfold2/processor.py", line 218, in prepare_input
features, chain_infos = prepare_esmfold2_input(
^^^^^^^^^^^^^^^^^^^^^^^
File "/data/ssd/esm-main/esm_env/lib/python3.12/site-packages/esm/models/esmfold2/prepare_input.py", line 1470, in prepare_esmfold2_input
chains, tokens, atoms = build_chains_from_input(input, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/ssd/esm-main/esm_env/lib/python3.12/site-packages/esm/models/esmfold2/prepare_input.py", line 759, in build_chains_from_input
new_tokens, new_atoms = tokenize_ligand_ccd(
^^^^^^^^^^^^^^^^^^^^
File "/data/ssd/esm-main/esm_env/lib/python3.12/site-packages/esm/models/esmfold2/prepare_input.py", line 520, in tokenize_ligand_ccd
raise ValueError(f"CCD component {code} not found")
ValueError: CCD component 2 not found

Activity

  1. changed the title [-][Bug] Issue with CCD code string parsing when code starts with a digit (e.g., "29N" parsed as "2")[/-] [+]Issue with CCD code string parsing when code starts with a digit (e.g., "29N" parsed as "2")[/+] on Sep 10, 2026
  2. faustomilletari commented on Sep 10, 2026

    @faustomilletari
    Collaborator

    on it. Can you pass CCD as a list of strings and check if the problem is still there?

  3. faustomilletari commented on Sep 10, 2026

    @faustomilletari
    Collaborator

    The issue happens because you are passing CCDs as bare strings and not lists of strings. You need to pass them as Lists of strings

  4. sansgordon-lang commented on Sep 15, 2026

    @sansgordon-lang
    Author

    Thank you so much for the clarification, @faustomilletari!

    Passing the CCD as a list of strings (ccd=["29N"]) instead of a bare string fixed the parsing issue. Really appreciate the quick and clear help!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions