From 1e2a2fcedf962aed8a5b15727e7b4fabe26c7413 Mon Sep 17 00:00:00 2001 From: Lior Zimmerman Date: Tue, 19 Nov 2024 10:57:11 +0200 Subject: [PATCH] Fixing a bug when more than one ligand is used, entities are recognized as same by ihm --- src/boltz/data/write/mmcif.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/boltz/data/write/mmcif.py b/src/boltz/data/write/mmcif.py index 26d525a..c0de617 100644 --- a/src/boltz/data/write/mmcif.py +++ b/src/boltz/data/write/mmcif.py @@ -55,7 +55,7 @@ def to_mmcif(structure: Structure) -> str: # noqa: C901 # Create entity objects entities_map = {} - for entity, sequence in sequences.items(): + for k,(entity, sequence) in enumerate(sequences.items()): mol_type = entity_to_moltype[entity] if mol_type == const.chain_type_ids["PROTEIN"]: @@ -69,11 +69,10 @@ def to_mmcif(structure: Structure) -> str: # noqa: C901 chem_comp = lambda x: ihm.RNAChemComp(id=x, code=x, code_canonical="N") # noqa: E731 elif len(sequence) > 1: alphabet = {} - chem_comp = lambda x: ihm.SaccharideChemComp(id=x) # noqa: E731 + chem_comp = lambda x: ihm.SaccharideChemComp(id=x,code_canonical=f"X{k}") # noqa: E731 else: alphabet = {} - chem_comp = lambda x: ihm.NonPolymerChemComp(id=x) # noqa: E731 - + chem_comp = lambda x: ihm.NonPolymerChemComp(id=x,code_canonical=f"X{k}") # noqa: E731 seq = [ alphabet[item] if item in alphabet else chem_comp(item) for item in sequence ]