Explorar o código

uniprot title component

bioinsilico %!s(int64=2) %!d(string=hai) anos
pai
achega
b02a6b4b07
Modificáronse 20 ficheiros con 667 adicións e 487 borrados
  1. 392 373
      package-lock.json
  2. 2 2
      package.json
  3. 2 4
      src/RcsbFv3D/RcsbFv3DUniprot.tsx
  4. 28 30
      src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory.ts
  5. 32 2
      src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory/UniprotRowMarkComponent.tsx
  6. 35 0
      src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory/UniprotRowTitleComponent.tsx
  7. 8 4
      src/RcsbFvState/AssemblyModelSate.ts
  8. 6 5
      src/RcsbFvState/RcsbFvStateInterface.ts
  9. 3 3
      src/RcsbFvState/RcsbFvStateManager.ts
  10. 11 13
      src/RcsbFvStructure/StructureUtils/MolstarAlignmentLoader.ts
  11. 4 0
      src/RcsbFvStructure/StructureViewerBehaviour/AssemblyBehaviour.ts
  12. 64 3
      src/RcsbFvStructure/StructureViewerBehaviour/UniprotBehaviour.ts
  13. 1 0
      src/RcsbFvStructure/StructureViewerBehaviourInterface.ts
  14. 2 0
      src/RcsbFvStructure/StructureViewerInterface.ts
  15. 17 0
      src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager.ts
  16. 3 3
      src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarCallbackManager.ts
  17. 35 30
      src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarModelMapManager.ts
  18. 17 12
      src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AlignmentRepresentationPresetProvider.ts
  19. 0 3
      src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AlignmentTrajectoryPresetProvider.ts
  20. 5 0
      src/RcsbFvStructure/StructureViewers/StructureViewer.ts

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 392 - 373
package-lock.json


+ 2 - 2
package.json

@@ -82,8 +82,8 @@
   "dependencies": {
     "@rcsb/rcsb-api-tools": "^4.1.0",
     "@rcsb/rcsb-molstar": "^2.5.5",
-    "@rcsb/rcsb-saguaro": "^2.2.9",
-    "@rcsb/rcsb-saguaro-app": "^4.4.3",
+    "@rcsb/rcsb-saguaro": "^2.2.15",
+    "@rcsb/rcsb-saguaro-app": "^4.4.9",
     "molstar": "^3.13.0"
   },
   "bugs": {

+ 2 - 4
src/RcsbFv3D/RcsbFv3DUniprot.tsx

@@ -50,9 +50,7 @@ export class RcsbFv3DUniprot extends RcsbFv3DAbstract<{upAcc:string},LoadMolstar
                         upAcc:params.config.upAcc
                     },
                     buildPfvOnMount: true,
-                    pfvManagerFactory: new UniprotPfvManagerFactory<LoadMolstarInterface>({
-                        structureLoader: new MolstarAlignmentLoader()
-                    }),
+                    pfvManagerFactory: new UniprotPfvManagerFactory<LoadMolstarInterface>(),
                     callbackManagerFactory: new UniprotCallbackManagerFactory<LoadMolstarInterface>({pluginLoadParamsDefinition})
                 }
             },
@@ -64,7 +62,7 @@ export class RcsbFv3DUniprot extends RcsbFv3DAbstract<{upAcc:string},LoadMolstar
                 }
             },
             structureViewer: new StructureViewer<LoadMolstarInterface,{viewerElement:string|HTMLElement,viewerProps:Partial<ViewerProps>}>( new MolstarManagerFactory() ),
-            structureViewerBehaviourObserver: new UniprotBehaviourObserver<LoadMolstarInterface>()
+            structureViewerBehaviourObserver: new UniprotBehaviourObserver<LoadMolstarInterface>(new MolstarAlignmentLoader())
         });
     }
 

+ 28 - 30
src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory.ts

@@ -16,49 +16,31 @@ import {
     AlignmentRequestContextType
 } from "@rcsb/rcsb-saguaro-app/build/dist/RcsbFvWeb/RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AlignmentTrackFactory";
 import {AlignmentResponse, TargetAlignment} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Borrego/GqlTypes";
-import {StructureLoaderInterface} from "../../../../RcsbFvStructure/StructureUtils/StructureLoaderInterface";
-import {
-    ViewerActionManagerInterface,
-    ViewerCallbackManagerInterface
-} from "../../../../RcsbFvStructure/StructureViewerInterface";
+import {UniprotRowTitleComponent} from "./UniprotPfvManagerFactory/UniprotRowTitleComponent";
 import {UniprotRowMarkComponent} from "./UniprotPfvManagerFactory/UniprotRowMarkComponent";
 
+
 interface UniprotPfvManagerInterface<R> extends PfvManagerFactoryConfigInterface<R,{context: UniprotSequenceOnchangeInterface;}> {
     upAcc:string;
 }
 
 export class UniprotPfvManagerFactory<R> implements PfvManagerFactoryInterface<{upAcc:string},R,{context: UniprotSequenceOnchangeInterface;}> {
 
-    private readonly structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;},{entryId:string;entityId:string;}]>;
-
-    constructor(config: {
-        structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;},{entryId:string;entityId:string;}]>
-    }) {
-        this.structureLoader = config.structureLoader;
-    }
-
     getPfvManager(config: UniprotPfvManagerInterface<R>): PfvManagerInterface {
-        return new UniprotPfvManager({
-            ...config,
-            structureLoader:this.structureLoader
-        });
+        return new UniprotPfvManager(config);
     }
+
 }
 
 class UniprotPfvManager<R> extends AbstractPfvManager<{upAcc:string},R,{context: UniprotSequenceOnchangeInterface;}>{
 
     private readonly upAcc:string;
-    private readonly structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;},{entryId:string;entityId:string;}]>;
 
     private module:RcsbFvModulePublicInterface;
-    private structureRef: {entryId:string;entityId:string;};
 
-    constructor(config:UniprotPfvManagerInterface<R> & {
-        structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;},{entryId:string;entityId:string;}]>
-    }) {
+    constructor(config:UniprotPfvManagerInterface<R>) {
         super(config);
         this.upAcc = config.upAcc;
-        this.structureLoader = config.structureLoader;
     }
 
     async create(): Promise<RcsbFvModulePublicInterface | undefined> {
@@ -76,9 +58,20 @@ class UniprotPfvManager<R> extends AbstractPfvManager<{upAcc:string},R,{context:
                     alignment: (alignmentContext: AlignmentRequestContextType, targetAlignment: TargetAlignment) => new Promise((resolve)=>{
                         resolve({
                             rowMark:{
-                                externalComponent: UniprotRowMarkComponent,
-                                clickCallback:()=>{
-                                    this.loadAlignment(alignmentContext,targetAlignment);
+                                externalRowMark: {
+                                    component:UniprotRowMarkComponent,
+                                    props:{
+                                        rowRef:TagDelimiter.parseEntity(targetAlignment.target_id!),
+                                        stateManager: this.stateManager
+                                    }
+                                },
+                                clickCallback:() => this.loadAlignment(alignmentContext,targetAlignment)
+                            },
+                            externalRowTitle: {
+                                rowTitleComponent:UniprotRowTitleComponent,
+                                rowTitleAdditionalProps:{
+                                    alignmentContext,
+                                    targetAlignment
                                 }
                             }
                         });
@@ -94,14 +87,19 @@ class UniprotPfvManager<R> extends AbstractPfvManager<{upAcc:string},R,{context:
     private async readyStateLoad(): Promise<void> {
         const alignments: AlignmentResponse = await this.module.getAlignmentResponse();
         if(alignments.target_alignment && alignments.target_alignment.length > 0 && typeof alignments.target_alignment[0]?.target_id === "string"){
-            this.structureRef = TagDelimiter.parseEntity(alignments.target_alignment[0]?.target_id);
-            await this.loadAlignment({queryId:this.upAcc}, alignments.target_alignment[0]);
+            this.loadAlignment({queryId:this.upAcc}, alignments.target_alignment[0]);
         }
     }
 
-    private async loadAlignment(alignmentContext: AlignmentRequestContextType, targetAlignment: TargetAlignment): Promise<void> {
+    private loadAlignment(alignmentContext: AlignmentRequestContextType, targetAlignment: TargetAlignment):void {
         if(typeof targetAlignment.target_id === "string") {
-            await this.structureLoader.load(this.structureViewer,this.structureRef,TagDelimiter.parseEntity(targetAlignment.target_id));
+            this.stateManager.next<"model-change", {pdb:{entryId:string;entityId:string;}}>({
+                type:"model-change",
+                view:"1d-view",
+                data:{
+                    pdb:TagDelimiter.parseEntity(targetAlignment.target_id)
+                }
+            });
         }
     }
 

+ 32 - 2
src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory/UniprotRowMarkComponent.tsx

@@ -6,12 +6,16 @@
 import React from "react";
 import classes from '../../../../../styles/UniprotPfvStyle.module.scss';
 import {Property} from "csstype";
-import {asyncScheduler} from "rxjs";
+import {asyncScheduler, Subscription} from "rxjs";
+import {RcsbFvStateManager} from "../../../../../RcsbFvState/RcsbFvStateManager";
+import {TagDelimiter} from "@rcsb/rcsb-saguaro-app";
 
 interface UniprotRowMarkInterface  {
     isGlowing:boolean;
     clickCallback?:()=>void;
     hoverCallback?:()=>void;
+    rowRef:{entryId:string;entityId:string;};
+    stateManager: RcsbFvStateManager;
 }
 
 interface UniprotRowMarkState {
@@ -23,6 +27,11 @@ export class UniprotRowMarkComponent extends React.Component <UniprotRowMarkInte
 
     private readonly HOVER_COLOR: string = "#666";
     private readonly ACTIVE_COLOR: string = "#ccc";
+    private subscription: Subscription;
+
+    constructor(props:UniprotRowMarkInterface) {
+        super(props);
+    }
 
     readonly state: UniprotRowMarkState = {
         visibility: undefined,
@@ -39,8 +48,29 @@ export class UniprotRowMarkComponent extends React.Component <UniprotRowMarkInte
         );
     }
 
+    componentDidMount() {
+        this.subscribe();
+    }
+
+    componentWillUnmount() {
+        this.subscription?.unsubscribe();
+    }
+
+    private subscribe(): void{
+        this.subscription = this.props.stateManager.subscribe( async o=>{
+            if(o.type == "model-change" && o.view == "3d-view")
+                this.modelChange();
+        });
+    }
+
+    private modelChange(): void {
+       if(Array.from(this.props.stateManager.assemblyModelSate.getMap().keys()).includes(`${this.props.rowRef.entryId}${TagDelimiter.entity}${this.props.rowRef.entityId}`))
+           this.setState({visibility: "visible", borderLeftColor: this.ACTIVE_COLOR});
+       else if(this.state.visibility == "visible")
+           this.setState({visibility: undefined, borderLeftColor: undefined});
+    }
+
     private click(): void {
-        this.setState({visibility:  this.state.visibility === "visible" ? undefined : "visible", borderLeftColor: this.state.visibility === "visible" ? undefined : this.ACTIVE_COLOR});
         asyncScheduler.schedule(()=>this.props.clickCallback?.());
     }
 

+ 35 - 0
src/RcsbFvSequence/SequenceViews/RcsbView/PfvManagerFactoryImplementation/UniprotPfvManagerFactory/UniprotRowTitleComponent.tsx

@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2021 RCSB PDB and contributors, licensed under MIT, See LICENSE file for more info.
+* @author Joan Segura Mora <joan.segura@rcsb.org>
+*/
+
+import * as React from "react";
+import {RcsbFvRowTitleInterface} from "@rcsb/rcsb-saguaro/build/RcsbFv/RcsbFvRow/RcsbFvRowTitle";
+import {RcsbFvRowConfigInterface} from "@rcsb/rcsb-saguaro";
+import {
+    AlignmentRequestContextType
+} from "@rcsb/rcsb-saguaro-app/build/dist/RcsbFvWeb/RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AlignmentTrackFactory";
+import {TargetAlignment} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Borrego/GqlTypes";
+
+export class UniprotRowTitleComponent extends React.Component <RcsbFvRowTitleInterface & {alignmentContext: AlignmentRequestContextType, targetAlignment: TargetAlignment}, {}> {
+
+    private readonly configData : RcsbFvRowConfigInterface;
+    readonly state = {
+        expandTitle: false
+    };
+
+    constructor(props: RcsbFvRowTitleInterface & {alignmentContext: AlignmentRequestContextType, targetAlignment: TargetAlignment}) {
+        super(props);
+        this.configData = this.props.data;
+    }
+
+    public render(): JSX.Element{
+       return <div style={{textAlign:"right"}}>
+           {this.props.targetAlignment.target_id}
+           <input type={"checkbox"}/>
+           <input type={"checkbox"}/>
+           <input type={"checkbox"}/>
+       </div>;
+    }
+
+}

+ 8 - 4
src/RcsbFvState/AssemblyModelSate.ts

@@ -68,10 +68,14 @@ export class AssemblyModelSate {
     }
 
     private setFirstModel(): void{
-        this.state.modelId = Array.from(this.modelMap.keys())[0];
-        this.state.entryId = this.modelMap.get(this.state.modelId)!.entryId;
-        this.state.assemblyId = this.modelMap.get(this.state.modelId)!.assemblyId;
-        this.state.operator = undefined;
+        if(Array.from(this.modelMap.keys()).length == 0){
+           this.state = {};
+        }else{
+            this.state.modelId = Array.from(this.modelMap.keys())[0];
+            this.state.entryId = this.modelMap.get(this.state.modelId)!.entryId;
+            this.state.assemblyId = this.modelMap.get(this.state.modelId)!.assemblyId;
+            this.state.operator = undefined;
+        }
     }
 
 }

+ 6 - 5
src/RcsbFvState/RcsbFvStateInterface.ts

@@ -8,9 +8,10 @@ import {RcsbFvSelectorManager} from "./RcsbFvSelectorManager";
 import {AssemblyModelSate} from "./AssemblyModelSate";
 import {Subscription} from "rxjs";
 
-export type RcsbFvStateType = {
-    type: "feature-click"|"selection-change"|"hover-change"|"model-change"|"representation-change"|"pfv-change";
-    view: "1d-view" | "3d-view"
+export type RcsbFvStateType<T="feature-click",D=undefined> = {
+    type: "feature-click"|"selection-change"|"hover-change"|"model-change"|"representation-change"|"pfv-change"|T;
+    view: "1d-view" | "3d-view";
+    data?:D;
 };
 
 export interface RcsbFvStateInterface {
@@ -19,8 +20,8 @@ export interface RcsbFvStateInterface {
     readonly assemblyModelSate: AssemblyModelSate;
 
 
-    subscribe(o:(state:RcsbFvStateType)=>void): Subscription;
+    subscribe<T,D>(o:(state:RcsbFvStateType<T,D>)=>void): Subscription;
 
-    next(state:RcsbFvStateType): void;
+    next<T,D>(state:RcsbFvStateType<T,D>): void;
 
 }

+ 3 - 3
src/RcsbFvState/RcsbFvStateManager.ts

@@ -13,13 +13,13 @@ export class RcsbFvStateManager implements RcsbFvStateInterface {
     readonly assemblyModelSate: AssemblyModelSate = new AssemblyModelSate();
     readonly selectionState: RcsbFvSelectorManager = new RcsbFvSelectorManager();
 
-    private readonly subject: Subject<RcsbFvStateType> = new Subject<RcsbFvStateType>();
+    private readonly subject: Subject<RcsbFvStateType<any,any>> = new Subject<RcsbFvStateType>();
 
-    next(state: RcsbFvStateType): void {
+    next<T,D>(state: RcsbFvStateType<T,D>): void {
         this.subject.next(state);
     }
 
-    subscribe(o: (state: RcsbFvStateType) => void): Subscription {
+    subscribe<T,D>(o: (state: RcsbFvStateType<T,D>) => void): Subscription {
        return  this.subject.subscribe(o);
     }
 

+ 11 - 13
src/RcsbFvStructure/StructureUtils/MolstarAlignmentLoader.ts

@@ -23,43 +23,41 @@ import {
     AlignmentTrajectoryPresetProvider, TrajectoryParamsType
 } from "../StructureViewers/MolstarViewer/TrajectoryPresetProvider/AlignmentTrajectoryPresetProvider";
 
-export class MolstarAlignmentLoader implements StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <LoadMolstarInterface<TrajectoryParamsType>>,{entryId:string;entityId:string;},{entryId:string;entityId:string;}]> {
+export class MolstarAlignmentLoader implements StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <LoadMolstarInterface<TrajectoryParamsType>>,{entryId:string;entityId:string;}]> {
 
-    private readonly structureMap: Map<string,string|undefined> = new Map<string,string|undefined>();
+    private readonly structureMap: Set<string> = new Set<string>();
 
-    async load(structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface <LoadMolstarInterface<TrajectoryParamsType>>, ref: {entryId:string;entityId:string;}, pdb:{entryId:string;entityId:string;}): Promise<void> {
+    async load(structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface <LoadMolstarInterface<TrajectoryParamsType>>, pdb:{entryId:string;entityId:string;}): Promise<void> {
         const structureId: string = `${pdb.entryId}${TagDelimiter.entity}${pdb.entityId}`;
         if(!this.structureMap.has(structureId)){
             await structureViewer.load({
                 loadMethod: LoadMethod.loadPdbId,
                 loadParams:{
+                    id: structureId,
                     entryId:pdb.entryId,
                     reprProvider: AlignmentTrajectoryPresetProvider,
                     params:{
                         assemblyId: "1",
                         modelIndex: 0,
-                        ref:ref,
                         pdb: pdb
                     }
                 }
             });
             structureViewer.pluginCall(async (plugin)=>{
-                this.structureMap.set(
-                    structureId,
-                    plugin.managers.structure.hierarchy.current.structures[ plugin.managers.structure.hierarchy.current.structures.length -1].properties?.cell?.obj?.data?.units[0]?.model?.id
+                this.structureMap.add(
+                    structureId
                 );
 
             });
 
         } else {
-            structureViewer.pluginCall(async (plugin)=>{
-                const pdbStr: StructureRef|undefined = plugin.managers.structure.hierarchy.current.structures.find(s=>s.properties?.cell?.obj?.data?.units[0]?.model?.id == this.structureMap.get(structureId));
-                if(pdbStr) {
-                    plugin.managers.structure.hierarchy.remove([pdbStr]);
-                    this.structureMap.delete(structureId);
-                    await PluginCommands.Camera.Reset(plugin);
+            await structureViewer.removeStructure({
+                loadMethod: LoadMethod.loadPdbId,
+                loadParams:{
+                    id: structureId
                 }
             });
+            this.structureMap.delete(structureId);
             return;
         }
     }

+ 4 - 0
src/RcsbFvStructure/StructureViewerBehaviour/AssemblyBehaviour.ts

@@ -43,6 +43,10 @@ class AssemblyBehaviour<R> implements StructureViewerBehaviourInterface {
         this.subscription = this.subscribe();
     }
 
+    public modelChange(): void {
+        throw new Error("Method not implemented.");
+    }
+
     private subscribe(): Subscription {
         return this.stateManager.subscribe(async o=>{
             if(o.type == "selection-change" && o.view == "1d-view")

+ 64 - 3
src/RcsbFvStructure/StructureViewerBehaviour/UniprotBehaviour.ts

@@ -3,16 +3,77 @@
 * @author Joan Segura Mora <joan.segura@rcsb.org>
 */
 
-import {StructureViewerBehaviourObserverInterface} from "../StructureViewerBehaviourInterface";
+import {
+    StructureViewerBehaviourInterface,
+    StructureViewerBehaviourObserverInterface
+} from "../StructureViewerBehaviourInterface";
 import {ViewerActionManagerInterface, ViewerCallbackManagerInterface} from "../StructureViewerInterface";
 import {RcsbFvStateInterface} from "../../RcsbFvState/RcsbFvStateInterface";
+import {Subscription} from "rxjs";
+import {StructureLoaderInterface} from "../StructureUtils/StructureLoaderInterface";
 
-export class UniprotBehaviourObserver <R> implements StructureViewerBehaviourObserverInterface<R> {
+export class UniprotBehaviourObserver<R> implements StructureViewerBehaviourObserverInterface<R> {
 
-    observe(structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface<R>, stateManager: RcsbFvStateInterface): void {
+    private structureBehaviour: StructureViewerBehaviourInterface;
+    private readonly structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;}]>;
+
+    constructor(structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;}]>) {
+        this.structureLoader = structureLoader
+    }
+    public observe(
+        structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface<R>,
+        stateManager: RcsbFvStateInterface
+    ): void {
+        this.structureBehaviour = new UniprotBehaviour(structureViewer, stateManager, this.structureLoader);
+    }
+
+    public unsubscribe(): void {
+        this.structureBehaviour.unsubscribe();
+    }
+
+}
+
+class UniprotBehaviour<R> implements StructureViewerBehaviourInterface {
+
+    private readonly structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface<R>;
+    private readonly stateManager: RcsbFvStateInterface;
+    private readonly subscription: Subscription;
+    private readonly structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;}]>;
+
+    constructor(
+        structureViewer: ViewerCallbackManagerInterface & ViewerActionManagerInterface<R>,
+        stateManager: RcsbFvStateInterface,
+        structureLoader: StructureLoaderInterface<[ViewerCallbackManagerInterface & ViewerActionManagerInterface <R>,{entryId:string;entityId:string;}]>
+    ) {
+        this.structureViewer = structureViewer;
+        this.stateManager = stateManager;
+        this.structureLoader = structureLoader;
+        this.subscription = this.subscribe();
+    }
+
+    private subscribe(): Subscription {
+        return this.stateManager.subscribe<"model-change",{pdb:{entryId:string;entityId:string;}}>(async o=>{
+            if(o.type == "model-change" && o.view == "1d-view" && o.data)
+                await this.modelChange(o.data);
+        });
+    }
+
+    featureClick(): void {
+    }
+
+    hoverChange(): void {
+    }
+
+    selectionChange(): void {
     }
 
     unsubscribe(): void {
     }
 
+    async modelChange(data?:{pdb:{entryId:string;entityId:string;}}): Promise<void> {
+        if(data)
+            await this.structureLoader.load(this.structureViewer, data.pdb);
+        console.log(this.stateManager.assemblyModelSate.getMap());
+    }
+
 }

+ 1 - 0
src/RcsbFvStructure/StructureViewerBehaviourInterface.ts

@@ -15,5 +15,6 @@ export interface StructureViewerBehaviourInterface {
     selectionChange(): void;
     hoverChange(): void;
     featureClick(): void;
+    modelChange(): void;
     unsubscribe(): void;
 }

+ 2 - 0
src/RcsbFvStructure/StructureViewerInterface.ts

@@ -55,6 +55,7 @@ export interface ViewerCallbackManagerInterface {
 
 export interface ViewerActionManagerInterface<R> {
     load(loadConfig: R|Array<R>): Promise<void>;
+    removeStructure(removeConfig: R|Array<R>): Promise<void>;
     select(modelId:string, labelAsymId: string, begin: number, end: number, mode: 'select'|'hover', operation:'add'|'set', operatorName?:string): void;
     select(selection: Array<SaguaroPosition>, mode: 'select'|'hover', operation:'add'|'set'): void;
     select(selection: Array<SaguaroRange>, mode: 'select'|'hover', operation:'add'|'set'): void;
@@ -79,6 +80,7 @@ export interface ViewerActionManagerInterface<R> {
 
 export interface ViewerModelMapManagerInterface<R> {
     add(lC: R): void;
+    delete(lC: R): void;
     getChains(): SaguaroPluginModelMapType;
     getModelId(id: string): string;
 }

+ 17 - 0
src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager.ts

@@ -21,6 +21,7 @@ import {Mat4} from "molstar/lib/mol-math/linear-algebra";
 import {BuiltInTrajectoryFormat} from "molstar/lib/mol-plugin-state/formats/trajectory";
 import {PluginState} from "molstar/lib/mol-plugin/state";
 import {TrajectoryHierarchyPresetProvider} from "molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset";
+import {PluginCommands} from "molstar/lib/mol-plugin/commands";
 
 export enum LoadMethod {
     loadPdbId = "loadPdbId",
@@ -93,6 +94,22 @@ export class MolstarActionManager implements ViewerActionManagerInterface<LoadMo
         this.loadingFlag.set(false);
     }
 
+    async removeStructure(loadConfig: LoadMolstarInterface|Array<LoadMolstarInterface>): Promise<void>{
+        loadConfig = Array.isArray(loadConfig) ? loadConfig : [loadConfig];
+        loadConfig.forEach(lC=>{
+            (Array.isArray(lC.loadParams) ? lC.loadParams : [lC.loadParams]).forEach(loadParams=>{
+                if(typeof loadParams.id === "string") {
+                    const pdbStr: StructureRef | undefined = this.viewer.plugin.managers.structure.hierarchy.current.structures.find(s => s.properties?.cell?.obj?.data?.units[0]?.model?.id == this.modelMapManager.getModelId(loadParams.id!));
+                    if (pdbStr) {
+                        this.viewer.plugin.managers.structure.hierarchy.remove([pdbStr]);
+                        PluginCommands.Camera.Reset(this.viewer.plugin);
+                    }
+                }
+            });
+
+        })
+    }
+
     public select(modelId:string, labelAsymId: string, begin: number, end: number, mode: 'select'|'hover', operation:'add'|'set', operatorName?:string): void;
     public select(selection: Array<SaguaroPosition>, mode: 'select'|'hover', operation:'add'|'set'): void;
     public select(selection: Array<SaguaroRange>, mode: 'select'|'hover', operation:'add'|'set'): void;

+ 3 - 3
src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarCallbackManager.ts

@@ -22,20 +22,20 @@ import {RcsbFvSelectorManager} from "../../../RcsbFvState/RcsbFvSelectorManager"
 import {DataContainer, DataContainerReader} from "../../../Utils/DataContainer";
 import {RcsbFvStateManager} from "../../../RcsbFvState/RcsbFvStateManager";
 
-
+type ModelMapType = Omit<ViewerModelMapManagerInterface<null>,'add'|'delete'>;
 export class MolstarCallbackManager implements ViewerCallbackManagerInterface{
 
     private readonly viewer: Viewer;
     private readonly  stateManager: RcsbFvStateManager;
     private readonly loadingFlag: DataContainerReader<boolean>;
-    private readonly modelMapManager: Omit<ViewerModelMapManagerInterface<null>,'add'>;
+    private readonly modelMapManager: ModelMapType;
     private readonly innerSelectionFlag: DataContainer<boolean>;
 
     private selectSubs: Subscription;
     private hoverSubs: Subscription;
     private modelChangeSubs: Subscription;
 
-    constructor(config:{viewer: Viewer; stateManager: RcsbFvStateManager;loadingFlag: DataContainerReader<boolean>;modelMapManager: Omit<ViewerModelMapManagerInterface<null>,'add'>;innerSelectionFlag: DataContainer<boolean>;}) {
+    constructor(config:{viewer: Viewer; stateManager: RcsbFvStateManager;loadingFlag: DataContainerReader<boolean>;modelMapManager: ModelMapType;innerSelectionFlag: DataContainer<boolean>;}) {
         this.viewer = config.viewer;
         this.stateManager = config.stateManager;
         this.loadingFlag = config.loadingFlag;

+ 35 - 30
src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarModelMapManager.ts

@@ -10,14 +10,14 @@ import {StructureRef} from "molstar/lib/mol-plugin-state/manager/structure/hiera
 import {State} from "molstar/lib/mol-state";
 import {PluginStateObject as PSO} from "molstar/lib/mol-plugin-state/objects";
 import {Viewer} from "@rcsb/rcsb-molstar/build/src/viewer";
-import {LoadMolstarInterface} from "./MolstarActionManager";
+import {LoadMethod} from "./MolstarActionManager";
 
 interface LoadParams<P=any,S={}> {
     id?:string;
     params?:P;
 }
 
-export class MolstarModelMapManager implements ViewerModelMapManagerInterface<LoadMolstarInterface> {
+export class MolstarModelMapManager implements ViewerModelMapManagerInterface<{loadMethod: LoadMethod; loadParams: LoadParams;}> {
 
     private readonly viewer: Viewer;
     private readonly modelMap: Map<string,string|undefined> = new Map<string, string>();
@@ -26,22 +26,28 @@ export class MolstarModelMapManager implements ViewerModelMapManagerInterface<Lo
         this.viewer = viewer;
     }
 
-    public add(lC: LoadMolstarInterface){
-        (Array.isArray(lC.loadParams) ? lC.loadParams : [lC.loadParams]).forEach((lP: LoadParams)=>{
-            if(typeof lP.params?.getMap === "function") {
-                const map: Map<string,string> = lP.params.getMap();
-                if(typeof map?.forEach === "function")
-                    map.forEach((modelId: string, key: string) => {
-                        if (typeof modelId === "string" && typeof key === "string") {
-                            this.modelMap.set(key, modelId);
-                            this.modelMap.set(modelId, key);
-                        }
-                    })
-            }
-        });
+    public add(lC: {loadMethod: LoadMethod; loadParams: LoadParams;}){
+        //TODO get rid of the getMap mechanics
+        if(typeof lC.loadParams.params?.getMap === "function") {
+            const map: Map<string,string> = lC.loadParams.params.getMap();
+            if(typeof map?.forEach === "function")
+                map.forEach((modelId: string, key: string) => {
+                    if (typeof modelId === "string" && typeof key === "string") {
+                        this.modelMap.set(key, modelId);
+                        this.modelMap.set(modelId, key);
+                    }
+                })
+        }
         this.map(lC.loadParams);
     }
 
+    public delete(lC: {loadMethod: LoadMethod; loadParams: LoadParams;}) {
+        if(lC.loadParams.id){
+            if(this.modelMap.get(lC.loadParams.id)) this.modelMap.delete(this.modelMap.get(lC.loadParams.id)!);
+            this.modelMap.delete(lC.loadParams.id);
+        }
+    }
+
     public getChains(): SaguaroPluginModelMapType{
         const structureRefList = getStructureOptions(this.viewer.plugin);
         const out: SaguaroPluginModelMapType = new Map<string, {entryId: string; chains: Array<ChainInfo>; assemblyId:string;}>();
@@ -49,7 +55,8 @@ export class MolstarModelMapManager implements ViewerModelMapManagerInterface<Lo
             const structure: Structure = getStructure(structureRef[0], this.viewer.plugin.state.data);
             let modelEntityId = getModelEntityOptions(structure)[0][0];
             const chains: [{modelId:string;entryId:string;assemblyId:string;},ChainInfo[]] = getChainValues(structure, modelEntityId);
-            out.set(this.getModelId(chains[0].modelId),{entryId:chains[0].entryId, assemblyId:chains[0].assemblyId, chains: chains[1]});
+            if(chains.length > 0 && chains[0].modelId)
+                out.set(this.getModelId(chains[0].modelId),{entryId:chains[0].entryId, assemblyId:chains[0].assemblyId, chains: chains[1]});
         });
         return out;
     }
@@ -58,24 +65,22 @@ export class MolstarModelMapManager implements ViewerModelMapManagerInterface<Lo
         return this.modelMap.get(id) ?? id;
     }
 
-    private map(loadParams: LoadParams | Array<LoadParams>): void{
-        const loadParamList: Array<LoadParams> = loadParams instanceof Array ? loadParams : [loadParams];
+    private map(loadParams: LoadParams): void{
         const structureRefList = getStructureOptions(this.viewer.plugin);
-        if(loadParamList.length == structureRefList.length )
-            structureRefList.forEach((structureRef,i)=>{
-                const structure = getStructure(structureRef[0], this.viewer.plugin.state.data);
-                let modelEntityId = getModelEntityOptions(structure)[0][0];
-                const chains: [{modelId:string, entryId:string},ChainInfo[]] = getChainValues(structure, modelEntityId);
-                if(!this.modelMap.has(chains[0].modelId)) {
-                    this.modelMap.set(chains[0].modelId, loadParamList[i].id);
-                    if (loadParamList[i].id != null)
-                        this.modelMap.set(loadParamList[i].id!, chains[0].modelId);
-                }
-            });
+        if(structureRefList.length > 0) {
+            const structureRef = structureRefList[structureRefList.length - 1];
+            const structure = getStructure(structureRef[0], this.viewer.plugin.state.data);
+            let modelEntityId = getModelEntityOptions(structure)[0][0];
+            const chains: [{ modelId: string, entryId: string }, ChainInfo[]] = getChainValues(structure, modelEntityId);
+            if (!this.modelMap.has(chains[0].modelId)) {
+                this.modelMap.set(chains[0].modelId, loadParams.id);
+                if (loadParams.id != null)
+                    this.modelMap.set(loadParams.id!, chains[0].modelId);
+            }
+        }
     }
 }
 
-
 function getStructureOptions(plugin: PluginContext): [string,string][] {
     const options: [string, string][] = [];
     plugin.managers.structure.hierarchy.current.structures.forEach(s=>{

+ 17 - 12
src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AlignmentRepresentationPresetProvider.ts

@@ -22,25 +22,31 @@ import {alignAndSuperpose} from "molstar/lib/mol-model/structure/structure/util/
 import {Mat4} from "molstar/lib/mol-math/linear-algebra";
 import {SymmetryOperator} from "molstar/lib/mol-math/geometry/symmetry-operator";
 import {StateTransforms} from "molstar/lib/mol-plugin-state/transforms";
+import {TagDelimiter} from "@rcsb/rcsb-saguaro-app";
 
-export const AlignmentRepresentationPresetProvider = StructureRepresentationPresetProvider<{ref?:{entryId:string;entityId:string;};pdb?:{entryId:string;entityId:string;};},any>({
+let refData: Structure|undefined = undefined;
+let refId: {entryId:string;entityId:string;}|undefined = undefined;
+export const AlignmentRepresentationPresetProvider = StructureRepresentationPresetProvider<{pdb?:{entryId:string;entityId:string;};},any>({
         id: 'alignment-to-reference',
         display: {
             name: 'Alignemnt to Reference'
         },
         isApplicable: (structureRef: PluginStateObject.Molecule.Structure, plugin: PluginContext): boolean => true,
         params: (structureRef: PluginStateObject.Molecule.Structure | undefined, plugin: PluginContext) => ({
-            ref: PD.Value<{entryId:string;entityId:string;}|undefined>(undefined),
             pdb: PD.Value<{entryId:string;entityId:string;}|undefined>(undefined)
         }),
-        apply: async (structureRef: StateObjectRef<PluginStateObject.Molecule.Structure>, params: {ref?:{entryId:string;entityId:string;};pdb?:{entryId:string;entityId:string;};}, plugin: PluginContext) => {
+        apply: async (structureRef: StateObjectRef<PluginStateObject.Molecule.Structure>, params: {pdb?:{entryId:string;entityId:string;};}, plugin: PluginContext) => {
             const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, structureRef);
-            if (!structureCell) return;
+            if(!structureCell) return;
             const structure = structureCell.obj!.data;
-            if(params.ref && params.pdb){
-                await structuralAlignment(plugin, params.ref, params.pdb, structure);
+            if(plugin.managers.structure.hierarchy.current.structures.length == 1){
+                refId = params.pdb
+            }
+            if(refId && params.pdb){
+                await structuralAlignment(plugin, refId, params.pdb, structure);
             }
-            const entryId = structure.model.entryId;
+            const entryId = params.pdb?.entryId!;
+            const entityId = params.pdb?.entityId!;
             const l = StructureElement.Location.create(structure);
             const asymObserved: {[key:string]:boolean} = {};
             for(const unit of structure.units) {
@@ -57,9 +63,9 @@ export const AlignmentRepresentationPresetProvider = StructureRepresentationPres
                         MS.struct.generator.atomGroups({
                             'chain-test': MS.core.rel.eq([MS.ammp('label_asym_id'), asymId])
                         }),
-                        uniqid(`${entryId}_${asymId}_${operators.join(",")}`),
+                        uniqid(`${entryId}${TagDelimiter.entity}${entityId}${TagDelimiter.instance}${asymId}_${operators.join(",")}`),
                         {
-                            label: `${entryId}.${asymId}-${operators.join(",")}`
+                            label: `${entryId}${TagDelimiter.entity}${entityId}${TagDelimiter.instance}${asymId}-${operators.join(",")}`
                         }
                     );
                     //TODO This needs to be called after tryCreateComponentFromExpression
@@ -81,9 +87,9 @@ export const AlignmentRepresentationPresetProvider = StructureRepresentationPres
                 const comp = await plugin.builders.structure.tryCreateComponentFromExpression(
                     structureCell,
                     expression.expression,
-                    uniqid(`${entryId}_${expression.tag}`),
+                    uniqid(`${entryId}${TagDelimiter.entity}${entityId}_${expression.tag}`),
                     {
-                        label: expression.label
+                        label: `${entryId}${TagDelimiter.entity}${entityId}-${expression.tag}`
                     });
                 //TODO This needs to be called after tryCreateComponentFromExpression
                 const { update, builder } = reprBuilder(plugin, {
@@ -100,7 +106,6 @@ export const AlignmentRepresentationPresetProvider = StructureRepresentationPres
         }
     });
 
-let refData: Structure|undefined = undefined;
 async function structuralAlignment(plugin: PluginContext, ref:{entryId:string;entityId:string;}, pdb:{entryId:string;entityId:string;}, structure: Structure): Promise<void> {
     if(ref.entryId == pdb.entryId){
         refData = structure;

+ 0 - 3
src/RcsbFvStructure/StructureViewers/MolstarViewer/TrajectoryPresetProvider/AlignmentTrajectoryPresetProvider.ts

@@ -18,7 +18,6 @@ import {PLDDTConfidenceColorThemeProvider} from "molstar/lib/extensions/model-ar
 import {AlignmentRepresentationPresetProvider} from "./AlignmentRepresentationPresetProvider";
 
 export type TrajectoryParamsType = {
-    ref?: {entryId:string;entityId:string;};
     pdb?: {entryId:string;entityId:string;};
     assemblyId?: string;
     modelIndex?: number;
@@ -34,7 +33,6 @@ export const AlignmentTrajectoryPresetProvider = TrajectoryHierarchyPresetProvid
     },
     isApplicable: (trajectory: PluginStateObject.Molecule.Trajectory, plugin: PluginContext): boolean => true,
     params: (trajectory: PluginStateObject.Molecule.Trajectory | undefined, plugin: PluginContext):ParamDefinition.For<TrajectoryParamsType> => ({
-        ref:PD.Value<{entryId:string;entityId:string;}|undefined>(undefined),
         pdb:PD.Value<{entryId:string;entityId:string;}|undefined>(undefined),
         assemblyId:PD.Value<string|undefined>(undefined),
         modelIndex:PD.Value<number|undefined>(undefined),
@@ -62,7 +60,6 @@ export const AlignmentTrajectoryPresetProvider = TrajectoryHierarchyPresetProvid
             structureProperties,
             AlignmentRepresentationPresetProvider,
             {
-                ref: params.ref,
                 pdb:params.pdb
             }
         );

+ 5 - 0
src/RcsbFvStructure/StructureViewers/StructureViewer.ts

@@ -47,6 +47,11 @@ export class StructureViewer<R,S> implements StructureViewerInterface<R,S> {
       this.modelChange();
     }
 
+    async removeStructure(loadConfig: R|Array<R>): Promise<void>{
+        await this.actionManager.removeStructure(loadConfig);
+        this.modelChange();
+    }
+
     public setBackground(color: number) {
     }
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio