From 956dabf4377919782c8d7f2f6562e83640eeb3fe Mon Sep 17 00:00:00 2001 From: NikoAnderson Date: Tue, 27 Aug 2024 13:29:49 -0400 Subject: [PATCH 1/3] fixing sitesshorthand bug, unused import cleanup --- .../links/link-form.component.ts | 4 +++- .../substance-form/substance-form.service.ts | 22 +++++++++---------- .../ssg4m-scheme-view.component.ts | 9 ++------ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/app/core/substance-form/links/link-form.component.ts b/src/app/core/substance-form/links/link-form.component.ts index eb62dd35..00263528 100644 --- a/src/app/core/substance-form/links/link-form.component.ts +++ b/src/app/core/substance-form/links/link-form.component.ts @@ -46,7 +46,9 @@ export class LinkFormComponent implements OnInit, OnDestroy { getStructure() { if (this.privateLink && this.privateLink.linkage){ - this.smiles = this.vocabulary[this.privateLink.linkage]; + if(this.vocabulary) { + this.smiles = this.vocabulary[this.privateLink.linkage]; + } if (this.smiles && this.smiles.fragmentStructure) { this.structure = this.cvService.getStructureUrlFragment(this.smiles.fragmentStructure); } else { diff --git a/src/app/core/substance-form/substance-form.service.ts b/src/app/core/substance-form/substance-form.service.ts index 64c233d7..0b3d1e28 100644 --- a/src/app/core/substance-form/substance-form.service.ts +++ b/src/app/core/substance-form/substance-form.service.ts @@ -1436,20 +1436,20 @@ export class SubstanceFormService implements OnDestroy { this.privateSubstance.protein.disulfideLinks.splice(i, 1); } } + } - if (this.privateSubstance.nucleicAcid) { - if (this.privateSubstance.nucleicAcid.linkages && this.privateSubstance.nucleicAcid.linkages.length > 0) { - for (let i = this.privateSubstance.nucleicAcid.linkages.length-1; i >= 0; i--) { - if (this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand) { - delete this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand; - } + if (this.privateSubstance.nucleicAcid) { + if (this.privateSubstance.nucleicAcid.linkages && this.privateSubstance.nucleicAcid.linkages.length > 0) { + for (let i = this.privateSubstance.nucleicAcid.linkages.length -1; i >= 0; i--) { + if (this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand) { + delete this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand; } } - if (this.privateSubstance.nucleicAcid.sugars && this.privateSubstance.nucleicAcid.sugars.length > 0) { - for (let i = this.privateSubstance.nucleicAcid.sugars.length-1; i >= 0; i--) { - if (this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand) { - delete this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand; - } + } + if (this.privateSubstance.nucleicAcid.sugars && this.privateSubstance.nucleicAcid.sugars.length > 0) { + for (let i = this.privateSubstance.nucleicAcid.sugars.length -1; i >= 0; i--) { + if (this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand) { + delete this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand; } } } diff --git a/src/app/core/substance-ssg4m/ssg4m-scheme-view/ssg4m-scheme-view.component.ts b/src/app/core/substance-ssg4m/ssg4m-scheme-view/ssg4m-scheme-view.component.ts index 3ec91ff5..a4729f34 100644 --- a/src/app/core/substance-ssg4m/ssg4m-scheme-view/ssg4m-scheme-view.component.ts +++ b/src/app/core/substance-ssg4m/ssg4m-scheme-view/ssg4m-scheme-view.component.ts @@ -3,17 +3,12 @@ import { Subscription } from 'rxjs'; import { OverlayContainer } from '@angular/cdk/overlay'; import { MatDialog } from '@angular/material/dialog'; import { Environment } from 'src/environments/environment.model'; -import { ConfigService, LoadedComponents } from '@gsrs-core/config'; +import { ConfigService } from '@gsrs-core/config'; import { UtilsService } from '@gsrs-core/utils'; -import { StructureImageModalComponent, StructureService } from '@gsrs-core/structure'; -import { SubstanceFormService } from '../../substance-form/substance-form.service'; +import { StructureImageModalComponent } from '@gsrs-core/structure'; import { SubstanceFormSsg4mProcessService } from '../ssg4m-process/substance-form-ssg4m-process.service'; import { SubstanceDetail, SpecifiedSubstanceG4mProcess, SubstanceAmount } from '@gsrs-core/substance/substance.model'; import { SubstanceSsg4mService } from '../substance-ssg4m-form.service'; -import * as htmlToImage from 'html-to-image'; -import domToImage from 'dom-to-image'; -import jsPDF from 'jspdf'; -import * as moment from 'moment'; @Component({ selector: 'app-ssg4m-scheme-view', From d77df671e4fbb0dbf283b7072337ac854b16196c Mon Sep 17 00:00:00 2001 From: NikoAnderson Date: Tue, 27 Aug 2024 13:47:42 -0400 Subject: [PATCH 2/3] adding future todo comment --- src/app/core/substance-form/substance-form.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/core/substance-form/substance-form.service.ts b/src/app/core/substance-form/substance-form.service.ts index 0b3d1e28..b9d4103f 100644 --- a/src/app/core/substance-form/substance-form.service.ts +++ b/src/app/core/substance-form/substance-form.service.ts @@ -1423,6 +1423,7 @@ export class SubstanceFormService implements OnDestroy { }); } + //TODO - recalculate sitesShorthand instead of deleting / determine when backend uses sitesShorthand over sites array if (this.privateSubstance.protein && this.privateSubstance.protein.disulfideLinks && this.privateSubstance.protein.disulfideLinks.length > 0) { for (let i = this.privateSubstance.protein.disulfideLinks.length -1; i >= 0; i--) { From 96f76eed01789bc297f38dad9cf462c2cd9ff98e Mon Sep 17 00:00:00 2001 From: NikoAnderson Date: Tue, 27 Aug 2024 16:25:00 -0400 Subject: [PATCH 3/3] changes for nitrosamine table --- src/app/core/config/config.model.ts | 1 + ...substance-form-structure-card.component.ts | 42 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/app/core/config/config.model.ts b/src/app/core/config/config.model.ts index 595e4136..11c7fd61 100644 --- a/src/app/core/config/config.model.ts +++ b/src/app/core/config/config.model.ts @@ -82,6 +82,7 @@ export interface Config { useApprovalAPI?: boolean; dummyWhoami?: Auth; enableStructureFeatures?: boolean; + StructureFeaturePriority?: Array; structureEditSearch?: boolean; } diff --git a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts index 665f43bc..dc722564 100644 --- a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts +++ b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts @@ -47,6 +47,16 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple featuresOnly = false; hideFeaturesTable = false; structureEditSearch = true; + StructureFeaturePriority = [ + 'Category Score', + 'Sum Of Scores', + 'AI Limit (US)', + 'Potency Category', + 'Potency Score', + 'type', + 'Type', + 'TYPE' + ]; @ViewChild(StructureEditorComponent) structureEditorComponent!: StructureEditorComponent; constructor( @@ -76,6 +86,13 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple this.configService.configData.structureEditSearch !== null)) { this.structureEditSearch = this.configService.configData.structureEditSearch; } + + if (this.configService.configData && + (this.configService.configData.StructureFeaturePriority !== undefined && + this.configService.configData.StructureFeaturePriority !== null)) { + this.StructureFeaturePriority = this.configService.configData.StructureFeaturePriority; + } + if(this.activatedRoute.snapshot.routeConfig.path === 'structure-features') { this.featuresOnly = true; } @@ -185,15 +202,27 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple } } + featureSort(a: any, b: any): number { + const indexA = this.StructureFeaturePriority.indexOf(a.key); + const indexB = this.StructureFeaturePriority.indexOf(b.key); + + + if (indexA !== -1 && indexB !== -1) { + return indexA - indexB; + } else if (indexA !== -1) { + return -1; // a comes first + } else if (indexB !== -1) { + return 1; // b comes first + } else { + return a.key.localeCompare(b.key); + } + } + processStructurePostResponse(structurePostResponse?: InterpretStructureResponse): void { if (structurePostResponse && structurePostResponse.structure) { let customSort = (array: any[]): any[] => { return array.sort((a, b) => { - if (a.key === 'Category Score') return -1; - if (b.key === 'Category Score') return 1; - if (a.key === 'Sum Of Scores') return a.key === 'Category Score' ? 1 : -1; - if (b.key === 'Sum Of Scores') return b.key === 'Category Score' ? -1 : 1; - return a.key.localeCompare(b.key); + return this.featureSort(a, b); }); }; @@ -219,6 +248,9 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple if(key === 'sumOfScores'){ label = 'Sum Of Scores'; } + if (key.toLowerCase() === 'type') { + label = 'Type'; + } temp.push({'key': label,'value': structurePostResponse.featureList[type][0][key] }); }); }