wrapper.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. */
  6. import { OrderedSet } from '../../../mol-data/int';
  7. import { Loci } from '../../../mol-model/loci';
  8. import { MarkerAction, applyMarkerAction } from '../../../mol-util/marker-action';
  9. import { StructureElement, Structure, Unit } from '../../../mol-model/structure';
  10. import { Color } from '../../../mol-util/color';
  11. export type StructureUnit = { structure: Structure, unit: Unit }
  12. export { SequenceWrapper }
  13. abstract class SequenceWrapper<D> {
  14. abstract residueLabel(seqIdx: number): string
  15. abstract residueColor(seqIdx: number): Color
  16. abstract eachResidue(loci: Loci, apply: (set: OrderedSet) => boolean): boolean
  17. abstract getLoci(seqIdx: number): StructureElement.Loci
  18. markResidue(loci: Loci, action: MarkerAction) {
  19. return this.eachResidue(loci, (set: OrderedSet) => {
  20. return applyMarkerAction(this.markerArray, set, action)
  21. })
  22. }
  23. constructor(readonly data: D, readonly markerArray: Uint8Array, readonly length: number) {
  24. }
  25. }
  26. namespace SequenceWrapper {
  27. export type Any = SequenceWrapper<any>
  28. }