Skip to content

Commit

Permalink
feat: link to organism page from assembly list and detail (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterckx committed Jan 24, 2025
1 parent 09542fc commit d70d70c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/apis/catalog/brc-analytics-catalog/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export function getOrganismId(organism: BRCDataCatalogOrganism): string {
return sanitizeEntityId(organism.ncbiTaxonomyId);
}

/**
* Get the ID of the organism entity associated with the given genome.
* @param genome - Genome.
* @returns organism ID.
*/
export function getGenomeOrganismId(genome: BRCDataCatalogGenome): string {
return sanitizeEntityId(genome.speciesTaxonomyId);
}

export function sanitizeEntityId(entityId?: string): string {
if (!entityId) return "";
return entityId.replace(/\./g, "_");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "site-config/brc-analytics/category";
import {
getGenomeId,
getGenomeOrganismId,
getOrganismId,
} from "../../../../apis/catalog/brc-analytics-catalog/common/utils";
import { COLUMN_IDENTIFIER } from "@databiosphere/findable-ui/lib/components/Table/common/columnIdentifier";
Expand Down Expand Up @@ -145,9 +146,10 @@ export const buildGcPercent = (
*/
export const buildGenomeSpecies = (
genome: BRCDataCatalogGenome
): ComponentProps<typeof C.BasicCell> => {
): ComponentProps<typeof C.Link> => {
return {
value: genome.species,
label: genome.species,
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getGenomeOrganismId(genome))}`,
};
};

Expand Down Expand Up @@ -379,9 +381,7 @@ export const buildGenomeDetails = (
BRC_DATA_CATALOG_CATEGORY_LABEL.SPECIES,
C.Link({
label: genome.species,
url: `https://www.ncbi.nlm.nih.gov/datasets/taxonomy/${encodeURIComponent(
genome.ncbiTaxonomyId
)}/`,
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getGenomeOrganismId(genome))}`,
})
);
keyValuePairs.set(
Expand Down
4 changes: 2 additions & 2 deletions site-config/brc-analytics/local/index/genomeEntityConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ export const genomeEntityConfig: BRCEntityConfig<BRCDataCatalogGenome> = {
},
{
componentConfig: {
component: C.BasicCell,
component: C.Link,
viewBuilder: V.buildGenomeSpecies,
} as ComponentConfig<typeof C.BasicCell, BRCDataCatalogGenome>,
} as ComponentConfig<typeof C.Link, BRCDataCatalogGenome>,
header: BRC_DATA_CATALOG_CATEGORY_LABEL.SPECIES,
id: BRC_DATA_CATALOG_CATEGORY_KEY.SPECIES,
width: { max: "1fr", min: "164px" },
Expand Down

0 comments on commit d70d70c

Please sign in to comment.