From f15d0379c3ea02849ebc34bb4109099db6d5235e Mon Sep 17 00:00:00 2001 From: jpaten Date: Mon, 10 Feb 2025 17:22:30 -0800 Subject: [PATCH] chore: remvoed ncpi viewmodelbuilders and misc references (#4357) --- .gitignore | 3 +- .../catalog/ncpi-catalog/common/entities.ts | 42 --- app/apis/catalog/ncpi-catalog/common/utils.ts | 71 ---- .../ncpi-catalog/common/viewModelBuilders.ts | 347 ------------------ cc-dev-deploy-all.sh | 1 - files/package.json | 8 +- 6 files changed, 2 insertions(+), 470 deletions(-) delete mode 100644 app/apis/catalog/ncpi-catalog/common/entities.ts delete mode 100644 app/apis/catalog/ncpi-catalog/common/utils.ts delete mode 100644 app/viewModelBuilders/catalog/ncpi-catalog/common/viewModelBuilders.ts diff --git a/.gitignore b/.gitignore index 1e1895ac0..756b993cc 100644 --- a/.gitignore +++ b/.gitignore @@ -56,8 +56,7 @@ _templates # favicons /public/favicons/* -/files/anvil-catalog/out/ -/files/ncpi-catalog/out/ +/files/**/out/ #Python __pycache__/ diff --git a/app/apis/catalog/ncpi-catalog/common/entities.ts b/app/apis/catalog/ncpi-catalog/common/entities.ts deleted file mode 100644 index 95ce91bcb..000000000 --- a/app/apis/catalog/ncpi-catalog/common/entities.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { DbGapStudy } from "../../common/entities"; - -export interface PlatformStudy { - dbGapId: string; - platform: string; -} - -export interface NCPIStudy extends DbGapStudy { - consentLongNames: Record; - platforms: string[]; -} - -export type DbGapId = string; - -export type NCPICatalogEntity = NCPICatalogPlatform | NCPICatalogStudy; - -export interface NCPICatalogPlatform { - consentCode: string[]; - consentLongName: Record; - dataType: string[]; - dbGapId: string[]; - focus: string[]; - participantCount: number; - platform: string; - studyAccession: string[]; - studyDesign: string[]; - title: string[]; -} - -export interface NCPICatalogStudy { - consentCode: string[]; - consentLongName: Record; - dataType: string[]; - dbGapId: string; - focus: string; - participantCount: number; - platform: string[]; - studyAccession: string; - studyDescription: string; - studyDesign: string[]; - title: string; -} diff --git a/app/apis/catalog/ncpi-catalog/common/utils.ts b/app/apis/catalog/ncpi-catalog/common/utils.ts deleted file mode 100644 index 5b3fd79f9..000000000 --- a/app/apis/catalog/ncpi-catalog/common/utils.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { - sanitizeString, - sanitizeStringArray, -} from "@databiosphere/findable-ui/lib/viewModelBuilders/common/utils"; -import { NCPICatalogPlatform, NCPICatalogStudy, NCPIStudy } from "./entities"; - -export function NCPIStudyInputMapper(ncpiStudy: NCPIStudy): NCPICatalogStudy { - const ncpiCatalogStudy: NCPICatalogStudy = { - consentCode: sanitizeStringArray(ncpiStudy.consentCodes), - consentLongName: ncpiStudy.consentLongNames, - dataType: sanitizeStringArray(ncpiStudy.dataTypes), - dbGapId: ncpiStudy.dbGapId, - focus: sanitizeString(ncpiStudy.focus), - participantCount: ncpiStudy.participantCount, - platform: ncpiStudy.platforms, - studyAccession: ncpiStudy.studyAccession, - studyDescription: ncpiStudy.description, - studyDesign: ncpiStudy.studyDesigns, - title: sanitizeString(ncpiStudy.title), - }; - return ncpiCatalogStudy; -} - -export function NCPIPlatformInputMapper( - ncpiPlatform: NCPICatalogPlatform -): NCPICatalogPlatform { - const ncpiCatalogPlatform: NCPICatalogPlatform = { - consentCode: sanitizeStringArray(ncpiPlatform.consentCode), - consentLongName: ncpiPlatform.consentLongName, - dataType: sanitizeStringArray(ncpiPlatform.dataType), - dbGapId: sanitizeStringArray(ncpiPlatform.dbGapId), - focus: sanitizeStringArray(ncpiPlatform.focus), - participantCount: ncpiPlatform.participantCount, - platform: ncpiPlatform.platform, - studyAccession: ncpiPlatform.studyAccession, - studyDesign: ncpiPlatform.studyDesign, - title: sanitizeStringArray(ncpiPlatform.title), - }; - return ncpiCatalogPlatform; -} - -/** - * Returns the platform ID - * @param ncpiCatalogPlatform - NCPI catalog platform. - * @returns String value of platform which is the platform name) - */ -export const getPlatformId = ( - ncpiCatalogPlatform: NCPICatalogPlatform -): string => ncpiCatalogPlatform.platform ?? ""; - -/** - * Returns the study ID which is the dbGaPId. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns String value of dbGapId. - */ -//TODO dbGaP is is not unique if the study has no ID. -export const getStudyId = (ncpiCatalogStudy: NCPICatalogStudy): string => - ncpiCatalogStudy.dbGapId ?? ""; - -/** - * Returns the study title from the given API response. - * Facilitates setting within the `` element of the page. - * @param ncpiCatalogStudy - Response model return from entity API. - * @returns study title. - */ -export const getTitle = ( - ncpiCatalogStudy?: NCPICatalogStudy -): string | undefined => { - if (!ncpiCatalogStudy) return; - return ncpiCatalogStudy.title; -}; diff --git a/app/viewModelBuilders/catalog/ncpi-catalog/common/viewModelBuilders.ts b/app/viewModelBuilders/catalog/ncpi-catalog/common/viewModelBuilders.ts deleted file mode 100644 index 16be7ce9b..000000000 --- a/app/viewModelBuilders/catalog/ncpi-catalog/common/viewModelBuilders.ts +++ /dev/null @@ -1,347 +0,0 @@ -import { stringifyValues } from "@databiosphere/findable-ui/lib/common/utils"; -import { Breadcrumb } from "@databiosphere/findable-ui/lib/components/common/Breadcrumbs/breadcrumbs"; -import { - Key, - Value, -} from "@databiosphere/findable-ui/lib/components/common/KeyValuePairs/keyValuePairs"; -import { ANCHOR_TARGET } from "@databiosphere/findable-ui/lib/components/Links/common/entities"; -import { ViewContext } from "@databiosphere/findable-ui/lib/config/entities"; -import React, { ReactElement } from "react"; -import { - NCPICatalogEntity, - NCPICatalogPlatform, - NCPICatalogStudy, -} from "../../../../apis/catalog/ncpi-catalog/common/entities"; -import * as C from "../../../../components"; -import { METADATA_KEY } from "../../../../components/Index/common/entities"; -import { getPluralizedMetadataLabel } from "../../../../components/Index/common/indexTransformer"; - -/** - * Build props for ConsentCodesCell component from the given NCPI entity. - * @param ncpiCatalogEntry - NCPI catalog entity. - * @returns Model to be used as props for the ConsentCodesCell component. - */ -export const buildConsentCodes = ( - ncpiCatalogEntry: NCPICatalogEntity -): React.ComponentProps => { - return { - consentCode: ncpiCatalogEntry.consentCode, - consentLongName: ncpiCatalogEntry.consentLongName, - label: getPluralizedMetadataLabel(METADATA_KEY.CONSENT_CODE), - }; -}; - -/** - * Build props for data types NTagCell component from the given NCPI entity. - * @param ncpiCatalogEntry - NCPI catalog entity. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildDataTypes = ( - ncpiCatalogEntry: NCPICatalogEntity -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.DATA_TYPE), - values: ncpiCatalogEntry.dataType, - }; -}; - -/** - * Build props for dbGaPId BasicCell component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns Model to be used as props for the BasicCell component. - */ -export const buildDbGapId = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - return { - value: ncpiCatalogStudy.dbGapId, - }; -}; - -/** - * Build props for dbGaPIds NTagCell component from the given NCPI entity. - * @param ncpiCatalogPlatform - NCPI catalog platform. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildDbGapIds = ( - ncpiCatalogPlatform: NCPICatalogPlatform -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.DBGAP_ID), - values: ncpiCatalogPlatform.dbGapId, - }; -}; - -/** - * Build props for focus/disease BasicCell component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns Model to be used as props for the BasicCell component. - */ -export const buildFocus = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - return { - value: ncpiCatalogStudy.focus, - }; -}; - -/** - * Build props for focus/diseases NTagCell component from the given NCPI entity. - * @param ncpiCatalogPlatform - NCPI catalog platform. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildFocusDiseases = ( - ncpiCatalogPlatform: NCPICatalogPlatform -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.FOCUS_DISEASE), - values: ncpiCatalogPlatform.focus, - }; -}; - -/** - * Build props for participant count BasicCell component from the given NCPI entity. - * @param ncpiCatalogEntry - NCPI catalog entity. - * @returns Model to be used as props for the BasicCell component. - */ -export const buildParticipantCount = ( - ncpiCatalogEntry: NCPICatalogEntity -): React.ComponentProps => { - return { - value: ncpiCatalogEntry.participantCount, - }; -}; - -/** - * Build props for platform BasicCell component from the given NCPI entity. - * @param ncpiCatalogPlatform - NCPI catalog platform. - * @returns Model to be used as props for the BasicCell component. - */ -export const buildPlatform = ( - ncpiCatalogPlatform: NCPICatalogPlatform -): React.ComponentProps => { - return { - value: ncpiCatalogPlatform.platform, - }; -}; - -/** - * Build props for platforms NTagCell component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildPlatforms = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.PLATFORM), - values: ncpiCatalogStudy.platform, - }; -}; - -/** - * Build props for Links component for the "Applying For Access" section. - * @returns model to be used as props for the Links component. - */ -export const buildStudyApplyingForAccess = (): React.ComponentProps< - typeof C.Links -> => { - return { - links: [ - { - label: "dbGaP FAQ", - target: ANCHOR_TARGET.BLANK, - url: "https://www.ncbi.nlm.nih.gov/books/NBK5295/", - }, - { - label: "dbGaP Access Request Video Tutorial", - target: ANCHOR_TARGET.BLANK, - url: "https://www.youtube.com/watch?v=m0xp_cCO7kA", - }, - ], - }; -}; - -/** - * Build props for Markdown component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns model to be used as props for the Markdown component. - */ -export const buildStudyDescription = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - return { - content: ncpiCatalogStudy.studyDescription || "None", - }; -}; - -/** - * Build props for study designs NTagCell component from the given NCPI entity. - * @param ncpiCatalogEntity - NCPI catalog entity. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildStudyDesigns = ( - ncpiCatalogEntity: NCPICatalogEntity -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.STUDY_DESIGN), - values: ncpiCatalogEntity.studyDesign, - }; -}; - -/** - * Build props for KeyValuePairs component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns model to be used as props for the KeyValuePairs component. - */ -export const buildStudyDetails = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - const { dbGapId, platform, studyAccession } = ncpiCatalogStudy; - const keyValuePairs = new Map(); - keyValuePairs.set("Platforms", stringifyValues(platform)); - keyValuePairs.set("dbGaP ID", getStudyDbGapIdKeyValue(studyAccession)); - keyValuePairs.set("APIs", getStudyAPIKeyValue(dbGapId)); - return { - KeyElType: C.KeyElType, - KeyValuesElType: (props) => C.Stack({ gap: 4, ...props }), - ValueElType: C.ValueElType, - keyValuePairs, - }; -}; - -/** - * Build props for BackPageHero component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @param viewContext - View context. - * @returns model to be used as props for the BackPageHero component. - */ -export const buildStudyHero = ( - ncpiCatalogStudy: NCPICatalogStudy, - viewContext: ViewContext -): React.ComponentProps => { - const { dbGapId, title } = ncpiCatalogStudy; - return { - breadcrumbs: getCatalogBreadcrumbs(viewContext, title), - callToAction: { - label: "Request Access", - target: ANCHOR_TARGET.BLANK, - url: `https://dbgap.ncbi.nlm.nih.gov/aa/wga.cgi?adddataset=${dbGapId}`, - }, - title: title, - }; -}; - -/** - * Build props for Details component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns model to be used as props for the Details component. - */ -export const buildStudySummary = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - const { - consentCode, - consentLongName, - dataType, - focus, - participantCount, - studyDesign, - } = ncpiCatalogStudy; - const keyValuePairs = new Map(); - keyValuePairs.set( - "Consent Codes", - C.ConsentCodeList({ consentCode, consentLongName }) - ); - keyValuePairs.set("Focus / Diseases", focus); - keyValuePairs.set("Study Design", stringifyValues(studyDesign)); - keyValuePairs.set("Data Types", stringifyValues(dataType)); - keyValuePairs.set("Subjects", participantCount.toLocaleString()); - return { - keyValuePairs, - title: "Summary", - }; -}; - -/** - * Build props for study name Link component from the given NCPI entity. - * @param ncpiCatalogStudy - NCPI catalog study. - * @returns Model to be used as props for the Link component. - */ -export const buildStudyTitle = ( - ncpiCatalogStudy: NCPICatalogStudy -): React.ComponentProps => { - const { dbGapId, studyAccession, title } = ncpiCatalogStudy; - return { - label: title, - url: studyAccession ? `/studies/${dbGapId}` : "", - }; -}; - -/** - * Build props for study names NTagCell component from the given NCPI entity. - * @param ncpiCatalogPlatform - NCPI catalog platform. - * @returns Model to be used as props for the NTagCell component. - */ -export const buildStudyNames = ( - ncpiCatalogPlatform: NCPICatalogPlatform -): React.ComponentProps => { - return { - label: getPluralizedMetadataLabel(METADATA_KEY.STUDY), - values: ncpiCatalogPlatform.title, - }; -}; - -/** - * Returns catalog related breadcrumbs. - * @param viewContext - View context. - * @param lastCrumbText - Study title to be displayed as last crumb text. - * @returns catalog breadcrumbs. - */ -function getCatalogBreadcrumbs( - viewContext: ViewContext, - lastCrumbText?: string -): Breadcrumb[] { - const { label, route } = viewContext.entityConfig; - const firstCrumb = { - path: `/${route}`, - text: label, - }; - const breadcrumbs = [firstCrumb]; - if (lastCrumbText) { - breadcrumbs.push({ path: "", text: lastCrumbText }); - } - return breadcrumbs; -} - -/** - * Returns the KeyValuePair value for the specified NCPI entity. - * @param dbGapId - Study identifier. - * @returns the KeyValuePair value for study APIs as a ReactElement. - */ -function getStudyAPIKeyValue(dbGapId: string): ReactElement { - return C.Stack({ - children: C.Links({ - links: [ - { - label: "dbGaP FHIR", - target: ANCHOR_TARGET.BLANK, - url: `https://dbgap-api.ncbi.nlm.nih.gov/fhir/x1/ResearchStudy?_id=${dbGapId}&_format=json`, - }, - ], - }), - }); -} - -/** - * Returns the KeyValuePair value for the specified NCPI entity. - * @param studyAccession - Study identifier with version. - * @returns the KeyValuePair value for study dbGap Id as a ReactElement. - */ -function getStudyDbGapIdKeyValue(studyAccession: string): ReactElement { - return C.Link({ - label: studyAccession, - target: ANCHOR_TARGET.BLANK, - url: `https://www.ncbi.nlm.nih.gov/projects/gap/cgi-bin/study.cgi?study_id=${studyAccession}`, - }); -} diff --git a/cc-dev-deploy-all.sh b/cc-dev-deploy-all.sh index 29a60241a..5fce11307 100755 --- a/cc-dev-deploy-all.sh +++ b/cc-dev-deploy-all.sh @@ -7,7 +7,6 @@ scripts=( "./cc-explore.anvilproject.dev.clevercanary.com-deploy.sh" "./cc-explore.data.humancellatlas.dev.clevercanary.com-deploy.sh" "./cc-ma-pilot.explore.data.humancellatlas.dev.clevercanary.com-deploy.sh" - "./cc-ncpi-catalog-dev-deploy.sh" ) diff --git a/files/package.json b/files/package.json index 320c402cf..d34c242aa 100644 --- a/files/package.json +++ b/files/package.json @@ -5,13 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build-anvil-db": "esrun anvil-catalog/build-anvil-catalog.ts", - "build-ncpi-db": "esrun ncpi-catalog/build-ncpi-catalog.ts", - "update-anvil-source": "esrun ncpi-catalog/update-anvil-source.ts", - "update-bdc-source": "esrun ncpi-catalog/update-bdc-source.ts", - "update-crdc-source": "esrun ncpi-catalog/update-crdc-source.ts", - "update-kfdrc-source": "esrun ncpi-catalog/update-kfdrc-source.ts", - "update-all-ncpi-sources": "npm run update-crdc-source && npm run update-bdc-source && npm run update-anvil-source && npm run update-kfdrc-source" + "build-anvil-db": "esrun anvil-catalog/build-anvil-catalog.ts" }, "author": "", "license": "ISC",