Переглянути джерело

filtering model assembly model state to find modelId

bioinsilico 3 роки тому
батько
коміт
012d2306c8

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@rcsb/rcsb-saguaro-3d",
-  "version": "1.3.2",
+  "version": "1.3.3",
   "description": "RCSB Molstar/Saguaro Web App",
   "main": "build/dist/app.js",
   "files": [

+ 3 - 0
src/RcsbFvSequence/SequenceViews/AssemblyView/AssemblyModelSate.ts

@@ -49,6 +49,9 @@ export class AssemblyModelSate {
         this.modelMap.forEach((v,k)=>f(v,k));
     }
 
+    public entries(): IterableIterator<[string,{entryId: string; assemblyId: string; chains:Array<ChainInfo>;}]>{
+        return this.modelMap.entries();
+    }
 
     public setOperator(asymId?:string, opName?:string) {
         const currentChainInfo: ChainInfo|undefined = this.getChainInfo(asymId??this.state.labelAsymId);

+ 5 - 2
src/RcsbFvSequence/SequenceViews/AssemblyView/AssemblyView.tsx

@@ -204,8 +204,11 @@ export class AssemblyView extends AbstractView<AssemblyViewInterface & AbstractV
                     onChangeCallback: onChangeCallback.get(this.assemblyModelSate.getString("entryId")),
                     beforeChangeCallback: (x: InstanceSequenceOnchangeInterface)=>{
                         this.assemblyModelSate.set({entryId:x.pdbId, labelAsymId: x.asymId});
-                        //TODO this will only work when modelId is equal to pdbId
-                        const operator: OperatorInfo|undefined = getOperator(this.assemblyModelSate.getMap().get(x.pdbId)!, defaultAuthId, operatorNameContainer.operatorName);
+                        const entryMap:[string, {entryId: string, assemblyId: string, chains: ChainInfo[]}] | undefined = Array.from(this.assemblyModelSate.entries()).find((e)=>(e[1].entryId === x.pdbId));
+                        if(!entryMap){
+                            throw `Error: no modelId was found for ${x.pdbId}`;
+                        }
+                        const operator: OperatorInfo|undefined = getOperator(this.assemblyModelSate.getMap().get(entryMap[0])!, defaultAuthId, operatorNameContainer.operatorName);
                         this.addOperatorButton(operator?.name);
                         this.assemblyModelSate.setOperator(x.asymId,operator?.name);
                         operatorNameContainer.operatorName = undefined;

+ 8 - 6
src/RcsbFvStructure/StructurePlugins/StructureRepresentation.ts

@@ -8,11 +8,13 @@ import {StateObjectSelector} from "molstar/lib/mol-state";
 import {PluginStateObject} from "molstar/lib/mol-plugin-state/objects";
 import {StateObject} from "molstar/lib/mol-state/object";
 import {StateTransformer} from "molstar/lib/mol-state/transformer";
+import {Structure, StructureElement, StructureProperties as SP} from "molstar/lib/mol-model/structure";
+import {ChainInfo} from "../SaguaroPluginInterface";
 
 type StructureObject = StateObjectSelector<PluginStateObject.Molecule.Structure, StateTransformer<StateObject<any, StateObject.Type<any>>, StateObject<any, StateObject.Type<any>>, any>>
 
 const RcsbParams = () => ({
-    preset: PD.Value<{assemblyId:string;}>({ assemblyId: '1' })
+    preset: PD.Value<{assemblyId:string;modelIndex:number;}>({ assemblyId: '1' , modelIndex:0})
 });
 
 export const RcsbRepresentationPreset: TrajectoryHierarchyPresetProvider = TrajectoryHierarchyPresetProvider({
@@ -23,7 +25,7 @@ export const RcsbRepresentationPreset: TrajectoryHierarchyPresetProvider = Traje
     params: RcsbParams,
     async apply(trajectory, params, plugin) {
         const builder = plugin.builders.structure;
-        const model = await builder.createModel(trajectory, {modelIndex: 0});
+        const model = await builder.createModel(trajectory, {modelIndex: params.preset.modelIndex});
         const modelProperties = await builder.insertModelProperties(model);
         const assemblyId: string = params.preset.assemblyId;
         const structure: StructureObject = await builder.createStructure(
@@ -33,21 +35,21 @@ export const RcsbRepresentationPreset: TrajectoryHierarchyPresetProvider = Traje
         const structureProperties: StructureObject = await builder.insertStructureProperties(structure);
         const unitcell: StateObjectSelector | undefined = await builder.tryCreateUnitcell(modelProperties, undefined, { isHidden: true });
         const representation: StructureRepresentationPresetProvider.Result | undefined = await plugin.builders.structure.representation.applyPreset(structureProperties, PresetStructureRepresentations.auto);
-        components:
+        water:
         for (const c of plugin.managers.structure.hierarchy.currentComponentGroups) {
             for (const comp of c) {
                 if(comp.cell.obj?.label === "Water") {
                     plugin.managers.structure.component.toggleVisibility(c);
-                    break components;
+                    break water;
                 }
             }
         }
-        components:
+        polymer:
         for (const c of plugin.managers.structure.hierarchy.currentComponentGroups) {
             for (const comp of c) {
                 if(comp.cell.obj?.label === "Polymer") {
                     plugin.managers.structure.component.updateRepresentationsTheme([comp], { color: 'chain-id' });
-                    break components;
+                    break polymer;
                 }
             }
         }

+ 0 - 0
src/examples/external-mapping/StructurePreset → src/examples/external-mapping/StructurePreset.ts