Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: link to organism page from assembly list and detail (#231) #232

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading