123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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<RcsbFvRowConfigInterface> = [
- {
- 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<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
- boardId: `${pdbEntry}_board`,
- boardConfig: {
- rowTitleWidth: 190,
- includeAxis: true
- },
- rowConfig: rowConfig,
- sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
- 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<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, d: RcsbFvTrackDataElementInterface) => {
- if(d!=null)
- plugin.cameraFocus(modelId, "A", d.begin, d.end ?? d.begin);
- },
- sequenceHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, elements: Array<RcsbFvTrackDataElementInterface>) => {
- 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<LoadMolstarInterface<unknown,unknown>,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<LoadMolstarInterface<unknown,unknown>,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;
- }
|