diff --git a/src/mol-model/sequence/alignment/sequence.ts b/src/mol-model/sequence/alignment/sequence.ts index 823490e058f3272b2a7116e874b61ceaa420d121..ad9aa481dc8a87db952d669c39e34d37425a28ac 100644 --- a/src/mol-model/sequence/alignment/sequence.ts +++ b/src/mol-model/sequence/alignment/sequence.ts @@ -22,7 +22,7 @@ namespace AlignSequences { score: number } - function createSeqIdIndicesMap(element: StructureElement.Loci.Element) { + export function createSeqIdIndicesMap(element: StructureElement.Loci.Element) { const seqIds = new Map<number, StructureElement.UnitIndex[]>(); if (Unit.isAtomic(element.unit)) { const { label_seq_id } = element.unit.model.atomicHierarchy.residues; @@ -94,7 +94,7 @@ namespace AlignSequences { } } -function entityKey(unit: Unit) { +export function entityKey(unit: Unit) { switch (unit.kind) { case Unit.Kind.Atomic: return unit.model.atomicHierarchy.index.getEntityFromChain(unit.chainIndex[unit.elements[0]]); @@ -105,6 +105,6 @@ function entityKey(unit: Unit) { } } -function getSequence(unit: Unit) { +export function getSequence(unit: Unit) { return unit.model.sequence.byEntityKey[entityKey(unit)].sequence; } \ No newline at end of file diff --git a/src/mol-model/structure/structure/util/superposition.ts b/src/mol-model/structure/structure/util/superposition.ts index 5476cae3ceb1f02299019c4b1a258e17466e9094..529a8ed89795c62cd869bf4fa6730a65bf2c4231 100644 --- a/src/mol-model/structure/structure/util/superposition.ts +++ b/src/mol-model/structure/structure/util/superposition.ts @@ -64,7 +64,7 @@ export function alignAndSuperpose(xs: StructureElement.Loci[]): AlignAndSuperpos return ret; } -function getPositionTable(xs: StructureElement.Loci, n: number): MinimizeRmsd.Positions { +export function getPositionTable(xs: StructureElement.Loci, n: number): MinimizeRmsd.Positions { const ret = MinimizeRmsd.Positions.empty(n); let o = 0; for (const u of xs.elements) { diff --git a/src/mol-plugin-ui/sequence.tsx b/src/mol-plugin-ui/sequence.tsx index 3807eb073bce3679b54087076348f7b6c1db0e23..fd554b1bdc98790dde83c5646e62b5e8f9686292 100644 --- a/src/mol-plugin-ui/sequence.tsx +++ b/src/mol-plugin-ui/sequence.tsx @@ -29,7 +29,7 @@ const MaxDisplaySequenceLength = 5000; const MaxSelectOptionsCount = 1000; const MaxSequenceWrappersCount = 30; -function opKey(l: StructureElement.Location) { +export function opKey(l: StructureElement.Location) { const ids = SP.unit.pdbx_struct_oper_list_ids(l); const ncs = SP.unit.struct_ncs_oper_id(l); const hkl = SP.unit.hkl(l); @@ -37,12 +37,12 @@ function opKey(l: StructureElement.Location) { return `${ids.sort().join(',')}|${ncs}|${hkl}|${spgrOp}`; } -function splitModelEntityId(modelEntityId: string) { +export function splitModelEntityId(modelEntityId: string) { const [modelIdx, entityId] = modelEntityId.split('|'); return [parseInt(modelIdx), entityId]; } -function getSequenceWrapper(state: { structure: Structure, modelEntityId: string, chainGroupId: number, operatorKey: string }, structureSelection: StructureSelectionManager): SequenceWrapper.Any | string { +export function getSequenceWrapper(state: { structure: Structure, modelEntityId: string, chainGroupId: number, operatorKey: string }, structureSelection: StructureSelectionManager): SequenceWrapper.Any | string { const { structure, modelEntityId, chainGroupId, operatorKey } = state; const l = StructureElement.Location.create(structure); const [modelIdx, entityId] = splitModelEntityId(modelEntityId); @@ -97,7 +97,7 @@ function getSequenceWrapper(state: { structure: Structure, modelEntityId: string } } -function getModelEntityOptions(structure: Structure, polymersOnly = false): [string, string][] { +export function getModelEntityOptions(structure: Structure, polymersOnly = false): [string, string][] { const options: [string, string][] = []; const l = StructureElement.Location.create(structure); const seen = new Set<string>(); @@ -131,7 +131,7 @@ function getModelEntityOptions(structure: Structure, polymersOnly = false): [str return options; } -function getChainOptions(structure: Structure, modelEntityId: string): [number, string][] { +export function getChainOptions(structure: Structure, modelEntityId: string): [number, string][] { const options: [number, string][] = []; const l = StructureElement.Location.create(structure); const seen = new Set<number>(); @@ -161,7 +161,7 @@ function getChainOptions(structure: Structure, modelEntityId: string): [number, return options; } -function getOperatorOptions(structure: Structure, modelEntityId: string, chainGroupId: number): [string, string][] { +export function getOperatorOptions(structure: Structure, modelEntityId: string, chainGroupId: number): [string, string][] { const options: [string, string][] = []; const l = StructureElement.Location.create(structure); const seen = new Set<string>(); @@ -189,7 +189,7 @@ function getOperatorOptions(structure: Structure, modelEntityId: string, chainGr return options; } -function getStructureOptions(state: State) { +export function getStructureOptions(state: State) { const options: [string, string][] = []; const all: Structure[] = []; diff --git a/src/mol-plugin-ui/sequence/sequence.tsx b/src/mol-plugin-ui/sequence/sequence.tsx index 0ba14c9c61e7a0843cebd25c6192e7eb79a96add..14e45cba0462fe7cafdd1adc6de0b88ca8c0ead6 100644 --- a/src/mol-plugin-ui/sequence/sequence.tsx +++ b/src/mol-plugin-ui/sequence/sequence.tsx @@ -27,21 +27,21 @@ const MaxSequenceNumberSize = 5; // TODO: this is somewhat inefficient and should be done using a canvas. export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { - private parentDiv = React.createRef<HTMLDivElement>(); - private lastMouseOverSeqIdx = -1; - private highlightQueue = new Subject<{ seqIdx: number, buttons: number, button: number, modifiers: ModifiersKeys }>(); + protected parentDiv = React.createRef<HTMLDivElement>(); + protected lastMouseOverSeqIdx = -1; + protected highlightQueue = new Subject<{ seqIdx: number, buttons: number, button: number, modifiers: ModifiersKeys }>(); - private lociHighlightProvider = (loci: Representation.Loci, action: MarkerAction) => { + protected lociHighlightProvider = (loci: Representation.Loci, action: MarkerAction) => { const changed = this.props.sequenceWrapper.markResidue(loci.loci, action); if (changed) this.updateMarker(); }; - private lociSelectionProvider = (loci: Representation.Loci, action: MarkerAction) => { + protected lociSelectionProvider = (loci: Representation.Loci, action: MarkerAction) => { const changed = this.props.sequenceWrapper.markResidue(loci.loci, action); if (changed) this.updateMarker(); }; - private get sequenceNumberPeriod() { + protected get sequenceNumberPeriod() { if (this.props.sequenceNumberPeriod !== undefined) { return this.props.sequenceNumberPeriod as number; } @@ -104,7 +104,7 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { e.preventDefault(); }; - private mouseDownLoci: StructureElement.Loci | undefined = undefined; + protected mouseDownLoci: StructureElement.Loci | undefined = undefined; mouseDown = (e: React.MouseEvent) => { e.stopPropagation(); @@ -148,7 +148,7 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { this.mouseDownLoci = undefined; }; - private getBackgroundColor(marker: number) { + protected getBackgroundColor(marker: number) { // TODO: make marker color configurable if (typeof marker === 'undefined') console.error('unexpected marker value'); return marker === 0 @@ -158,17 +158,17 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { : 'rgb(255, 102, 153)'; // highlighted } - private getResidueClass(seqIdx: number, label: string) { + protected getResidueClass(seqIdx: number, label: string) { return label.length > 1 ? this.props.sequenceWrapper.residueClass(seqIdx) + (seqIdx === 0 ? ' msp-sequence-residue-long-begin' : ' msp-sequence-residue-long') : this.props.sequenceWrapper.residueClass(seqIdx); } - private residue(seqIdx: number, label: string, marker: number) { + protected residue(seqIdx: number, label: string, marker: number) { return <span key={seqIdx} data-seqid={seqIdx} style={{ backgroundColor: this.getBackgroundColor(marker) }} className={this.getResidueClass(seqIdx, label)}>{`\u200b${label}\u200b`}</span>; } - private getSequenceNumberClass(seqIdx: number, seqNum: string, label: string) { + protected getSequenceNumberClass(seqIdx: number, seqNum: string, label: string) { const classList = ['msp-sequence-number']; if (seqNum.startsWith('-')) { if (label.length > 1 && seqIdx > 0) classList.push('msp-sequence-number-long-negative'); @@ -179,8 +179,8 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { return classList.join(' '); } - private location = StructureElement.Location.create(void 0); - private getSequenceNumber(seqIdx: number) { + protected location = StructureElement.Location.create(void 0); + protected getSequenceNumber(seqIdx: number) { let seqNum = ''; const loci = this.props.sequenceWrapper.getLoci(seqIdx); const l = StructureElement.Loci.getFirstLocation(loci, this.location); @@ -196,16 +196,16 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { return seqNum; } - private padSeqNum(n: string) { + protected padSeqNum(n: string) { if (n.length < MaxSequenceNumberSize) return n + new Array(MaxSequenceNumberSize - n.length + 1).join('\u00A0'); return n; } - private getSequenceNumberSpan(seqIdx: number, label: string) { + protected getSequenceNumberSpan(seqIdx: number, label: string) { const seqNum = this.getSequenceNumber(seqIdx); return <span key={`marker-${seqIdx}`} className={this.getSequenceNumberClass(seqIdx, seqNum, label)}>{this.padSeqNum(seqNum)}</span>; } - private updateMarker() { + protected updateMarker() { if (!this.parentDiv.current) return; const xs = this.parentDiv.current.children; const { markerArray } = this.props.sequenceWrapper; diff --git a/src/mol-plugin-ui/structure/superposition.tsx b/src/mol-plugin-ui/structure/superposition.tsx index dc59353b887950753d040b96683d054dc247790d..95ca1ee67a1e753217ab4d0bfc234383a54fb2bd 100644 --- a/src/mol-plugin-ui/structure/superposition.tsx +++ b/src/mol-plugin-ui/structure/superposition.tsx @@ -65,7 +65,7 @@ type SuperpositionControlsState = { options: StructureSuperpositionOptions } -interface LociEntry { +export interface LociEntry { loci: StructureElement.Loci, label: string, cell: StateObjectCell<PluginStateObject.Molecule.Structure>