Skip to content

Commit

Permalink
Merge pull request #517 from ncats/ketcher_fixes
Browse files Browse the repository at this point in the history
fixes to structure search import/export
  • Loading branch information
NikoAnderson authored Jun 21, 2024
2 parents 3b0e4d1 + 4566909 commit e6f528a
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 76 deletions.
11 changes: 11 additions & 0 deletions src/app/core/structure-editor/structure-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ export class StructureEditorComponent implements OnInit, AfterViewInit, OnDestro
}
}

@Input() setMolecule(structure: any){
if(this.structureEditor==="ketcher") {
this.structureService.interpretStructure(structure).subscribe(resp => {
this.ketcher.setMolecule(resp.structure.molfile);
});
} else {
this.editor.setMolecule(structure);
}
}

listener = () => {
var elmR=document.getElementById("root");
if(this.structureEditor==="ketcher"){
Expand Down Expand Up @@ -154,6 +164,7 @@ export class StructureEditorComponent implements OnInit, AfterViewInit, OnDestro

this.structureEditor = environment.structureEditor;
let pref = sessionStorage.getItem('gsrsStructureEditor');
console.log(pref);
if (pref && this.enableJSDraw) {
if (pref === 'ketcher') {
this.structureEditor = 'ketcher';
Expand Down
6 changes: 4 additions & 2 deletions src/app/core/structure-search/structure-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Title } from '@angular/platform-browser';
import * as _ from 'lodash';
import { pipeline } from 'stream';
import { take } from 'rxjs';
import { StructureEditorComponent } from '@gsrs-core/structure-editor';

@Component({
selector: 'app-structure-search',
Expand All @@ -29,6 +30,7 @@ export class StructureSearchComponent implements OnInit, AfterViewInit, OnDestro
showSimilarityCutoff = false;
searchTypeControl = new FormControl();
@ViewChild('contentContainer', { static: true }) contentContainer;
@ViewChild(StructureEditorComponent) structureEditor!: StructureEditorComponent;
private overlayContainer: HTMLElement;

constructor(
Expand Down Expand Up @@ -187,7 +189,7 @@ export class StructureSearchComponent implements OnInit, AfterViewInit, OnDestro
this.overlayContainer.style.zIndex = null;

if (structurePostResponse && structurePostResponse.structure && structurePostResponse.structure.molfile) {
this.editor.setMolecule(structurePostResponse.structure.molfile);
this.structureEditor.setMolecule(structurePostResponse.structure.molfile);
}
}, () => {
this.overlayContainer.style.zIndex = null;
Expand All @@ -203,7 +205,7 @@ export class StructureSearchComponent implements OnInit, AfterViewInit, OnDestro
height: 'auto',
width: '650px',
data: {
molfile: this.editor.getMolfile(),
molfile: mol,
smiles: this.editor.getSmiles()
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
{{substance.definitionLevel}} DEFINITION
</span>
</div>
<div>
<div class = "full-col">
<div class = "left-col">
<div class="name-value">
<div class="name">Substance Class</div>
<div class="value blue-font">{{substance.substanceClass | classDisplay}}</div>
Expand Down Expand Up @@ -87,6 +88,52 @@
<span class = "deprecated" *ngIf ="substance.deprecated">RECORD IS DEPRECATED</span>
</div>
</div>
<div *ngIf="!isAdmin && !substance.$$source" class="name-value">
<div class="name">Record Version</div>
<div class="value blue-font">{{substance.version}}</div>
</div>
<div *ngIf="isAdmin && !substance.$$source" class="name-value">
<div class="name">Record Version</div>
<mat-form-field class="version-dropdown">
<mat-select [formControl]="versionControl" class="version-select">
<mat-option *ngFor="let version of versions" [value]="version" class="version-option">
{{version}}
</mat-option>
</mat-select>
</mat-form-field>
<button *ngIf="substance.version != versionControl.value" mat-button
class="mat-raised-button mat-primary view-version" (click)='changeVersion()'>View</button>
</div>
<div *ngIf="substance.version != latestVersion && !substance.$$source" class="indent">
This is an older version of this substance - Ver. {{this.substance.version}}
<button *ngIf="isAdmin" mat-button
class="mat-raised-button mat-primary view-version" (click)='restoreVersion()'>Restore this version</button>
</div>

<div class="name-value">
<div class="name">Definitional Access</div>
<div class="value blue-font">
<span *ngIf="(defAccess && defAccess.length > 0) else defIndicator">
<span>Not a public definition</span>&nbsp;
<mat-icon svgIcon="lock"></mat-icon>
</span>
<ng-template #defIndicator>
<span>Public definition</span>&nbsp;
<mat-icon svgIcon="lock_open"></mat-icon>
</ng-template>
</div>
<!-- <div class="value">
<span *ngIf = "!defAccess || defAccess.length === 0">Public</span>
<span *ngIf = "defAccess && defAccess.length > 0">
<span class = "pre" *ngFor ="let access of defAccess;last as islast">
{{access}}{{!islast? ', ':''}}
</span>
</span>
</div>-->
</div>
</div>
<div class = "right-col">
<div *ngIf="substance.protein" class="diverseWrapper">
<div class="name-value" *ngIf="substance.protein.proteinType">
<div class="name">Protein Type</div>
Expand Down Expand Up @@ -220,71 +267,32 @@
</div>
</div>
</div>
<div *ngIf="!isAdmin && !substance.$$source" class="name-value">
<div class="name">Record Version</div>
<div class="value blue-font">{{substance.version}}</div>
</div>
<div *ngIf="isAdmin && !substance.$$source" class="name-value">
<div class="name">Record Version</div>
<mat-form-field class="version-dropdown">
<mat-select [formControl]="versionControl" class="version-select">
<mat-option *ngFor="let version of versions" [value]="version" class="version-option">
{{version}}
</mat-option>
</mat-select>
</mat-form-field>
<button *ngIf="substance.version != versionControl.value" mat-button
class="mat-raised-button mat-primary view-version" (click)='changeVersion()'>View</button>
</div>
<div *ngIf="substance.version != latestVersion && !substance.$$source" class="indent">
This is an older version of this substance - Ver. {{this.substance.version}}
<button *ngIf="isAdmin" mat-button
class="mat-raised-button mat-primary view-version" (click)='restoreVersion()'>Restore this version</button>
</div>
<div class="name-value">
<div class="name">Tags</div>
<div class="value">
<mat-chip-list #tagList aria-label="Tags" selectable="false">
<mat-chip
*ngFor="let tag of substance.tags"
removable="false">
{{tag}}
</mat-chip>
</mat-chip-list>
</div>
</div>
<div class="name-value" *ngIf="references?.length > 0">
<div class="name">
<a tabindex="0" role="link" (click)="toggleReferences()" class='blue-font references-link'>
<span>{{showDef === false ? 'Show' : 'Hide'}} Definitional References</span>
<mat-icon svgIcon="{{defIcon}}"></mat-icon>
</a>
</div>
</div>
<div [hidden]="!showDef">
<app-references-manager [substance]="substance" [references]="references"></app-references-manager>
</div>
<div class="name-value">
<div class="name">Definitional Access</div>
<div class="value blue-font">
<span *ngIf="(defAccess && defAccess.length > 0) else defIndicator">
<span>Not a public definition</span>&nbsp;
<mat-icon svgIcon="lock"></mat-icon>
</span>
<ng-template #defIndicator>
<span>Public definition</span>&nbsp;
<mat-icon svgIcon="lock_open"></mat-icon>
</ng-template>
</div>
<!-- <div class="value">
<span *ngIf = "!defAccess || defAccess.length === 0">Public</span>
<span *ngIf = "defAccess && defAccess.length > 0">
<span class = "pre" *ngFor ="let access of defAccess;last as islast">
{{access}}{{!islast? ', ':''}}
</span>
</span>
</div>-->
</div>
</div>
</div>
<div class="name-value">
<div class="name">Tags</div>
<div class="value">
<mat-chip-list #tagList aria-label="Tags" selectable="false">
<mat-chip
*ngFor="let tag of substance.tags"
removable="false">
{{tag}}
</mat-chip>
</mat-chip-list>
</div>
<div *ngIf="substance.tags.length === 0">
<i>None</i>
</div>
</div>
<div class="name-value" *ngIf="references?.length > 0">
<div class="name">
<a tabindex="0" role="link" (click)="toggleReferences()" class='blue-font references-link'>
<span>{{showDef === false ? 'Show' : 'Hide'}} Definitional References</span>
<mat-icon svgIcon="{{defIcon}}"></mat-icon>
</a>
</div>
</div>
<div [hidden]="!showDef">
<app-references-manager [substance]="substance" [references]="references"></app-references-manager>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
display: inline-flex;
vertical-align: middle;
}

.left-col {
width:50%;

}

.right-col {
width: 50%;
}

.full-col {
width: 100%;
display:flex;
flex-direction: row;
}

.version-dropdown{
width:50px;
border:0px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ export class AccessManagerComponent implements OnInit, AfterViewInit {
getVocabularies(): void {
this.cvService.getDomainVocabulary('ACCESS_GROUP').subscribe(response => {
const accessOptions = response['ACCESS_GROUP'].list;
console.log(accessOptions);
let hasRep = false;
accessOptions.forEach(option => {
if (option.value.toLowerCase() === 'representative') {
hasRep = true;
}
});
if (!hasRep) {
accessOptions.push(
{display: 'representative',
value: 'representative'
}
)
}
this.createAccessFromGroup(accessOptions);
this.accessOptions = accessOptions;
this.crosscheckAccesses();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { Component, OnInit, AfterViewInit, OnDestroy, ViewChild } from '@angular/core';
import { SubstanceFormBase } from '../base-classes/substance-form-base';
import { Editor } from '../../structure-editor/structure.editor.model';
import { SubstanceStructure } from '@gsrs-core/substance/substance.model';
Expand All @@ -17,6 +17,7 @@ import { SubstanceService } from '@gsrs-core/substance/substance.service';
import { SubstanceFormStructuralUnitsService } from '../structural-units/substance-form-structural-units.service';
import { SubstanceFormStructureService } from './substance-form-structure.service';
import { ActivatedRoute } from '@angular/router';
import { StructureEditorComponent } from '@gsrs-core/structure-editor';

@Component({
selector: 'app-substance-form-structure-card',
Expand All @@ -35,6 +36,7 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple
private overlayContainer: HTMLElement;
structureErrorsArray: Array<StructureDuplicationMessage>;
subscriptions: Array<Subscription> = [];
@ViewChild(StructureEditorComponent) structureEditorComponent!: StructureEditorComponent;

constructor(
private substanceFormService: SubstanceFormService,
Expand Down Expand Up @@ -197,7 +199,7 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple
this.overlayContainer.style.zIndex = null;
if (response != null) {
if (response && response.structure && response.structure.molfile) {
this.structureEditor.setMolecule(response.structure.molfile);
this.structureEditorComponent.setMolecule(response.structure.molfile);
}
this.processStructurePostResponse(response);
}
Expand Down Expand Up @@ -249,7 +251,7 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple
this.overlayContainer.style.zIndex = null;
if (molfile != null && molfile !== '') {
this.updateStructureForm(molfile);
this.structureEditor.setMolecule(molfile);
this.structureEditorComponent.setMolecule(molfile);
}
}, () => { });
}
Expand Down
13 changes: 9 additions & 4 deletions src/app/core/substance-form/substance-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,13 @@ export class SubstanceFormService implements OnDestroy {
substanceClass: 'mixture',
references: [],
names: [],
mixture: {},
mixture: {
access: ['representative']
},
codes: [],
relationships: [],
properties: []
properties: [],
access: ['representative']
};
} else if (substanceClass === 'structurallyDiverse') {
this.privateSubstance = {
Expand Down Expand Up @@ -224,11 +227,13 @@ export class SubstanceFormService implements OnDestroy {
polymer: {
idealizedStructure: {},
monomers: [],
access: ['representative']
},
codes: [],
moieties: [],
relationships: [],
properties: []
properties: [],
access: ['representative']
};
} else {
this.privateSubstance = {
Expand All @@ -242,7 +247,7 @@ export class SubstanceFormService implements OnDestroy {

// TP: default to protected for root level record.
// ***** AN: Adding this right now for SSG4m and G2 ******
if (substanceClass !== 'specifiedSubstanceG4m') {
if (substanceClass !== 'specifiedSubstanceG4m' && substanceClass !== 'mixture' && substanceClass !== 'polymer') {
this.privateSubstance.access = ["protected"];

if (substanceClass !== 'specifiedSubstanceG2') {
Expand Down

0 comments on commit e6f528a

Please sign in to comment.