Skip to content

Commit 966bda7

Browse files
further draft find or create entry
1 parent 8a4e58b commit 966bda7

File tree

2 files changed

+10
-2
lines changed
  • molstar-extension/src

2 files changed

+10
-2
lines changed

molstar-extension/src/extensions/volumes-and-segmentations/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export async function findOrCreateVolsegEntry(entryId: string, source: string, p
7373
const nodes = plugin.state.data.selectQ(q => q.ofType(VolsegEntry)).map(cell => cell?.obj).filter(isDefined);
7474
const targetNode = nodes.find(n => n.data.entryId === entryId && n.data.source === source);
7575
debugger;
76+
const globalStateNode = plugin.state.data.selectQ(q => q.ofType(VolsegGlobalState))[0];
77+
if (!globalStateNode) {
78+
await plugin.state.data.build().toRoot().apply(VolsegGlobalStateFromRoot, {}, { state: { isGhost: !DEBUGGING } }).commit();
79+
}
7680
if (targetNode) {
7781
// TODO: return selector?
7882
// return targetNode;
@@ -93,8 +97,9 @@ export async function findOrCreateVolsegEntry(entryId: string, source: string, p
9397
// source: SourceChoice.PDSelect(),
9498
// entryId: ParamDefinition.Text('emd-1832', { description: 'Entry identifier, including the source prefix, e.g. "emd-1832"' }),
9599
// };
96-
debugger;
97100
const entryNode = await plugin.state.data.build().toRoot().apply(VolsegEntryFromRoot, entryParams).commit();
101+
await plugin.state.data.build().to(entryNode).apply(VolsegStateFromEntry, {}, { state: { isGhost: !DEBUGGING } }).commit();
102+
debugger;
98103
return entryNode;
99104
}
100105
}

molstar-extension/src/viewer/app.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { StateObjectRef } from 'molstar/lib/mol-state';
3030
import { Color } from 'molstar/lib/mol-util/color';
3131
import 'molstar/lib/mol-util/polyfill';
3232
import { ObjectKeys } from 'molstar/lib/mol-util/type-helpers';
33-
import { Volseg } from '../extensions/volumes-and-segmentations';
33+
import { Volseg, findOrCreateVolsegEntry } from '../extensions/volumes-and-segmentations';
3434
import { CVSXSpec } from '../extensions/cvsx-extension/behaviour';
3535
import { loadCVSXFromAnything } from '../extensions/cvsx-extension';
3636

@@ -195,6 +195,9 @@ export class Viewer {
195195
plugin.builders.structure.representation.registerPreset(ViewerAutoPreset);
196196
}
197197
});
198+
// const nn = await findOrCreateVolsegEntry('emd-1832', 'emdb', plugin)
199+
// console.log(nn);
200+
// debugger;
198201
return new Viewer(plugin);
199202
}
200203

0 commit comments

Comments
 (0)