wrapper.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 residueClass(seqIdx: number): string
  17. abstract getLoci(seqIdx: number): StructureElement.Loci
  18. abstract mark(loci: Loci, action: MarkerAction): boolean;
  19. markResidue(loci: Loci, action: MarkerAction) {
  20. if (isEveryLoci(loci)) {
  21. return applyMarkerAction(this.markerArray, Interval.ofLength(this.length), action)
  22. } else {
  23. return this.mark(loci, action);
  24. }
  25. }
  26. constructor(readonly data: D, readonly markerArray: Uint8Array, readonly length: number) {
  27. }
  28. }
  29. namespace SequenceWrapper {
  30. export type Any = SequenceWrapper<any>
  31. }