From beb1b2655ee6629beb9b0a4fe82a379f507e329a Mon Sep 17 00:00:00 2001 From: dsehnal <david.sehnal@gmail.com> Date: Sun, 17 Jul 2022 17:58:57 +0200 Subject: [PATCH] scan all entities when looking for struct_conn etries - solves PDB loading issue --- .../structure/property/bonds/struct_conn.ts | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mol-model-formats/structure/property/bonds/struct_conn.ts b/src/mol-model-formats/structure/property/bonds/struct_conn.ts index d8b2ca61e..f5f38998e 100644 --- a/src/mol-model-formats/structure/property/bonds/struct_conn.ts +++ b/src/mol-model-formats/structure/property/bonds/struct_conn.ts @@ -111,24 +111,28 @@ export namespace StructConn { symmetry: struct_conn.ptnr2_symmetry }; + const entityIds = Array.from(model.entities.data.id.toArray()); const _p = (row: number, ps: typeof p1) => { if (ps.label_asym_id.valueKind(row) !== Column.ValueKind.Present) return void 0; const asymId = ps.label_asym_id.value(row); - const entityIndex = model.atomicHierarchy.index.findEntity(asymId); - if (entityIndex < 0) return void 0; - const residueIndex = model.atomicHierarchy.index.findResidue( - model.entities.data.id.value(entityIndex), - asymId, - ps.auth_seq_id.value(row), - ps.ins_code.value(row) - ); - if (residueIndex < 0) return void 0; const atomName = ps.label_atom_id.value(row); // turns out "mismat" records might not have atom name value - if (!atomName) return void 0; - const atomIndex = model.atomicHierarchy.index.findAtomOnResidue(residueIndex, atomName, ps.label_alt_id.value(row)); - if (atomIndex < 0) return void 0; - return { residueIndex, atomIndex, symmetry: ps.symmetry.value(row) }; + if (!atomName) return undefined; + + const altId = ps.label_alt_id.value(row); + for (const eId of entityIds) { + const residueIndex = model.atomicHierarchy.index.findResidue( + eId, + asymId, + ps.auth_seq_id.value(row), + ps.ins_code.value(row) + ); + if (residueIndex < 0) continue; + const atomIndex = model.atomicHierarchy.index.findAtomOnResidue(residueIndex, atomName, altId); + if (atomIndex < 0) continue; + return { residueIndex, atomIndex, symmetry: ps.symmetry.value(row) }; + } + return void 0; }; const entries: StructConn.Entry[] = []; -- GitLab