trace-lookup.ts 1.1 KB

12345678910111213141516171819202122
  1. /**
  2. * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { GridLookup3D } from '../../../../mol-math/geometry';
  7. import { SortedArray } from '../../../../mol-data/int';
  8. import { Unit } from '../../../../mol-model/structure/structure';
  9. import { ResidueIndex } from '../../../../mol-model/structure';
  10. import { getBoundary } from '../../../../mol-math/geometry/boundary';
  11. export function calcUnitProteinTraceLookup3D(unit: Unit.Atomic, unitProteinResidues: SortedArray<ResidueIndex>): GridLookup3D {
  12. const { x, y, z } = unit.model.atomicConformation;
  13. const { traceElementIndex } = unit.model.atomicHierarchy.derived.residue
  14. const indices = new Uint32Array(unitProteinResidues.length)
  15. for (let i = 0, il = unitProteinResidues.length; i < il; ++i) {
  16. indices[i] = traceElementIndex[unitProteinResidues[i]]
  17. }
  18. const position = { x, y, z, indices: SortedArray.ofSortedArray(indices) }
  19. return GridLookup3D(position, getBoundary(position));
  20. }