trace-lookup.ts 1.3 KB

12345678910111213141516171819202122232425262728
  1. /**
  2. * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
  6. */
  7. import { AtomicHierarchy, AtomicConformation } from 'mol-model/structure/model/properties/atomic';
  8. import { MoleculeType } from 'mol-model/structure/model/types';
  9. import { GridLookup3D } from 'mol-math/geometry';
  10. import { SortedArray } from 'mol-data/int';
  11. import { ResidueIndex } from 'mol-model/structure';
  12. export function calcAtomicTraceLookup3D(hierarchy: AtomicHierarchy, conformation: AtomicConformation) {
  13. const { x, y, z } = conformation;
  14. const { moleculeType, traceElementIndex } = hierarchy.derived.residue
  15. const indices: number[] = []
  16. const _proteinResidues: number[] = []
  17. for (let i = 0, il = moleculeType.length; i < il; ++i) {
  18. if (moleculeType[i] === MoleculeType.protein) {
  19. indices[indices.length] = traceElementIndex[i]
  20. _proteinResidues[_proteinResidues.length] = i
  21. }
  22. }
  23. const lookup3d = GridLookup3D({ x, y, z, indices: SortedArray.ofSortedArray(indices) }, 4);
  24. const proteinResidues = SortedArray.ofSortedArray<ResidueIndex>(_proteinResidues)
  25. return { lookup3d, proteinResidues }
  26. }