From 89a5eaaf4947cb7a76c35efe8b8bb47e79bae1df Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Thu, 7 Dec 2023 05:38:45 +0100 Subject: [PATCH] feat: rename defaultGene and geneOrderPreference --- .../src/dataset/dataset_download.rs | 4 ++-- .../src/components/GeneMap/GeneMap.tsx | 6 +++--- .../src/components/GeneMap/GeneMapAxis.tsx | 4 ++-- .../src/components/GeneMap/getAxisLength.ts | 4 ++-- .../src/components/Results/ResultsTable.tsx | 4 ++-- .../Results/ResultsTableRowResult.tsx | 4 ++-- .../SequenceView/ListOfAminoacidDeletions.tsx | 4 ++-- .../ListOfAminoacidSubstitutions.tsx | 4 ++-- .../SequenceView/SequenceSelector.tsx | 20 +++++++++---------- packages_rs/nextclade-web/src/constants.ts | 2 +- .../nextclade-web/src/hooks/useRunAnalysis.ts | 20 +++++++++---------- .../nextclade-web/src/state/dataset.state.ts | 6 ++---- .../src/state/seqViewSettings.state.ts | 12 +++++------ .../nextclade/src/analyze/virus_properties.rs | 4 ++-- .../nextclade/src/run/nextclade_wasm.rs | 8 ++++---- 15 files changed, 52 insertions(+), 54 deletions(-) diff --git a/packages_rs/nextclade-cli/src/dataset/dataset_download.rs b/packages_rs/nextclade-cli/src/dataset/dataset_download.rs index fe9920f5c..1a346c168 100644 --- a/packages_rs/nextclade-cli/src/dataset/dataset_download.rs +++ b/packages_rs/nextclade-cli/src/dataset/dataset_download.rs @@ -232,8 +232,8 @@ pub fn dataset_individual_files_load( rest_files: BTreeMap::default(), other: serde_json::Value::default(), }, - default_gene: None, - gene_order_preference: vec![], + default_cds: None, + cds_order_preference: vec![], mut_labels: LabelledMutationsConfig::default(), primers: vec![], qc: None, diff --git a/packages_rs/nextclade-web/src/components/GeneMap/GeneMap.tsx b/packages_rs/nextclade-web/src/components/GeneMap/GeneMap.tsx index e6cb4c539..8b6790653 100644 --- a/packages_rs/nextclade-web/src/components/GeneMap/GeneMap.tsx +++ b/packages_rs/nextclade-web/src/components/GeneMap/GeneMap.tsx @@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react' import { ReactResizeDetectorDimensions, withResizeDetector } from 'react-resize-detector' import { useRecoilValue, useSetRecoilState } from 'recoil' import { ErrorInternal } from 'src/helpers/ErrorInternal' -import { isInNucleotideViewAtom, viewedGeneAtom } from 'src/state/seqViewSettings.state' +import { isInNucleotideViewAtom, viewedCdsAtom } from 'src/state/seqViewSettings.state' import styled from 'styled-components' import { BASE_MIN_WIDTH_PX } from 'src/constants' import type { Cds, CdsSegment } from 'src/types' @@ -88,7 +88,7 @@ export function CdsSegmentView({ const { t } = useTranslationSafe() const [showTooltip, setShowTooltip] = useState(false) - const setViewedGene = useSetRecoilState(viewedGeneAtom) + const setViewedGene = useSetRecoilState(viewedCdsAtom) const [hovered, setHovered] = useState(false) const [timeoutId, setTimeoutId] = useState(undefined) @@ -224,7 +224,7 @@ export type GeneMapProps = ReactResizeDetectorDimensions export function GeneMapUnsized({ width = 0, height = 0 }: GeneMapProps) { const cdsesAll = useRecoilValue(cdsesAtom) const genomeSize = useRecoilValue(genomeSizeAtom) - const viewedGene = useRecoilValue(viewedGeneAtom) + const viewedGene = useRecoilValue(viewedCdsAtom) const isInNucView = useRecoilValue(isInNucleotideViewAtom) const { viewBox, cdsSegViews, geneMapHeight } = useMemo(() => { diff --git a/packages_rs/nextclade-web/src/components/GeneMap/GeneMapAxis.tsx b/packages_rs/nextclade-web/src/components/GeneMap/GeneMapAxis.tsx index 44a49bce6..ff9b924e1 100644 --- a/packages_rs/nextclade-web/src/components/GeneMap/GeneMapAxis.tsx +++ b/packages_rs/nextclade-web/src/components/GeneMap/GeneMapAxis.tsx @@ -3,7 +3,7 @@ import { range } from 'lodash' import { XAxis, ComposedChart, ResponsiveContainer } from 'recharts' import { useRecoilValue } from 'recoil' import { cdsesAtom, genomeSizeAtom } from 'src/state/results.state' -import { viewedGeneAtom } from 'src/state/seqViewSettings.state' +import { viewedCdsAtom } from 'src/state/seqViewSettings.state' import { getAxisLength } from './getAxisLength' const MARGIN = {} @@ -26,7 +26,7 @@ export function getTickSize(axisLength: number) { export function GeneMapAxis() { const genomeSize = useRecoilValue(genomeSizeAtom) const cdses = useRecoilValue(cdsesAtom) - const viewedGene = useRecoilValue(viewedGeneAtom) + const viewedGene = useRecoilValue(viewedCdsAtom) const { ticks, domain } = useMemo(() => { const length = getAxisLength(genomeSize, viewedGene, cdses) diff --git a/packages_rs/nextclade-web/src/components/GeneMap/getAxisLength.ts b/packages_rs/nextclade-web/src/components/GeneMap/getAxisLength.ts index 8278ae969..acc72b3d6 100644 --- a/packages_rs/nextclade-web/src/components/GeneMap/getAxisLength.ts +++ b/packages_rs/nextclade-web/src/components/GeneMap/getAxisLength.ts @@ -1,11 +1,11 @@ import type { Cds } from 'src/types' -import { GENE_OPTION_NUC_SEQUENCE } from 'src/constants' +import { CDS_OPTION_NUC_SEQUENCE } from 'src/constants' import { cdsCodonLength } from 'src/types' /** Retrieves length of the axis to draw: Genome size in case of nuc sequence, or gene length on case of gene */ export function getAxisLength(genomeSize: number, viewedGene: string, cdses: Cds[]) { let length = genomeSize - if (viewedGene !== GENE_OPTION_NUC_SEQUENCE) { + if (viewedGene !== CDS_OPTION_NUC_SEQUENCE) { const cds = cdses?.find((cds) => cds.name === viewedGene) if (cds) { length = Math.round(cdsCodonLength(cds)) diff --git a/packages_rs/nextclade-web/src/components/Results/ResultsTable.tsx b/packages_rs/nextclade-web/src/components/Results/ResultsTable.tsx index 62e87b9a8..c1a89ee26 100644 --- a/packages_rs/nextclade-web/src/components/Results/ResultsTable.tsx +++ b/packages_rs/nextclade-web/src/components/Results/ResultsTable.tsx @@ -4,7 +4,7 @@ import { useTranslationSafe as useTranslation } from 'src/helpers/useTranslation import { FixedSizeList as FixedSizeListBase, FixedSizeListProps } from 'react-window' import AutoSizerBase from 'react-virtualized-auto-sizer' import { useRecoilCallback, useRecoilValue } from 'recoil' -import { viewedGeneAtom } from 'src/state/seqViewSettings.state' +import { viewedCdsAtom } from 'src/state/seqViewSettings.state' import styled from 'styled-components' import { SortCategory, SortDirection } from 'src/helpers/sortResults' @@ -78,7 +78,7 @@ export function ResultsTable() { const aaMotifsDescs = useRecoilValue(aaMotifsDescsAtom) const isResultsFilterPanelCollapsed = useRecoilValue(isResultsFilterPanelCollapsedAtom) - const viewedGene = useRecoilValue(viewedGeneAtom) + const viewedGene = useRecoilValue(viewedCdsAtom) const rowData: TableRowDatum[] = useMemo(() => { return seqIndices.map((seqIndex) => ({ diff --git a/packages_rs/nextclade-web/src/components/Results/ResultsTableRowResult.tsx b/packages_rs/nextclade-web/src/components/Results/ResultsTableRowResult.tsx index bbde6441a..20bbcbe27 100644 --- a/packages_rs/nextclade-web/src/components/Results/ResultsTableRowResult.tsx +++ b/packages_rs/nextclade-web/src/components/Results/ResultsTableRowResult.tsx @@ -26,7 +26,7 @@ import { } from 'src/components/Results/ResultsTableStyle' import { PeptideView } from 'src/components/SequenceView/PeptideView' import { SequenceView } from 'src/components/SequenceView/SequenceView' -import { GENE_OPTION_NUC_SEQUENCE } from 'src/constants' +import { CDS_OPTION_NUC_SEQUENCE } from 'src/constants' import { analysisResultAtom } from 'src/state/results.state' import { ColumnCoverage } from 'src/components/Results/ColumnCoverage' import { ColumnAaMotifs } from 'src/components/Results/ColumnAaMotifs' @@ -185,7 +185,7 @@ export function ResultsTableRowResult({ - {viewedGene === GENE_OPTION_NUC_SEQUENCE ? ( + {viewedGene === CDS_OPTION_NUC_SEQUENCE ? ( ) : ( diff --git a/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidDeletions.tsx b/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidDeletions.tsx index a77d6a407..bac0c063c 100644 --- a/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidDeletions.tsx +++ b/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidDeletions.tsx @@ -8,7 +8,7 @@ import { useTranslationSafe } from 'src/helpers/useTranslationSafe' import { splitToRows } from 'src/components/Results/splitToRows' import { TableSlim } from 'src/components/Common/TableSlim' import { AminoacidMutationBadge } from 'src/components/Common/MutationBadge' -import { geneOrderPreferenceAtom } from 'src/state/dataset.state' +import { cdsOrderPreferenceAtom } from 'src/state/dataset.state' import { sortByCdsName } from './sortByCdsName' export interface ListOfAminoacidDeletionsProps { @@ -18,7 +18,7 @@ export interface ListOfAminoacidDeletionsProps { export function ListOfAminoacidDeletions({ aminoacidDeletions }: ListOfAminoacidDeletionsProps) { const { t } = useTranslationSafe() - const geneOrderPreference = useRecoilValue(geneOrderPreferenceAtom) + const geneOrderPreference = useRecoilValue(cdsOrderPreferenceAtom) const totalDeletions = aminoacidDeletions.length const maxRows = 6 diff --git a/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidSubstitutions.tsx b/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidSubstitutions.tsx index 155408574..abdebfd54 100644 --- a/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidSubstitutions.tsx +++ b/packages_rs/nextclade-web/src/components/SequenceView/ListOfAminoacidSubstitutions.tsx @@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil' import copy from 'fast-copy' import type { AaSub } from 'src/types' -import { geneOrderPreferenceAtom } from 'src/state/dataset.state' +import { cdsOrderPreferenceAtom } from 'src/state/dataset.state' import { formatAAMutation } from 'src/helpers/formatMutation' import { useTranslationSafe } from 'src/helpers/useTranslationSafe' import { splitToRows } from 'src/components/Results/splitToRows' @@ -18,7 +18,7 @@ export interface ListOfAminoacidMutationsProps { export function ListOfAminoacidSubstitutions({ aminoacidSubstitutions }: ListOfAminoacidMutationsProps) { const { t } = useTranslationSafe() - const geneOrderPreference = useRecoilValue(geneOrderPreferenceAtom) + const geneOrderPreference = useRecoilValue(cdsOrderPreferenceAtom) const totalMutations = aminoacidSubstitutions.length const maxRows = Math.min(8, totalMutations) diff --git a/packages_rs/nextclade-web/src/components/SequenceView/SequenceSelector.tsx b/packages_rs/nextclade-web/src/components/SequenceView/SequenceSelector.tsx index 5e89f517f..74d6b9ef0 100644 --- a/packages_rs/nextclade-web/src/components/SequenceView/SequenceSelector.tsx +++ b/packages_rs/nextclade-web/src/components/SequenceView/SequenceSelector.tsx @@ -10,9 +10,9 @@ import { Badge as BadgeBase } from 'reactstrap' import { ButtonFilter } from 'src/components/Results/ButtonFilter' import { notUndefinedOrNull } from 'src/helpers/notUndefined' import styled from 'styled-components' -import { viewedGeneAtom } from 'src/state/seqViewSettings.state' +import { viewedCdsAtom } from 'src/state/seqViewSettings.state' import { useRecoilState, useRecoilValue } from 'recoil' -import { GENE_OPTION_NUC_SEQUENCE } from 'src/constants' +import { CDS_OPTION_NUC_SEQUENCE } from 'src/constants' import { useTranslationSafe } from 'src/helpers/useTranslationSafe' import { genesAtom } from 'src/state/results.state' import { ensureNumber } from 'src/helpers/number' @@ -30,23 +30,23 @@ export interface Option { export function SequenceSelector() { const genes = useRecoilValue(genesAtom) - const [viewedGene, setViewedGene] = useRecoilState(viewedGeneAtom) + const [viewedGene, setViewedGene] = useRecoilState(viewedCdsAtom) const { options, defaultOption } = useMemo(() => { return prepareOptions(genes) }, [genes]) const option = useMemo((): Option => { - if (viewedGene === GENE_OPTION_NUC_SEQUENCE) { - return { value: GENE_OPTION_NUC_SEQUENCE } + if (viewedGene === CDS_OPTION_NUC_SEQUENCE) { + return { value: CDS_OPTION_NUC_SEQUENCE } } return options.find((option) => option.cds?.name === viewedGene) ?? defaultOption }, [defaultOption, options, viewedGene]) const onChange = useCallback( (option: Option | null) => { - if (option?.value === GENE_OPTION_NUC_SEQUENCE) { - setViewedGene(GENE_OPTION_NUC_SEQUENCE) + if (option?.value === CDS_OPTION_NUC_SEQUENCE) { + setViewedGene(CDS_OPTION_NUC_SEQUENCE) } if (option?.cds?.name) { @@ -135,7 +135,7 @@ function OptionLabel(option: Option, meta: FormatOptionLabelMeta