11import { Component , OnInit , OnChanges , Input ,
22 ChangeDetectionStrategy , ChangeDetectorRef } from '@angular/core' ;
33import { DomSanitizer , SafeResourceUrl } from '@angular/platform-browser' ;
4- import { GeneDetails , ProteinComplexDetails } from '../pombase-api.service' ;
4+ import { PombaseAPIService , GeneSummaryMap , GeneSummary ,
5+ GeneDetails , ProteinComplexDetails } from '../pombase-api.service' ;
56import { getXrfWithPrefix } from '../config' ;
67
78@Component ( {
@@ -17,9 +18,15 @@ export class ComplexViewerComponent implements OnInit, OnChanges {
1718 complexes : Array < ProteinComplexDetails > = [ ] ;
1819 currentComplexUniquename ?: string = undefined ;
1920 currentComplex ?: ProteinComplexDetails = undefined ;
21+ currentGenes : Array < GeneSummary > = [ ] ;
22+
23+ private geneSummaryMapPromise : Promise < GeneSummaryMap > ;
2024
2125 constructor ( private changeDetectorRef : ChangeDetectorRef ,
22- private sanitizer : DomSanitizer ) { }
26+ private sanitizer : DomSanitizer ,
27+ private pombaseApiService : PombaseAPIService ) {
28+ this . geneSummaryMapPromise = this . pombaseApiService . getGeneSummaryMapPromise ( ) ;
29+ }
2330
2431 complexPortalUrl ( complexId : string ) : string {
2532 const xrfDetails = getXrfWithPrefix ( 'ComplexPortal' , complexId ) ! ;
@@ -32,19 +39,35 @@ export class ComplexViewerComponent implements OnInit, OnChanges {
3239 }
3340
3441 complexChanged ( ) {
35- this . changeDetectorRef . detectChanges ( ) ;
42+ this . setGenes ( ) ;
43+ this . changeDetectorRef . detectChanges ( ) ;
44+ }
45+
46+ setGenes ( ) {
47+ this . currentGenes = [ ] ;
48+ this . geneSummaryMapPromise . then ( summaryMap => {
49+ if ( this . currentComplex ) {
50+ this . currentGenes = this . currentComplex . genes
51+ . map ( geneUniquename => summaryMap [ geneUniquename ] )
52+ this . changeDetectorRef . detectChanges ( ) ;
53+ }
54+ } ) ;
3655 }
3756
3857 ngOnInit ( ) {
58+ console . log ( "ngOnInit()" )
3959 }
4060
4161 ngOnChanges ( ) {
62+ console . log ( "ngOnChanges()" )
4263 if ( this . geneDetails ) {
4364 this . complexes = this . geneDetails . complexes ;
4465 this . currentComplex = this . complexes [ 0 ] ;
66+ this . setGenes ( ) ;
4567 } else {
4668 this . complexes = [ ] ;
4769 this . currentComplex = undefined ;
70+ this . currentGenes = [ ] ;
4871 }
4972 }
5073}
0 commit comments