Quellcode durchsuchen

asymId parameter for assembly

bioinsilico vor 2 Jahren
Ursprung
Commit
09fcbbf837

+ 1 - 1
package.json

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

+ 3 - 1
src/RcsbFv3D/RcsbFv3DAssembly.tsx

@@ -39,6 +39,7 @@ export interface RcsbFv3DAssemblyInterface {
     config: {
         entryId: string;
         assemblyId?: string;
+        asymId?: string;
         title?: string;
         subtitle?: string;
     };
@@ -91,7 +92,8 @@ export class RcsbFv3DAssembly extends RcsbFv3DAbstract<
             structureViewerBehaviourObserver: new AssemblyBehaviourObserver<AssemblyLoadMolstarType,LoadMolstarReturnType>(
                 new MolstarAssemblyLoader({
                     entryId: params.config.entryId,
-                    assemblyId: typeof (params.config.assemblyId) === "string" && params.config.assemblyId?.length > 0 ? params.config.assemblyId : '1'
+                    assemblyId: typeof (params.config.assemblyId) === "string" && params.config.assemblyId?.length > 0 ? params.config.assemblyId : '1',
+                    asymId: params.config.asymId
                 })
             ),
             cssConfig: params.cssConfig

+ 1 - 4
src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/AssemblyPfvManagerFactory.tsx

@@ -3,7 +3,6 @@ import {
 } from "@rcsb/rcsb-saguaro-app/build/dist/RcsbFvWeb/RcsbFvModule/RcsbFvModuleInterface";
 import {
     ChainInfo, OperatorInfo,
-    SaguaroPluginModelMapType, ViewerActionManagerInterface
 } from "../../../../RcsbFvStructure/StructureViewerInterface";
 import {
     InstanceSequenceConfig
@@ -29,8 +28,6 @@ import {
     PfvManagerInterface,
     PfvManagerFactoryInterface
 } from "../PfvManagerFactoryInterface";
-import {ColorTheme} from "molstar/lib/mol-theme/color";
-import {PLDDTConfidenceColorThemeProvider} from "molstar/lib/extensions/model-archive/quality-assessment/color/plddt";
 
 interface AssemblyPfvManagerInterface extends PfvManagerFactoryConfigInterface<undefined>{
     useOperatorsFlag?: boolean;
@@ -76,7 +73,7 @@ class AssemblyPfvManager extends AbstractPfvManager<{instanceSequenceConfig?: In
                 this.stateManager.assemblyModelSate.getString("entryId"),
                 {
                     ...this.instanceSequenceConfig,
-                    defaultValue: config.defaultAuthId,
+                    defaultValue: config.defaultAuthId ?? this.instanceSequenceConfig?.defaultValue,
                     onChangeCallback: onChangeCallback.get(this.stateManager.assemblyModelSate.getString("entryId")),
                     beforeChangeCallback: (x: PolymerEntityInstanceInterface)=>{
                         this.stateManager.assemblyModelSate.set({entryId:x.entryId, labelAsymId: x.asymId});

+ 5 - 2
src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarUtils/MolstarAssemblyLoader.ts

@@ -18,9 +18,11 @@ export class MolstarAssemblyLoader implements StructureLoaderInterface<
 
     private readonly entryId: string;
     private readonly assemblyId: string;
-    constructor(config: {entryId: string; assemblyId: string;}){
+    private readonly asymId?: string;
+    constructor(config: {entryId: string; assemblyId: string; asymId?:string;}){
         this.entryId = config.entryId;
         this.assemblyId = config.assemblyId;
+        this.asymId = config.asymId;
     }
 
     async load(structureViewer: ViewerActionManagerInterface<LoadMolstarInterface<AssemblyTrajectoryParamsType, LoadMolstarReturnType>, LoadMolstarReturnType>): Promise<LoadMolstarReturnType|undefined> {
@@ -32,7 +34,8 @@ export class MolstarAssemblyLoader implements StructureLoaderInterface<
                 id: this.entryId,
                 params: {
                     assemblyId: this.assemblyId,
-                    modelIndex: 0
+                    modelIndex: 0,
+                    asymId: this.asymId
                 }
             }
         });

+ 1 - 1
src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AssemblyRepresentationPresetProvider.ts

@@ -95,7 +95,7 @@ export const AssemblyRepresentationPresetProvider = StructureRepresentationPrese
                 type: expression.type
             },{
                 initialState:{
-                    isHidden: expression.tag == "water" ? true : false
+                    isHidden: expression.tag == "water"
                 }
             });
             if (comp?.cell?.state && expression.tag == "water") {

+ 30 - 6
src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AssemblyTrajectoryPresetProvider.ts

@@ -1,5 +1,4 @@
 import {
-    PresetStructureRepresentations,
     StructureRepresentationPresetProvider
 } from "molstar/lib/mol-plugin-state/builder/structure/representation-preset";
 import {ParamDefinition, ParamDefinition as PD} from 'molstar/lib/mol-util/param-definition';
@@ -9,16 +8,15 @@ 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 {PluginContext} from "molstar/lib/mol-plugin/context";
-import {AlignmentTrajectoryParamsType} from "./AlignmentTrajectoryPresetProvider";
 import {AssemblyRepresentationPresetProvider} from "./AssemblyRepresentationPresetProvider";
+import {Structure, StructureElement, StructureProperties as SP} from "molstar/lib/mol-model/structure";
 
 type StructureObject = StateObjectSelector<PluginStateObject.Molecule.Structure, StateTransformer<StateObject<any, StateObject.Type<any>>, StateObject<any, StateObject.Type<any>>, any>>
 
-
-
 export type AssemblyTrajectoryParamsType = {
     assemblyId:string;
     modelIndex:number;
+    asymId?:string;
 }
 
 export const AssemblyTrajectoryPresetProvider = TrajectoryHierarchyPresetProvider({
@@ -28,17 +26,43 @@ export const AssemblyTrajectoryPresetProvider = TrajectoryHierarchyPresetProvide
     },
     params: (trajectory: PluginStateObject.Molecule.Trajectory | undefined, plugin: PluginContext): ParamDefinition.For<AssemblyTrajectoryParamsType> => ({
         assemblyId: PD.Value<string>("1"),
+        asymId: PD.Value<string|undefined>(undefined),
         modelIndex: PD.Value<number>(0)
     }),
     async apply(trajectory, params, plugin) {
         const builder = plugin.builders.structure;
         const model = await builder.createModel(trajectory, {modelIndex: params.modelIndex});
         const modelProperties = await builder.insertModelProperties(model);
-        const assemblyId: string = params.assemblyId;
-        const structure: StructureObject = await builder.createStructure(
+        let assemblyId: string = params.assemblyId;
+        let structure: StructureObject = await builder.createStructure(
             modelProperties,
             (assemblyId != "" && assemblyId != "0") ? {name: 'assembly', params:{id:assemblyId}} : {name:"model", params:{}}
         );
+        if(params.asymId) {
+            let asymCheck: boolean = false;
+            let assemblyId: number = 1;
+            do {
+                plugin.managers.structure.hierarchy.remove([
+                    plugin.managers.structure.hierarchy.current.structures[plugin.managers.structure.hierarchy.current.structures.length - 1]
+                ]);
+                structure = await builder.createStructure(modelProperties, {name: 'assembly', params:{id:(assemblyId++).toString()}});
+                const cell = structure.cell;
+                if (cell) {
+                    const units = structure.cell?.obj?.data.units;
+                    const strData: Structure = (cell.obj as StateObject<Structure>).data;
+                    if (units) {
+                        const l = StructureElement.Location.create(strData);
+                        for (const unit of units) {
+                            StructureElement.Location.set(l, strData, unit, unit.elements[0]);
+                            asymCheck = (SP.chain.label_asym_id(l) == params.asymId);
+                            if (asymCheck)
+                                break;
+                        }
+                    }
+                }
+            } while (!asymCheck);
+        }
+
         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, AssemblyRepresentationPresetProvider);

+ 7 - 5
src/examples/assembly/index.ts

@@ -21,20 +21,22 @@ document.addEventListener("DOMContentLoaded", function(event) {
         return result;
     }
 
-    const args: {pdbId:string} = getJsonFromUrl().pdbId ? getJsonFromUrl() : {pdbId:"1A6D"};
+    const args: {pdbId:string} = getJsonFromUrl().pdbId ? getJsonFromUrl() : {pdbId:"1XXX"};
 
-    const sequenceConfig = {
+    const config = {
         entryId: args.pdbId,
         title: "Title " + args.pdbId,
-        subtitle: "Subtitle for " + args.pdbId
+        subtitle: "Subtitle for " + args.pdbId,
+        asymId: "E"
     };
 
     const panel3d = new RcsbFv3DAssembly({
         elementId: "null",
-        config: sequenceConfig,
+        config: config,
         instanceSequenceConfig:{
             dropdownTitle: "Chain",
-            module: "interface"
+            module: "interface",
+            defaultValue: "E"
         },
         additionalConfig: {
             boardConfig: {