import { FeatureViewInterface } from "../../RcsbFvSequence/SequenceViews/CustomView/CustomView"; import { RcsbFv, RcsbFvDisplayTypes, RcsbFvRowConfigInterface, RcsbFvTrackDataElementInterface } from "@rcsb/rcsb-saguaro"; import { RegionSelectionInterface } from "../../RcsbFvState/RcsbFvSelectorManager"; import { StructureViewerPublicInterface, SaguaroRegionList } from "../../RcsbFvStructure/StructureViewerInterface"; import { LoadMolstarInterface, LoadMolstarReturnType } from "../../RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager"; import {RcsbFvStateManager} from "../../RcsbFvState/RcsbFvStateManager"; export const rowConfig: Array = [ { trackId: "sequenceTrack", trackHeight: 20, trackColor: "#F9F9F9", displayType: RcsbFvDisplayTypes.SEQUENCE, nonEmptyDisplay: true, rowTitle: "N/A", trackData: [ { begin: 1, value: "N/A" } ] } ]; export function createFeatureViewerConfing(pdbEntry: string, labelAsymId: string) { const modelId = `${pdbEntry}_model`; const fvConfig: FeatureViewInterface,LoadMolstarReturnType> = { boardId: `${pdbEntry}_board`, boardConfig: { rowTitleWidth: 190, includeAxis: true }, rowConfig: rowConfig, sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, sequenceRegion: Array) => { stateManager.selectionState.clearSelection("select", {modelId: modelId, labelAsymId: labelAsymId}); if(sequenceRegion.length > 0) { const regions = sequenceRegion.map(r => ({ modelId: modelId, labelAsymId: labelAsymId, region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface })); stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select"); plugin.select(regions.map(r => ({ ...r, begin: r.region.begin, end: r.region.end })), "select", "set"); }else{ plugin.clearSelection("select", {modelId: modelId, labelAsymId: labelAsymId}) plugin.resetCamera(); } }, sequenceElementClickCallback: (plugin: StructureViewerPublicInterface,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, d: RcsbFvTrackDataElementInterface) => { if(d!=null) plugin.cameraFocus(modelId, "A", d.begin, d.end ?? d.begin); }, sequenceHoverCallback: (plugin: StructureViewerPublicInterface,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, elements: Array) => { console.log('HOEVER...', elements); if(elements == null || elements.length == 0) plugin.clearSelection("hover"); else { const e = elements[0]; console.log({ modelId: modelId, labelAsymId: labelAsymId, begin: e.begin, end: e.end ?? e.begin }); plugin.select(elements.map(e=>({ modelId: modelId, labelAsymId: labelAsymId, begin: e.begin, end: e.end ?? e.begin })), "hover", "set"); } }, structureSelectionCallback: (plugin: StructureViewerPublicInterface,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => { const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "select"); if(sel == null) { pfv.clearSelection("select"); plugin.resetCamera(); }else { pfv.setSelection({elements: sel.regions, mode: "select"}); } }, structureHoverCallback: (plugin: StructureViewerPublicInterface,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => { const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "hover"); if(sel == null) pfv.clearSelection("hover"); else pfv.setSelection({elements:sel.regions, mode:"hover"}); } } return fvConfig; }