|
@@ -10,44 +10,58 @@ import {
|
|
|
StructureViewerPublicInterface, SaguaroRegionList
|
|
|
} from "../../RcsbFvStructure/StructureViewerInterface";
|
|
|
import {
|
|
|
- LoadMolstarInterface, LoadMolstarReturnType
|
|
|
+ LoadMethod,
|
|
|
+ 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"
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-];
|
|
|
+import {RcsbFvStructureConfigInterface} from "../../RcsbFvStructure/RcsbFvStructure";
|
|
|
+import {
|
|
|
+ CustomViewInterface,
|
|
|
+ FeatureBlockInterface
|
|
|
+} from "../../RcsbFvSequence/SequenceViews/CustomView/CustomView";
|
|
|
+import {
|
|
|
+} from "../../RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager";
|
|
|
+import {ViewerProps} from "@rcsb/rcsb-molstar/build/src/viewer";
|
|
|
+import { RcsbPreset } from "@rcsb/rcsb-molstar/build/src/viewer/helpers/preset";
|
|
|
+import { updateSiteColors } from "./UniTmpColor";
|
|
|
+import { fetchHtpDescriptor, fetchPdbtmJsvLibDescriptor, htpDescriptorToTrackData, jsvLibDescriptorToTrackData } from "./UniTmpHelper";
|
|
|
|
|
|
|
|
|
-export function createFeatureViewerConfing(pdbEntry: string, labelAsymId: string) {
|
|
|
- const modelId = `${pdbEntry}_model`;
|
|
|
+export async function createFeatureViewerConfing(params: { pdbEntry: string, pdbtmEntry: string, htpEntry: string, labelAsymId: string, side1: string }) {
|
|
|
+ const modelId = `${params.pdbEntry}_model`;
|
|
|
+
|
|
|
+ const rowConfig: Array<RcsbFvRowConfigInterface> = [
|
|
|
+ {
|
|
|
+ trackId: "sequenceTrack",
|
|
|
+ trackHeight: 20,
|
|
|
+ trackColor: "#F9F9F9",
|
|
|
+ displayType: RcsbFvDisplayTypes.SEQUENCE,
|
|
|
+ nonEmptyDisplay: true,
|
|
|
+ rowTitle: "N/A",
|
|
|
+ trackData: [
|
|
|
+ {
|
|
|
+ begin: 1,
|
|
|
+ value: "N/A"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ];
|
|
|
|
|
|
const fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
|
|
|
- boardId: `${pdbEntry}_board`,
|
|
|
+ boardId: `${params.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});
|
|
|
+ stateManager.selectionState.clearSelection("select", {modelId: modelId, labelAsymId: params.labelAsymId});
|
|
|
if(sequenceRegion.length > 0) {
|
|
|
const regions = sequenceRegion.map(r => ({
|
|
|
modelId: modelId,
|
|
|
- labelAsymId: labelAsymId,
|
|
|
+ labelAsymId: params.labelAsymId,
|
|
|
region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface
|
|
|
}));
|
|
|
stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select");
|
|
@@ -57,36 +71,35 @@ export function createFeatureViewerConfing(pdbEntry: string, labelAsymId: string
|
|
|
end: r.region.end
|
|
|
})), "select", "set");
|
|
|
}else{
|
|
|
- plugin.clearSelection("select", {modelId: modelId, labelAsymId: labelAsymId})
|
|
|
+ plugin.clearSelection("select", {modelId: modelId, labelAsymId: params.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);
|
|
|
+ plugin.cameraFocus(modelId, params.labelAsymId, 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,
|
|
|
+ labelAsymId: params.labelAsymId,
|
|
|
begin: e.begin,
|
|
|
end: e.end ?? e.begin
|
|
|
});
|
|
|
plugin.select(elements.map(e=>({
|
|
|
modelId: modelId,
|
|
|
- labelAsymId: labelAsymId,
|
|
|
+ labelAsymId: params.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");
|
|
|
+ const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, params.labelAsymId, "select");
|
|
|
if(sel == null) {
|
|
|
pfv.clearSelection("select");
|
|
|
plugin.resetCamera();
|
|
@@ -95,12 +108,62 @@ export function createFeatureViewerConfing(pdbEntry: string, labelAsymId: string
|
|
|
}
|
|
|
},
|
|
|
structureHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
|
|
|
- const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "hover");
|
|
|
+ const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, params.labelAsymId, "hover");
|
|
|
if(sel == null)
|
|
|
pfv.clearSelection("hover");
|
|
|
else
|
|
|
pfv.setSelection({elements:sel.regions, mode:"hover"});
|
|
|
}
|
|
|
}
|
|
|
- return fvConfig;
|
|
|
+
|
|
|
+ const block: FeatureBlockInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
|
|
|
+ blockId: `${params.pdbEntry}_${params.labelAsymId}_block_id`,
|
|
|
+ featureViewConfig: [fvConfig]
|
|
|
+ };
|
|
|
+
|
|
|
+ const customConfig: CustomViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
|
|
|
+ blockConfig:[block]
|
|
|
+ }
|
|
|
+
|
|
|
+ const sequenceConfig = {
|
|
|
+ title: "UniTmp example",
|
|
|
+ subtitle: `HTP entry ${params.htpEntry}`,
|
|
|
+ config: customConfig
|
|
|
+ };
|
|
|
+
|
|
|
+ const molstarConfig: RcsbFvStructureConfigInterface<LoadMolstarInterface<unknown,unknown>,{viewerProps:Partial<ViewerProps>}> = {
|
|
|
+ loadConfig: {
|
|
|
+ loadMethod: LoadMethod.loadStructureFromUrl,
|
|
|
+ loadParams: {
|
|
|
+ //url: `https://pdbtm.unitmp.org/api/v1/entry/${pdbEntry}.trpdb`,
|
|
|
+ url: `https://www.ebi.ac.uk/pdbe/entry-files/download/${params.pdbEntry}_updated.cif`,
|
|
|
+ format: 'mmcif',
|
|
|
+ isBinary: false,
|
|
|
+ id: `${params.pdbEntry}_model`,
|
|
|
+ reprProvider: RcsbPreset
|
|
|
+ }
|
|
|
+ },
|
|
|
+ structureViewerConfig: {
|
|
|
+ viewerProps:{
|
|
|
+ showImportControls: true,
|
|
|
+ showSessionControls: false,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ updateSiteColors(params.side1 as any);
|
|
|
+ const htpDescriptor = await fetchHtpDescriptor(params.htpEntry);
|
|
|
+ const jsvlibDescriptor = await fetchPdbtmJsvLibDescriptor(params.pdbtmEntry);
|
|
|
+
|
|
|
+ let sequence = htpDescriptor.Sequence.Seq;
|
|
|
+ sequence = sequence.replace(/\s+/g, '');
|
|
|
+
|
|
|
+ fvConfig.boardConfig.length = parseInt(htpDescriptor.Sequence['@attributes'].Length);
|
|
|
+ fvConfig.rowConfig[0].rowTitle = `${htpDescriptor['@attributes'].id} sequence`;
|
|
|
+ rowConfig[0].trackData![0].value = sequence;
|
|
|
+ rowConfig.push(...htpDescriptorToTrackData(htpDescriptor));
|
|
|
+
|
|
|
+ rowConfig.push(...jsvLibDescriptorToTrackData(jsvlibDescriptor));
|
|
|
+
|
|
|
+ return { sequenceConfig: sequenceConfig, molstarConfig: molstarConfig };
|
|
|
}
|