|
@@ -14,25 +14,33 @@ import { BuiltInTrajectoryFormat } from 'molstar/lib/mol-plugin-state/formats/tr
|
|
|
import { TrajectoryHierarchyPresetProvider } from 'molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset';
|
|
|
|
|
|
export class ModelLoader {
|
|
|
- async load<P = {}>(load: LoadParams, props?: PresetProps, matrix?: Mat4, reprProvider?: TrajectoryHierarchyPresetProvider<P>, params?: P) {
|
|
|
+ async load<P = {}, S={}>(load: LoadParams, props?: PresetProps, matrix?: Mat4, reprProvider?: TrajectoryHierarchyPresetProvider<P, S>, params?: P) {
|
|
|
const { fileOrUrl, format, isBinary } = load;
|
|
|
|
|
|
const data = fileOrUrl instanceof File
|
|
|
? (await this.plugin.builders.data.readFile({ file: Asset.File(fileOrUrl), isBinary })).data
|
|
|
: await this.plugin.builders.data.download({ url: fileOrUrl, isBinary });
|
|
|
- await this.handleTrajectory<P>(data, format, props, matrix, reprProvider, params);
|
|
|
+
|
|
|
+ return await this.handleTrajectory<P, S>(data, format, props, matrix, reprProvider, params);
|
|
|
}
|
|
|
|
|
|
- async parse<P = {}>(parse: ParseParams, props?: PresetProps & { dataLabel?: string }, matrix?: Mat4, reprProvider?: TrajectoryHierarchyPresetProvider<P>, params?: P) {
|
|
|
+ async parse<P = {}, S={}>(parse: ParseParams, props?: PresetProps & { dataLabel?: string }, matrix?: Mat4, reprProvider?: TrajectoryHierarchyPresetProvider<P, S>, params?: P) {
|
|
|
const { data, format } = parse;
|
|
|
const _data = await this.plugin.builders.data.rawData({ data, label: props?.dataLabel });
|
|
|
- await this.handleTrajectory(_data, format, props, matrix, reprProvider, params);
|
|
|
+ return await this.handleTrajectory(_data, format, props, matrix, reprProvider, params);
|
|
|
}
|
|
|
|
|
|
- private async handleTrajectory<P = {}>(data: any, format: BuiltInTrajectoryFormat, props?: PresetProps, matrix?: Mat4, reprProvider?: TrajectoryHierarchyPresetProvider<P>, params?: P) {
|
|
|
+ private async handleTrajectory<P = {}, S = {}>(
|
|
|
+ data: any,
|
|
|
+ format: BuiltInTrajectoryFormat,
|
|
|
+ props?: PresetProps,
|
|
|
+ matrix?: Mat4,
|
|
|
+ reprProvider?: TrajectoryHierarchyPresetProvider<P, S>,
|
|
|
+ params?: P
|
|
|
+ ): Promise<S|ReturnType<typeof RcsbPreset.apply>|undefined> {
|
|
|
const trajectory = await this.plugin.builders.structure.parseTrajectory(data, format);
|
|
|
if (reprProvider) {
|
|
|
- await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, reprProvider, { ...params } as P);
|
|
|
+ return this.plugin.builders.structure.hierarchy.applyPreset(trajectory, reprProvider, params);
|
|
|
} else {
|
|
|
const selector = await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, RcsbPreset, {
|
|
|
preset: props || { kind: 'standard', assemblyId: '' }
|
|
@@ -49,6 +57,7 @@ export class ModelLoader {
|
|
|
.insert(StateTransforms.Model.TransformStructureConformation, params);
|
|
|
await this.plugin.runTask(this.plugin.state.data.updateTree(b));
|
|
|
}
|
|
|
+ return selector;
|
|
|
}
|
|
|
|
|
|
}
|