diff --git a/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts b/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts index 1dd4bc8b36398ea5f115d31e38912ec30216c510..0f80fb2687375a1027fa9fdef5e71088c34bf7ac 100644 --- a/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts +++ b/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts @@ -12,7 +12,7 @@ import { MeshBuilder } from '../../../geometry/mesh/mesh-builder'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { Segmentation } from 'mol-data/int'; import { MoleculeType, isNucleic, isPurinBase, isPyrimidineBase } from 'mol-model/structure/model/types'; -import { getElementIndexForAtomId, getElementIndexForAtomRole } from 'mol-model/structure/util'; +import { getElementIndexForAtomRole } from 'mol-model/structure/util'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { addCylinder } from '../../../geometry/mesh/builder/cylinder'; import { Box } from '../../../primitive/box'; @@ -42,7 +42,7 @@ async function createNucleotideBlockMesh(ctx: RuntimeContext, unit: Unit, struct const { elements, model } = unit const { chemicalComponentMap, modifiedResidues } = model.properties - const { chainAtomSegments, residueAtomSegments, residues } = model.atomicHierarchy + const { chainAtomSegments, residueAtomSegments, residues, index: atomicIndex } = model.atomicHierarchy const { label_comp_id } = residues const pos = unit.conformation.invariantPosition @@ -67,19 +67,19 @@ async function createNucleotideBlockMesh(ctx: RuntimeContext, unit: Unit, struct if (isPurinBase(compId)) { height = 4.5 - idx1 = getElementIndexForAtomId(model, residueIndex, 'N1') - idx2 = getElementIndexForAtomId(model, residueIndex, 'C4') - idx3 = getElementIndexForAtomId(model, residueIndex, 'C6') - idx4 = getElementIndexForAtomId(model, residueIndex, 'C2') - idx5 = getElementIndexForAtomId(model, residueIndex, 'N9') + idx1 = atomicIndex.findAtomOnResidue(residueIndex, 'N1') + idx2 = atomicIndex.findAtomOnResidue(residueIndex, 'C4') + idx3 = atomicIndex.findAtomOnResidue(residueIndex, 'C6') + idx4 = atomicIndex.findAtomOnResidue(residueIndex, 'C2') + idx5 = atomicIndex.findAtomOnResidue(residueIndex, 'N9') idx6 = getElementIndexForAtomRole(model, residueIndex, 'trace') } else if (isPyrimidineBase(compId)) { height = 3.0 - idx1 = getElementIndexForAtomId(model, residueIndex, 'N3') - idx2 = getElementIndexForAtomId(model, residueIndex, 'C6') - idx3 = getElementIndexForAtomId(model, residueIndex, 'C4') - idx4 = getElementIndexForAtomId(model, residueIndex, 'C2') - idx5 = getElementIndexForAtomId(model, residueIndex, 'N1') + idx1 = atomicIndex.findAtomOnResidue(residueIndex, 'N3') + idx2 = atomicIndex.findAtomOnResidue(residueIndex, 'C6') + idx3 = atomicIndex.findAtomOnResidue(residueIndex, 'C4') + idx4 = atomicIndex.findAtomOnResidue(residueIndex, 'C2') + idx5 = atomicIndex.findAtomOnResidue(residueIndex, 'N1') idx6 = getElementIndexForAtomRole(model, residueIndex, 'trace') } diff --git a/src/mol-model/structure/util.ts b/src/mol-model/structure/util.ts index d09d0c6378ba524a2e05a2e0f24bb3b645dd9fdc..04cdc89b23f622081e21736b9a9effe8ece39ea1 100644 --- a/src/mol-model/structure/util.ts +++ b/src/mol-model/structure/util.ts @@ -49,18 +49,9 @@ export function getAtomIdForAtomRole(moleculeType: MoleculeType, atomRole: AtomR return '' } -export function getElementIndexForAtomId(model: Model, rI: ResidueIndex, atomId: string): ElementIndex | -1 { - const { offsets } = model.atomicHierarchy.residueAtomSegments - const { label_atom_id } = model.atomicHierarchy.atoms - for (let j = offsets[rI], _j = offsets[rI + 1]; j < _j; j++) { - if (label_atom_id.value(j) === atomId) return j as ElementIndex - } - return -1 -} - export function getElementIndexForAtomRole(model: Model, rI: ResidueIndex, atomRole: AtomRole) { const atomId = getAtomIdForAtomRole(getAtomicMoleculeType(model, rI), atomRole) - return getElementIndexForAtomId(model, rI, atomId) + return model.atomicHierarchy.index.findAtomOnResidue(rI, atomId) } export function residueLabel(model: Model, rI: number) {