From b0965642ec9ec8e383604a85a176c9bb7655d048 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Thu, 1 Nov 2018 11:05:28 +0100 Subject: [PATCH] mol-model: added findAtomOnResidue --- .../structure/model/properties/atomic/hierarchy.ts | 9 ++++++++- .../structure/model/properties/utils/atomic-index.ts | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mol-model/structure/model/properties/atomic/hierarchy.ts b/src/mol-model/structure/model/properties/atomic/hierarchy.ts index a8007a645..62c7d7ca6 100644 --- a/src/mol-model/structure/model/properties/atomic/hierarchy.ts +++ b/src/mol-model/structure/model/properties/atomic/hierarchy.ts @@ -169,7 +169,14 @@ export interface AtomicIndex { * @param key * @returns index or -1 if the atom is not present. */ - findAtomAuth(key: AtomicIndex.AtomAuthKey): ElementIndex + findAtomAuth(key: AtomicIndex.AtomAuthKey): ElementIndex, + + /** + * Find element index of an atom on a given residue. + * @param key + * @returns index or -1 if the atom is not present. + */ + findAtomOnResidue(residueIndex: ResidueIndex, label_atom_id: string, label_alt_id?: string): ElementIndex // TODO: add indices that support comp_id? } diff --git a/src/mol-model/structure/model/properties/utils/atomic-index.ts b/src/mol-model/structure/model/properties/utils/atomic-index.ts index 8a0178abd..75af86ad0 100644 --- a/src/mol-model/structure/model/properties/utils/atomic-index.ts +++ b/src/mol-model/structure/model/properties/utils/atomic-index.ts @@ -152,6 +152,14 @@ class Index implements AtomicIndex { return findAtomByNameAndAltLoc(offsets[rI], offsets[rI + 1], this.map.auth_atom_id, this.map.label_alt_id, key.auth_atom_id, key.label_alt_id); } + findAtomOnResidue(rI: ResidueIndex, label_atom_id: string, label_alt_id?: string) { + const offsets = this.map.segments.residueAtomSegments.offsets; + if (typeof label_alt_id === 'undefined') { + return findAtomByName(offsets[rI], offsets[rI + 1], this.map.label_atom_id, label_atom_id); + } + return findAtomByNameAndAltLoc(offsets[rI], offsets[rI + 1], this.map.label_atom_id, this.map.label_alt_id, label_atom_id, label_alt_id); + } + constructor(private map: Mapping) { this.entityIndex = map.entities.getEntityIndex; } -- GitLab