diff --git a/src/mol-model/structure/model/properties/atomic/hierarchy.ts b/src/mol-model/structure/model/properties/atomic/hierarchy.ts index a8007a645eb117f71115174309f6e5db5b364237..62c7d7ca6531ef0fd5efaaabe8bc99ecf0534176 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 8a0178abdb814061a31af61c57e7f22009b2e7f4..75af86ad0738579a7c6c2fa2c7e1079813a7d738 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; }