Skip to content
Snippets Groups Projects
Commit 13bb3ccf authored by Michal Malý's avatar Michal Malý
Browse files

ReDNATCO plugin stage 13

parent 014358ac
No related branches found
No related tags found
No related merge requests found
import { ReDNATCOMsp } from './index';
import { ReDNATCOMspApi } from './api';
export class ReDNATCOMspApiImpl implements ReDNATCOMspApi.Object {
private target: ReDNATCOMsp|undefined = undefined;
private onEvent: ((evt: ReDNATCOMspApi.Event) => void)|undefined;
private check() {
if (!this.target)
throw new Error('ReDNATCOMsp object not bound');
}
_bind(target: ReDNATCOMsp) {
this.target = target;
}
command(cmd: ReDNATCOMspApi.Command) {
this.check();
this.target!.command(cmd);
}
event(evt: ReDNATCOMspApi.Event) {
if (this.onEvent)
this.onEvent(evt);
}
init(elemId: string, onEvent?: (evt: ReDNATCOMspApi.Event) => void, onInited?: () => void) {
this.onEvent = onEvent;
ReDNATCOMsp.init(elemId, onInited);
return this;
}
isReady(): boolean {
return !!this.target;
}
loadStructure(data: string, type: 'cif'|'pdb') {
this.check();
this.target!.loadStructure(data, type);
}
query(type: ReDNATCOMspApi.Queries.Type): ReDNATCOMspApi.Response {
this.check();
return this.target!.apiQuery(type);
}
}
export namespace ReDNATCOMspApi {
export namespace Commands {
export type Type = 'deselect-step'|'redraw'|'select-step'|'switch-model';
export type Redraw = { type: 'redraw' }
export function Redraw(): Redraw { return { type: 'redraw' }; }
export type DeselectStep = { type: 'deselect-step' }
export function DeselectStep() {
return { type: 'deselect-step' };
}
export type SelectStep = {
type: 'select-step';
stepName: string;
prevStepName: string|undefined;
nextStepName: string|undefined;
referenceNtC: string;
references: ('sel'|'prev'|'next')[];
}
export function SelectStep(stepName: string, prevStepName: string|undefined, nextStepName: string|undefined, referenceNtC = '', references = ['sel', 'prev', 'next']): SelectStep {
return {
type: 'select-step',
stepName,
prevStepName,
nextStepName,
referenceNtC,
references: references as ('sel'|'prev'|'next')[],
};
}
export type SwitchModel = { type: 'switch-model', model: number };
export function SwitchModel(model: number): SwitchModel { return { type: 'switch-model', model }; }
}
export type Command =
Commands.DeselectStep |
Commands.Redraw |
Commands.SelectStep |
Commands.SwitchModel;
export namespace Events {
export type Type = 'step-deselected'|'step-requested'|'step-selected';
export type StepDeselected = { type: 'step-deselected' }
export function StepDeselected(): StepDeselected {
return { type: 'step-deselected' };
}
export type StepRequested = { type: 'step-requested', name: string }
export function StepRequested(name: string): StepRequested {
return { type: 'step-requested', name };
}
export type StepSelected = { type: 'step-selected', success: boolean, name: string, rmsd?: number }
export function StepSelectedOk(name: string, rmsd?: number): StepSelected {
return { type: 'step-selected', success: true, name, rmsd };
}
export function StepSelectedFail(): StepSelected {
return { type: 'step-selected', success: false, name: '' };
}
}
export type Event =
Events.StepDeselected |
Events.StepRequested |
Events.StepSelected;
export namespace Queries {
export type Type = 'selected-step';
export type SelectedStep = { type: 'selected-step', name: string, rmsd?: number }
export function SelectedStep(name: string, rmsd?: number): SelectedStep {
return { type: 'selected-step', name, rmsd };
}
}
export type Response = Queries.SelectedStep;
export interface Object {
command: (cmd: Command) => void;
event: (evt: Event) => void;
init: (elemId: string, onEvent?: (evt: Event) => void, onInited?: () => void) => void;
isReady: () => boolean;
loadStructure: (data: string, type: 'cif'|'pdb') => void;
query: (type: Queries.Type) => Response;
}
}
export namespace Commands {
export type Type = 'redraw'|'select-step'|'switch-model';
export type Redraw = { type: 'redraw' }
export function Redraw(): Redraw { return { type: 'redraw' }; }
export type SelectStep = {
type: 'select-step';
stepName: string;
prevStepName: string|null;
nextStepName: string|null;
referenceNtC: string;
references: ('sel'|'prev'|'next')[];
}
export function SelectStep(stepName: string, prevStepName: string|null, nextStepName: string|null, referenceNtC = '', references = ['sel', 'prev', 'next']): SelectStep {
return {
type: 'select-step',
stepName,
prevStepName,
nextStepName,
referenceNtC,
references: references as ('sel'|'prev'|'next')[],
};
}
export type SwitchModel = { type: 'switch-model', model: number };
export function SwitchModel(model: number): SwitchModel { return { type: 'switch-model', model }; }
export type Cmd = Redraw|SelectStep|SwitchModel;
}
export type ID ='data'|'trajectory'|'model'|'structure'|'visual'|'pyramids'|'superposition'; export type ID ='data'|'trajectory'|'model'|'structure'|'visual'|'pyramids'|'superposition';
export type Substructure = 'nucleic'|'protein'|'water'; export type Substructure = 'nucleic'|'protein'|'water'|'selected-slice'|'remainder-slice';
export function ID(id: ID, sub: Substructure|'', ref: string) { export function ID(id: ID, sub: Substructure|'', ref: string) {
if (sub === '') if (sub === '')
......
This diff is collapsed.
...@@ -66,6 +66,14 @@ export namespace Traverse { ...@@ -66,6 +66,14 @@ export namespace Traverse {
return EmptyLoci; return EmptyLoci;
} }
export function findStep(asymId: string, seqId: number, altId: string|undefined, loci: StructureElement.Loci, source: 'label'|'auth') {
const sel = findResidue(asymId, seqId, altId, loci, source);
if (sel.kind === 'empty-loci')
return sel;
return Loci.normalize(sel, 'two-residues');
}
export function residue(shift: number, altId: string|undefined, cursor: StructureElement.Loci) { export function residue(shift: number, altId: string|undefined, cursor: StructureElement.Loci) {
for (const e of cursor.elements) { for (const e of cursor.elements) {
const entireUnit = cursor.structure.units[e.unit.id]; const entireUnit = cursor.structure.units[e.unit.id];
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment