Skip to content

Commit

Permalink
Revert "Add links for term IDs in GO-CAM titles"
Browse files Browse the repository at this point in the history
Temporarily revert to fix Angular errors with:
--configuration production

This reverts commit 519c5ea.
  • Loading branch information
kimrutherford committed Jan 23, 2025
1 parent 7e4ee78 commit 27025c6
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 65 deletions.
1 change: 0 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ export class PomBaseUrlSerializer extends DefaultUrlSerializer {
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
exports: [],
imports: [
IntersectionObserverModule.forRoot({
debounce: 50,
Expand Down
9 changes: 1 addition & 8 deletions src/app/go-cam-view-page/go-cam-view-page.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div *ngIf="getIFrameURL()">
<div class="header-section">
<div class="return-to-gene-page">
<div class="title">GO-CAM pathway model
<span class="model-title-or-id">
<app-description-display *ngIf="gocamDetails && gocamDetails.title"
[description]="gocamDetails!.title"
[descriptionParts]="titleParts">
</app-description-display>
<span *ngIf="(!gocamDetails || !gocamDetails.title) && gocamId">{{gocamId}}</span>
</span>
<div class="title">GO-CAM pathway model <span class="model-title-or-id">{{getTitleOrId()}}</span>
<span *ngIf="sourcePageType != 'docs'" class="go-cam-view">
<span class="help-link"><a routerLink="/documentation/go-cam-pathway-models">All curated pathways</a></span>
</span>
Expand Down
14 changes: 2 additions & 12 deletions src/app/go-cam-view-page/go-cam-view-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ActivatedRoute, Params } from '@angular/router';
import { DomSanitizer, Meta, SafeResourceUrl, Title } from '@angular/platform-browser';
import { AppConfig, getAppConfig } from '../config';
import { PombaseAPIService, GoCamDetails, GeneSummaryMap, GeneSummary } from '../pombase-api.service';
import { TextOrTermId, Util } from '../shared/util';

@Component({
selector: 'app-go-cam-view-page',
Expand All @@ -24,7 +23,6 @@ export class GoCamViewPageComponent implements OnInit {
sourceName?: string;
modelGenes: Array<GeneSummary> = [];
geneSummaryMap?: GeneSummaryMap;
titleParts: Array<TextOrTermId> = [];

constructor(private titleService: Title,
private sanitizer: DomSanitizer,
Expand Down Expand Up @@ -70,21 +68,14 @@ export class GoCamViewPageComponent implements OnInit {
this.meta.updateTag({ property: 'description', content: title });
}

setTitleParts(): void {
if (this.gocamDetails && this.gocamDetails.title) {
this.titleParts = Util.splitDescription(this.gocamDetails.title, this.gocamDetails.title_terms ?? []);
} else {
this.titleParts = [];
}
}

ngOnInit(): void {
this.route.params.forEach((params: Params) => {
if (params['gocam_id'] !== undefined) {
this.gocamId = params['gocam_id'];

const summPromise = this.pombaseApi.getGeneSummaryMapPromise();


const gocamDetailPromise = this.pombaseApi.getGoCamDetailById(this.gocamId!);
gocamDetailPromise.then((details) => {
this.gocamDetails = details;
Expand All @@ -97,8 +88,7 @@ export class GoCamViewPageComponent implements OnInit {
const geneSumm = geneSummMap[geneUniquename];
this.modelGenes.push(geneSumm);
}
this.modelGenes.sort((a,b) => a.displayName().localeCompare(b.displayName()));
this.setTitleParts();
this.modelGenes.sort((a,b) => a.displayName().localeCompare(b.displayName()))
})

this.sourcePageType = params['source_page_type'];
Expand Down
1 change: 0 additions & 1 deletion src/app/pombase-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ export interface GoCamContributor {
export interface GoCamDetails {
gocam_id: GoCamId;
title?: string;
title_terms: Array<TermId>;
genes: Array<GeneUniquename>;
terms: Array<TermAndName>;
contributors: Array<GoCamContributor>;
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/gene-results/gene-results.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div *ngIf="results">
<div *ngIf="results.getRowCount() == 0" class="description">
<span class="description-prefix">No results for:</span>
<app-description-display *ngIf="description || descriptionParts.length != 0"
<app-query-description-display *ngIf="description || descriptionParts.length != 0"
[description]="description" [descriptionParts]="descriptionParts">
</app-description-display>
</app-query-description-display>
</div>

<app-genes-table *ngIf="results.getRowCount() != 0"
Expand Down
20 changes: 16 additions & 4 deletions src/app/shared/gene-results/gene-results.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, Input, OnInit, OnChanges } from '@angular/core';
import { QueryResult, TermAndName } from '../../pombase-query';
import { Util, TextOrTermId } from '../util';

@Component({
selector: 'app-gene-results',
Expand All @@ -14,7 +13,7 @@ export class GeneResultsComponent implements OnInit, OnChanges {

description: string;

descriptionParts: Array<TextOrTermId> = [];
descriptionParts: Array<({ text?: string; term?: TermAndName; })> = [];
termsInQuery: Array<TermAndName> = [];

constructor() { }
Expand All @@ -31,9 +30,22 @@ export class GeneResultsComponent implements OnInit, OnChanges {

this.termsInQuery = this.results.getQuery().referencedTerms();
const termids = this.termsInQuery.map(term => term.termid);
const termidRe = new RegExp('(' + termids.join('|') + ')');

const descriptionBits = this.description.split(termidRe);
this.descriptionParts =
Util.splitDescription(this.description, termids);
}
descriptionBits.map(bit => {
const index = termids.indexOf(bit);
if (index === -1) {
return {
text: bit,
};
} else {
return {
term: this.termsInQuery[index],
};
}
});
}
}
}
6 changes: 3 additions & 3 deletions src/app/shared/genes-table/genes-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<span class="description-prefix" *ngIf="showingQuilt()">QuiLT visualisation of: </span>
<span class="description-prefix" *ngIf="showingGeneEx()">Gene expression of: </span>
<span class="description-prefix" *ngIf="!showingQuilt() && !showingGeneEx()">Query:</span>
<app-description-display *ngIf="description || descriptionParts.length != 0"
[description]="description" [descriptionParts]="descriptionParts">
</app-description-display>
<app-query-description-display *ngIf="description || descriptionParts.length != 0"
[description]="description" [descriptionParts]="descriptionParts">
</app-query-description-display>


<div *ngIf="showingQuilt()" class="documentation-link">
Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/genes-table/genes-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
import { PombaseAPIService, GeneSummaryMap, GeneShort } from '../../pombase-api.service';
import { GenesDownloadDialogComponent } from '../../genes-download-dialog/genes-download-dialog.component';
import { QueryService, HistoryEntry, DisplayResultRow } from '../../query.service';
import { GeneQuery, GeneListNode, QueryResult } from '../../pombase-query';
import { GeneQuery, GeneListNode, TermAndName, QueryResult } from '../../pombase-query';
import { getAppConfig, GeneResultsFieldConfig } from '../../config';
import { DeployConfigService } from '../../deploy-config.service';
import { GenesTableConfigComponent } from '../../genes-table-config/genes-table-config.component';
import { SettingsService } from '../../settings.service';
import { Subscription } from 'rxjs';
import { faCog } from '@fortawesome/free-solid-svg-icons';
import { QueryRouterService } from '../../query-router.service';
import { TextOrTermId, Util } from '../util';
import { Util } from '../util';

@Component({
selector: 'app-genes-table',
Expand All @@ -30,7 +30,7 @@ export class GenesTableComponent implements OnInit {
// a decomposed version of the description as an Array of Objects
// like: [{text: "abnormal cell ... ("}, {term: <a TermShort>}, {text: ")"}, ...]
// which allows the the termids in a description to be linked to the term pages
@Input() descriptionParts: Array<TextOrTermId> = [];
@Input() descriptionParts: Array<({ text?: string; term?: TermAndName; })> = [];
@Input() genesOrResults: Array<GeneShort>|QueryResult;

@ViewChild('interMineSendForm') interMineSendForm: ElementRef;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span *ngIf="descriptionParts.length == 0">{{description}}</span>
<span *ngIf="descriptionParts.length != 0">
<span *ngFor="let part of descriptionParts"><span *ngIf="part.text" [innerHTML]="part.text"></span><a *ngIf="part.term" routerLink="/term/{{part.term.termid}}">{{part.term.termid}}</a></span>
</span>

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { QueryDescriptionDisplayComponent } from './query-description-display.component';

describe('QueryDescriptionDisplayComponent', () => {
let component: QueryDescriptionDisplayComponent;
let fixture: ComponentFixture<QueryDescriptionDisplayComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ QueryDescriptionDisplayComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(QueryDescriptionDisplayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, OnInit, Input } from '@angular/core';
import { TermAndName } from '../../pombase-query';

@Component({
selector: 'app-query-description-display',
templateUrl: './query-description-display.component.html',
styleUrls: ['./query-description-display.component.css'],
standalone: false
})
export class QueryDescriptionDisplayComponent implements OnInit {
@Input() description: string;

// a decomposed version of the description as an Array of Objects
// like: [{text: "abnormal cell ... ("}, {term: <a TermShort>}, {text: ")"}, ...]
// which allows the the termids in a description to be linked to the term pages
@Input() descriptionParts: Array<({ text?: string; term?: TermAndName; })> = [];

constructor() { }

ngOnInit() {
}

}
5 changes: 2 additions & 3 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ExternalLinkComponent } from './external-link/external-link.component';
import { GeneResultsComponent } from './gene-results/gene-results.component';
import { GeneResultsVisComponent } from './gene-results-vis/gene-results-vis.component';
import { GenesTableComponent } from './genes-table/genes-table.component';
import { QueryDescriptionDisplayComponent } from './query-description-display/query-description-display.component';
import { GeneLinkComponent } from './gene-link/gene-link.component';
import { PageContentsMenuComponent } from './page-contents-menu/page-contents-menu.component';
import { CvVersionComponent } from './cv-version/cv-version.component';
Expand All @@ -32,7 +33,6 @@ import { SocialContactComponent } from './social-contact/social-contact.componen
import { GeneResultsSlimTableComponent } from './gene-results-slim-table/gene-results-slim-table.component';
import { FacetedSearchComponent } from './faceted-search/faceted-search.component';
import { ChromosomeOverviewComponent } from './chromosome-overview/chromosome-overview.component';
import { DescriptionDisplayComponent } from './description-display/description-display.component';

import { PublicationBadgeComponent } from './publication-badge/publication-badge.component';

Expand Down Expand Up @@ -74,7 +74,6 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
FacetedSearchComponent,
ChromosomeOverviewComponent,
PublicationBadgeComponent,
DescriptionDisplayComponent,
],
declarations: [
SlimTableComponent,
Expand All @@ -97,7 +96,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
GoCamTableComponent,
SocialContactComponent,
GeneResultsSlimTableComponent,
DescriptionDisplayComponent,
QueryDescriptionDisplayComponent,
FacetedSearchComponent,
ChromosomeOverviewComponent,
PublicationBadgeComponent,
Expand Down
28 changes: 0 additions & 28 deletions src/app/shared/util.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { SolrAlleleSummary } from '../complete.service';
import { GenotypeDetails, GenotypeShort, GeneShort,
AlleleShort, TranscriptDetails} from '../pombase-api.service';
import { TermId } from '../pombase-query';

export type TextOrTermId = {
text?: string;
termid?: TermId;
}
export class Util {
static geneCompare(gene1: GeneShort, gene2: GeneShort): number {
if (gene1.name) {
Expand Down Expand Up @@ -242,27 +237,4 @@ export class Util {

return ret;
}

static splitDescription(description: string, termids: Array<TermId>): Array<TextOrTermId> {
if (termids.length == 0) {
return [{ text: description }];
}

const termidRe = new RegExp('(' + termids.join('|') + ')');

const descriptionBits = description.split(termidRe);

return descriptionBits.map(bit => {
const index = termids.indexOf(bit);
if (index === -1) {
return {
text: bit,
};
} else {
return {
termid: bit,
};
}
});
}
}

0 comments on commit 27025c6

Please sign in to comment.