-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from hpi-dhc/issue/343-rename-genephenotype
Rename `GenePhenotype`
- Loading branch information
Showing
20 changed files
with
224 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Cron } from '@nestjs/schedule'; | ||
|
||
import { GenePhenotypesService } from './gene-phenotypes/gene-phenotypes.service'; | ||
import { GuidelinesService } from './guidelines/guidelines.service'; | ||
import { MedicationsService } from './medications/medications.service'; | ||
import { PhenotypesService } from './phenotypes/phenotypes.service'; | ||
|
||
@Injectable() | ||
export class AppService { | ||
constructor( | ||
private medicationService: MedicationsService, | ||
private guidelineService: GuidelinesService, | ||
private genephenotypeService: GenePhenotypesService, | ||
private phenotypesService: PhenotypesService, | ||
) {} | ||
|
||
@Cron('0 0 1 * *', { name: 'monthlyUpdates' }) | ||
async initializeDatabase(): Promise<void> { | ||
await this.medicationService.fetchAllMedications(); | ||
await this.genephenotypeService.fetchGenePhenotypes(); | ||
await this.phenotypesService.fetchPhenotypes(); | ||
await this.guidelineService.fetchGuidelines(); | ||
} | ||
} |
89 changes: 0 additions & 89 deletions
89
annotation-server/src/guidelines/caches/gene-phenotype-caches.ts
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
annotation-server/src/guidelines/caches/phenotype-caches.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { ILike } from 'typeorm'; | ||
|
||
import { Phenotype } from '../../phenotypes/entities/phenotype.entity'; | ||
import { PhenotypesService } from '../../phenotypes/phenotypes.service'; | ||
import { | ||
GuidelineError, | ||
GuidelineErrorBlame, | ||
GuidelineErrorType, | ||
} from '../entities/guideline-error.entity'; | ||
import { GuidelineCacheMap } from './guideline-cache'; | ||
|
||
export class PhenotypesByGeneCache extends GuidelineCacheMap< | ||
Array<Set<Phenotype>> | ||
> { | ||
private phenotypesService: PhenotypesService; | ||
private spreadsheetGeneResultHeader: Set<string>[]; | ||
|
||
constructor( | ||
phenotypesService: PhenotypesService, | ||
spreadsheetGeneResultHeader: Set<string>[], | ||
) { | ||
super(); | ||
this.phenotypesService = phenotypesService; | ||
this.spreadsheetGeneResultHeader = spreadsheetGeneResultHeader; | ||
} | ||
|
||
protected async retrieve( | ||
...[geneSymbolName]: string[] | ||
): Promise<Set<Phenotype>[]> { | ||
const geneSymbol = await this.phenotypesService.findOneGeneSymbol({ | ||
where: { name: ILike(geneSymbolName) }, | ||
relations: [ | ||
'phenotypes', | ||
'phenotypes.geneResult', | ||
'phenotypes.geneSymbol', | ||
], | ||
}); | ||
const phenotypes = this.spreadsheetGeneResultHeader.map( | ||
(geneResults) => | ||
new Set( | ||
geneSymbol.phenotypes.filter((phenotype) => | ||
geneResults.has( | ||
phenotype.geneResult.name.toLowerCase(), | ||
), | ||
), | ||
), | ||
); | ||
return phenotypes; | ||
} | ||
|
||
protected createError(...[geneSymbolName]: string[]): GuidelineError { | ||
const error = new GuidelineError(); | ||
error.type = GuidelineErrorType.PHENOTYPE_NOT_FOUND; | ||
error.blame = GuidelineErrorBlame.CPIC; | ||
error.context = geneSymbolName; | ||
return error; | ||
} | ||
} | ||
|
||
export class PhenotypesCache extends GuidelineCacheMap<Phenotype> { | ||
private phenotypesService: PhenotypesService; | ||
|
||
constructor(phenotypesService: PhenotypesService) { | ||
super(); | ||
this.phenotypesService = phenotypesService; | ||
} | ||
|
||
protected async retrieve( | ||
...[geneSymbolName, geneResultName]: string[] | ||
): Promise<Phenotype> { | ||
return this.phenotypesService.findOne({ | ||
where: { | ||
geneSymbol: { name: ILike(geneSymbolName) }, | ||
geneResult: { name: geneResultName }, | ||
}, | ||
relations: ['geneResult', 'geneSymbol'], | ||
}); | ||
} | ||
|
||
protected createError( | ||
...[geneSymbolName, geneResultName]: string[] | ||
): GuidelineError { | ||
const error = new GuidelineError(); | ||
error.type = GuidelineErrorType.PHENOTYPE_NOT_FOUND; | ||
error.blame = GuidelineErrorBlame.CPIC; | ||
error.context = `${geneSymbolName}:${geneResultName}`; | ||
return error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.