Skip to content

Commit

Permalink
Merge pull request Sage-Bionetworks#1286 from sagely1/AG-1307-flatten…
Browse files Browse the repository at this point in the history
…-ensembl-info

AG-1307 - Flatten ensembl_info
  • Loading branch information
sagely1 authored Feb 27, 2024
2 parents 39c38bd + 3f5b678 commit 8ce1871
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1,054 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ <h4 class="gene-hero-aliases-heading">Also known as</h4>
<ng-container *ngIf="getEnsemblUrl() !== ''">
<p>
<a [href]="getEnsemblUrl()" target="_blank">{{ gene.ensembl_gene_id }}</a>
<span *ngIf="gene.ensembl_info[0].ensembl_release">
(Ensembl Release {{ gene.ensembl_info[0].ensembl_release }})
<span *ngIf="gene.ensembl_info.ensembl_release">
(Ensembl Release {{ gene.ensembl_info.ensembl_release }})
</span>
</p>
</ng-container>
<ng-container *ngIf="getEnsemblUrl() === ''">
<span *ngIf="getEnsemblUrl() === ''">{{ gene.ensembl_gene_id }}</span>
</ng-container>
<p *ngIf="gene.ensembl_info[0].ensembl_possible_replacements.length > 0">
<a [href]="getPossibleReplacementsURL()">Possible replacement value<span *ngIf="gene.ensembl_info[0].ensembl_possible_replacements.length > 1">s</span></a>:
{{ gene.ensembl_info[0].ensembl_possible_replacements.join(', ')}}
<p *ngIf="gene.ensembl_info.ensembl_possible_replacements.length > 0">
<a [href]="getPossibleReplacementsURL()">Possible replacement value<span *ngIf="gene.ensembl_info.ensembl_possible_replacements.length > 1">s</span></a>:
{{ gene.ensembl_info.ensembl_possible_replacements.join(', ')}}
</p>
<p *ngIf="getAlias() !== ''">
{{ getAlias() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RouterTestingModule } from '@angular/router/testing';
// Internal
// -------------------------------------------------------------------------- //
import { GeneHeroComponent } from './';
import { geneMissingEnsemblInfo, geneMock1, geneMock3 } from '../../../../testing';
import { geneMock1, geneMock3 } from '../../../../testing';

// -------------------------------------------------------------------------- //
// Tests
Expand Down Expand Up @@ -116,12 +116,6 @@ describe('Component: Gene Hero', () => {
expect(component.getEnsemblUrl()).toBe('https://may2015.archive.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g=ENSG00000264794');
});

it('should return an empty string if the gene is missing ensembl info', () => {
// if gene does not have a url
component.gene = geneMissingEnsemblInfo;
expect(component.getEnsemblUrl()).toBe('');
});

it('should return a url with ensembl id', () => {
component.gene = geneMock1;
expect(component.getPossibleReplacementsURL()).toBe('https://useast.ensembl.org/Homo_sapiens/Gene/Idhistory?g=ENSG00000147065');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ export class GeneHeroComponent {
}

getEnsemblUrl() {
if (!this.gene?.ensembl_info || this.gene.ensembl_info.length <= 0)
if (!this.gene?.ensembl_info)
return '';
return this.gene?.ensembl_info[0].ensembl_permalink;
return this.gene?.ensembl_info.ensembl_permalink;
}

getPossibleReplacementsURL() {
Expand Down
3 changes: 1 addition & 2 deletions src/app/models/genes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export interface Gene {

bio_domains?: BioDomains;

// FIXME Will be fixed by AG-1324 in a future data release as it doesn't make sense to have an array here
ensembl_info: EnsemblInfo[];
ensembl_info: EnsemblInfo;
}

export interface GenesResponse {
Expand Down
Loading

0 comments on commit 8ce1871

Please sign in to comment.