Skip to content

Commit 06bdb3c

Browse files
authored
feat: add taxonomic levels to assembly list (#312) (#316)
1 parent 665a20a commit 06bdb3c

File tree

9 files changed

+265
-202
lines changed

9 files changed

+265
-202
lines changed

app/apis/catalog/brc-analytics-catalog/common/entities.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ export interface BRCDataCatalogGenome {
1717
scaffoldCount: number | null;
1818
scaffoldL50: number | null;
1919
scaffoldN50: number | null;
20-
species: string;
2120
speciesTaxonomyId: string;
22-
strain: string | null;
21+
strainName: string | null;
2322
taxonomicGroup: string[];
2423
taxonomicLevelClass: string;
2524
taxonomicLevelFamily: string;

app/apis/catalog/brc-analytics-catalog/common/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function getGenomeId(genome: BRCDataCatalogGenome): string {
77

88
export function getGenomeTitle(genome?: BRCDataCatalogGenome): string {
99
if (!genome) return "";
10-
return `${genome.species}`;
10+
return `${genome.taxonomicLevelSpecies}`;
1111
}
1212

1313
export function getOrganismId(organism: BRCDataCatalogOrganism): string {

app/viewModelBuilders/catalog/brc-analytics-catalog/common/viewModelBuilders.ts

+75-58
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,28 @@ export const buildGcPercent = (
145145
* @param genome - Genome entity.
146146
* @returns Props to be used for the cell.
147147
*/
148-
export const buildGenomeSpecies = (
148+
export const buildGenomeTaxonomicLevelSpecies = (
149149
genome: BRCDataCatalogGenome
150150
): ComponentProps<typeof C.Link> => {
151151
return {
152-
label: genome.species,
152+
label: genome.taxonomicLevelSpecies,
153153
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getGenomeOrganismId(genome))}`,
154154
};
155155
};
156156

157+
/**
158+
* Build props for the strain cell.
159+
* @param genome - Genome entity.
160+
* @returns Props to be used for the cell.
161+
*/
162+
export const buildGenomeTaxonomicLevelStrain = (
163+
genome: BRCDataCatalogGenome
164+
): ComponentProps<typeof C.BasicCell> => {
165+
return {
166+
value: getGenomeStrainText(genome),
167+
};
168+
};
169+
157170
/**
158171
* Build props for the "is ref" cell.
159172
* @param genome - Genome entity.
@@ -207,6 +220,20 @@ export const buildOrganismAssemblyTaxonomyIds = (
207220
};
208221
};
209222

223+
/**
224+
* Build props for the species cell.
225+
* @param organism - Organism entity.
226+
* @returns Props to be used for the cell.
227+
*/
228+
export const buildOrganismTaxonomicLevelSpecies = (
229+
organism: BRCDataCatalogOrganism
230+
): ComponentProps<typeof C.Link> => {
231+
return {
232+
label: organism.taxonomicLevelSpecies,
233+
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getOrganismId(organism))}`,
234+
};
235+
};
236+
210237
/**
211238
* Build props for the strain cell.
212239
* @param organism - Organism entity.
@@ -237,106 +264,92 @@ export const buildTaxonomicGroup = (
237264

238265
/**
239266
* Build props for the class cell.
240-
* @param organism - Organism entity.
267+
* @param entity - Organism or genome entity.
241268
* @returns Props to be used for the cell.
242269
*/
243270
export const buildTaxonomicLevelClass = (
244-
organism: BRCDataCatalogOrganism
271+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
245272
): ComponentProps<typeof C.BasicCell> => {
246273
return {
247-
value: organism.taxonomicLevelClass,
274+
value: entity.taxonomicLevelClass,
248275
};
249276
};
250277

251278
/**
252279
* Build props for the family cell.
253-
* @param organism - Organism entity.
280+
* @param entity - Organism or genome entity.
254281
* @returns Props to be used for the cell.
255282
*/
256283
export const buildTaxonomicLevelFamily = (
257-
organism: BRCDataCatalogOrganism
284+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
258285
): ComponentProps<typeof C.BasicCell> => {
259286
return {
260-
value: organism.taxonomicLevelFamily,
287+
value: entity.taxonomicLevelFamily,
261288
};
262289
};
263290

264291
/**
265292
* Build props for the genus cell.
266-
* @param organism - Organism entity.
293+
* @param entity - Organism or genome entity.
267294
* @returns Props to be used for the cell.
268295
*/
269296
export const buildTaxonomicLevelGenus = (
270-
organism: BRCDataCatalogOrganism
297+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
271298
): ComponentProps<typeof C.BasicCell> => {
272299
return {
273-
value: organism.taxonomicLevelGenus,
300+
value: entity.taxonomicLevelGenus,
274301
};
275302
};
276303

277304
/**
278305
* Build props for the kingdom cell.
279-
* @param organism - Organism entity.
306+
* @param entity - Organism or genome entity.
280307
* @returns Props to be used for the cell.
281308
*/
282309
export const buildTaxonomicLevelKingdom = (
283-
organism: BRCDataCatalogOrganism
310+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
284311
): ComponentProps<typeof C.BasicCell> => {
285312
return {
286-
value: organism.taxonomicLevelKingdom,
313+
value: entity.taxonomicLevelKingdom,
287314
};
288315
};
289316

290317
/**
291318
* Build props for the order cell.
292-
* @param organism - Organism entity.
319+
* @param entity - Organism or genome entity.
293320
* @returns Props to be used for the cell.
294321
*/
295322
export const buildTaxonomicLevelOrder = (
296-
organism: BRCDataCatalogOrganism
323+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
297324
): ComponentProps<typeof C.BasicCell> => {
298325
return {
299-
value: organism.taxonomicLevelOrder,
326+
value: entity.taxonomicLevelOrder,
300327
};
301328
};
302329

303330
/**
304331
* Build props for the phylum cell.
305-
* @param organism - Organism entity.
332+
* @param entity - Organism or genome entity.
306333
* @returns Props to be used for the cell.
307334
*/
308335
export const buildTaxonomicLevelPhylum = (
309-
organism: BRCDataCatalogOrganism
336+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
310337
): ComponentProps<typeof C.BasicCell> => {
311338
return {
312-
value: organism.taxonomicLevelPhylum,
313-
};
314-
};
315-
316-
/**
317-
* Build props for the species cell.
318-
* @param organism - Organism entity.
319-
* @returns Props to be used for the cell.
320-
*/
321-
export const buildTaxonomicLevelSpecies = (
322-
organism: BRCDataCatalogOrganism
323-
): ComponentProps<typeof C.Link> => {
324-
return {
325-
label: organism.taxonomicLevelSpecies,
326-
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getOrganismId(organism))}`,
339+
value: entity.taxonomicLevelPhylum,
327340
};
328341
};
329342

330343
/**
331344
* Build props for the superkingdom cell.
332-
* @param organism - Organism entity.
345+
* @param entity - Organism or genome entity.
333346
* @returns Props to be used for the cell.
334347
*/
335348
export const buildTaxonomicLevelSuperkingdom = (
336-
organism: BRCDataCatalogOrganism
349+
entity: BRCDataCatalogOrganism | BRCDataCatalogGenome
337350
): ComponentProps<typeof C.BasicCell> => {
338351
return {
339-
value: organism.taxonomicLevelSuperkingdom,
352+
value: entity.taxonomicLevelSuperkingdom,
340353
};
341354
};
342355

@@ -379,19 +392,6 @@ export const buildScaffoldN50 = (
379392
};
380393
};
381394

382-
/**
383-
* Build props for the strain cell.
384-
* @param genome - Genome entity.
385-
* @returns Props to be used for the cell.
386-
*/
387-
export const buildStrain = (
388-
genome: BRCDataCatalogGenome
389-
): ComponentProps<typeof C.BasicCell> => {
390-
return {
391-
value: genome.strain,
392-
};
393-
};
394-
395395
/**
396396
* Build props for the taxonomy ID cell.
397397
* @param genome - Genome entity.
@@ -479,7 +479,7 @@ export const buildGenomeChooseAnalysisMethodDetailViewHero = (
479479
breadcrumbs: getGenomeEntityChooseAnalysisMethodBreadcrumbs(genome),
480480
subTitle: C.Link({
481481
TypographyProps: { color: "ink.light", variant: TEXT_BODY_SMALL_400 },
482-
label: `Species: ${genome.species}`,
482+
label: `Species: ${genome.taxonomicLevelSpecies}`,
483483
underline: "hover",
484484
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getGenomeOrganismId(genome))}`,
485485
}),
@@ -497,15 +497,15 @@ export const buildGenomeDetails = (
497497
): ComponentProps<typeof C.KeyValuePairs> => {
498498
const keyValuePairs = new Map<Key, Value>();
499499
keyValuePairs.set(
500-
BRC_DATA_CATALOG_CATEGORY_LABEL.SPECIES,
500+
BRC_DATA_CATALOG_CATEGORY_LABEL.TAXONOMIC_LEVEL_SPECIES,
501501
C.Link({
502-
label: genome.species,
502+
label: genome.taxonomicLevelSpecies,
503503
url: `${ROUTES.ORGANISMS}/${encodeURIComponent(getGenomeOrganismId(genome))}`,
504504
})
505505
);
506506
keyValuePairs.set(
507-
BRC_DATA_CATALOG_CATEGORY_LABEL.STRAIN,
508-
genome.strain ?? LABEL.UNSPECIFIED
507+
BRC_DATA_CATALOG_CATEGORY_LABEL.TAXONOMIC_LEVEL_STRAIN,
508+
getGenomeStrainText(genome, LABEL.UNSPECIFIED)
509509
);
510510
keyValuePairs.set(
511511
BRC_DATA_CATALOG_CATEGORY_LABEL.TAXONOMY_ID,
@@ -611,9 +611,10 @@ function buildOrganismGenomesTableColumns(): ColumnDef<BRCDataCatalogGenome>[] {
611611
header: BRC_DATA_CATALOG_CATEGORY_LABEL.ACCESSION,
612612
},
613613
{
614-
accessorKey: BRC_DATA_CATALOG_CATEGORY_KEY.STRAIN,
615-
cell: ({ row }) => C.BasicCell(buildStrain(row.original)),
616-
header: BRC_DATA_CATALOG_CATEGORY_LABEL.STRAIN,
614+
accessorKey: BRC_DATA_CATALOG_CATEGORY_KEY.TAXONOMIC_LEVEL_STRAIN,
615+
cell: ({ row }) =>
616+
C.BasicCell(buildGenomeTaxonomicLevelStrain(row.original)),
617+
header: BRC_DATA_CATALOG_CATEGORY_LABEL.TAXONOMIC_LEVEL_STRAIN,
617618
},
618619
{
619620
accessorKey: BRC_DATA_CATALOG_CATEGORY_KEY.TAXONOMY_ID,
@@ -688,6 +689,22 @@ function getGenomeEntityChooseAnalysisMethodBreadcrumbs(
688689
];
689690
}
690691

692+
/**
693+
* Get text for genome strain, consisting of, from highest to lowest priority, either: strain-only name; strain name including species; or the specified default value.
694+
* @param genome - Genome entity.
695+
* @param defaultValue - Default value to use if there's no strain.
696+
* @returns strain text.
697+
*/
698+
function getGenomeStrainText(
699+
genome: BRCDataCatalogGenome,
700+
defaultValue = ""
701+
): string {
702+
if (genome.strainName) return genome.strainName;
703+
if (genome.taxonomicLevelStrain !== "None")
704+
return genome.taxonomicLevelStrain;
705+
return defaultValue;
706+
}
707+
691708
/**
692709
* Get the organism entity breadcrumbs.
693710
* @param organism - Organism entity.

catalog/build/ts/build-catalog.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async function buildGenomes(): Promise<BRCDataCatalogGenome[]> {
5151
console.log(`Skipping assembly ${row.accession} - ploidy not found`);
5252
continue;
5353
}
54+
const taxonomicLevelStrain = row.taxonomicLevelStrain || (row.strain ? `${row.taxonomicLevelSpecies} strain ${row.strain}` : "None");
5455
mappedRows.push({
5556
accession: row.accession,
5657
annotationStatus: parseStringOrNull(row.annotationStatus),
@@ -66,9 +67,8 @@ async function buildGenomes(): Promise<BRCDataCatalogGenome[]> {
6667
scaffoldCount: parseNumberOrNull(row.scaffoldCount),
6768
scaffoldL50: parseNumberOrNull(row.scaffoldL50),
6869
scaffoldN50: parseNumberOrNull(row.scaffoldN50),
69-
species: row.species,
7070
speciesTaxonomyId: row.speciesTaxonomyId,
71-
strain: parseStringOrNull(row.strain),
71+
strainName: parseStringOrNull(row.strain),
7272
taxonomicGroup: row.taxonomicGroup ? row.taxonomicGroup.split(",") : [],
7373
taxonomicLevelClass: defaultStringToNone(row.taxonomicLevelClass),
7474
taxonomicLevelFamily: defaultStringToNone(row.taxonomicLevelFamily),
@@ -77,7 +77,7 @@ async function buildGenomes(): Promise<BRCDataCatalogGenome[]> {
7777
taxonomicLevelOrder: defaultStringToNone(row.taxonomicLevelOrder),
7878
taxonomicLevelPhylum: defaultStringToNone(row.taxonomicLevelPhylum),
7979
taxonomicLevelSpecies: defaultStringToNone(row.taxonomicLevelSpecies),
80-
taxonomicLevelStrain: defaultStringToNone(row.taxonomicLevelStrain),
80+
taxonomicLevelStrain,
8181
taxonomicLevelSuperkingdom: defaultStringToNone(row.taxonomicLevelSuperkingdom),
8282
ucscBrowserUrl: parseStringOrNull(row.ucscBrowser),
8383
});

0 commit comments

Comments
 (0)