wrapper.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 { Interval } from '../../mol-data/int';
  7. import { Loci, isEveryLoci } 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, units: Unit[] }
  12. export { SequenceWrapper }
  13. abstract class SequenceWrapper<D> {
  14. abstract residueLabel(seqIdx: number): string
  15. abstract residueColor(seqIdx: number): Color
  16. abstract getLoci(seqIdx: number): StructureElement.Loci
  17. abstract mark(loci: Loci, action: MarkerAction): boolean;
  18. markResidue(loci: Loci, action: MarkerAction) {
  19. if (isEveryLoci(loci)) {
  20. return applyMarkerAction(this.markerArray, Interval.ofLength(this.length), action)
  21. } else {
  22. return this.mark(loci, action);
  23. }
  24. }
  25. constructor(readonly data: D, readonly markerArray: Uint8Array, readonly length: number) {
  26. }
  27. }
  28. namespace SequenceWrapper {
  29. export type Any = SequenceWrapper<any>
  30. }