Skip to content

Commit

Permalink
VEP fixes (#1174)
Browse files Browse the repository at this point in the history
- Use actual species genome ids instead of the hard-coded ones in the table of VEP results
   (forgotten leftover from early prototype of VEP results table)
- Fix errors during submission status update caused by direct mutation of the redux state.
  • Loading branch information
azangru authored Oct 3, 2024
1 parent 96270ac commit c264b7b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,17 @@ const vepSubmissionsRestoreListener = {
}
}

// Make sure to not pass the actual submission objects to VepSubmissionStatusPolling,
// because the submission objects belong to the redux state, and are therefore immutable
const submissionsDataForPolling = unresolvedSubmissions.map(
(submission) => ({
id: submission.id,
status: submission.status
})
);

vepSubmissionStatusPolling.processSubmissionsOnStartup({
submissions: unresolvedSubmissions,
submissions: submissionsDataForPolling,
dispatch
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import type { VepResultsResponse } from 'src/content/app/tools/vep/types/vepResu

import styles from './VepSubmissionResults.module.css';

type RestoredVepSubmission = Omit<VepSubmissionWithoutInputFile, 'species'> & {
species: NonNullable<VepSubmissionWithoutInputFile['species']>;
};

/**
* TODO:
* - Add unique id to variants after they are requested (to use for keys)
Expand Down Expand Up @@ -126,6 +130,9 @@ const VepSubmissionResults = () => {
} = vepResults;
const { per_page, total } = paginationMetadata;
const maxPage = Math.ceil(total / per_page);
const genomeIdForUrl =
submission.species?.genome_tag ??
(submission as RestoredVepSubmission).species.genome_id;

return (
<div className={styles.container}>
Expand All @@ -146,7 +153,10 @@ const VepSubmissionResults = () => {
</div>
)}
<div className={styles.tableViewport}>
<VepResultsTable variants={vepResults.variants} />
<VepResultsTable
genomeId={genomeIdForUrl}
variants={vepResults.variants}
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -228,8 +238,9 @@ const MockFiltersToggle = () => {

const VepResultsTable = (props: {
variants: VepResultsResponse['variants'];
genomeId: string;
}) => {
const { variants } = props;
const { variants, genomeId } = props;

return (
<Table className={styles.table}>
Expand All @@ -247,7 +258,7 @@ const VepResultsTable = (props: {
<tbody>
{/* Use something more reliable for key than index */}
{variants.map((variant, index) => (
<VariantRow variant={variant} key={index} />
<VariantRow variant={variant} genomeId={genomeId} key={index} />
))}
</tbody>
</Table>
Expand All @@ -256,13 +267,15 @@ const VepResultsTable = (props: {

const VariantRow = (props: {
variant: VepResultsResponse['variants'][number];
genomeId: string;
}) => {
const { genomeId, variant } = props;
const [expandedTranscriptPaths, setExpandedTranscriptPaths] = useState<
ExpandedTranscriptsPath[]
>([]);

const tabularData = useVepVariantTabularData({
variant: props.variant,
variant,
expandedTranscriptPaths
});

Expand Down Expand Up @@ -303,7 +316,7 @@ const VariantRow = (props: {
rowSpan={row.variant.rowspan > 1 ? row.variant.rowspan : undefined}
>
<VepResultsLocation
genomeId="grch38"
genomeId={genomeId}
location={row.variant.location}
/>
</td>
Expand All @@ -320,7 +333,7 @@ const VariantRow = (props: {
<VepResultsAllele sequence={row.alternativeAllele.allele_sequence} />
</td>
)}
<GeneTableCell row={row} />
<GeneTableCell row={row} genomeId={genomeId} />
<TranscriptTableCell
row={row}
expandedTranscriptPaths={expandedTranscriptPaths}
Expand All @@ -333,13 +346,16 @@ const VariantRow = (props: {
));
};

const GeneTableCell = (props: { row: VepResultsTableRowData }) => {
const { row } = props;
const GeneTableCell = (props: {
row: VepResultsTableRowData;
genomeId: string;
}) => {
const { row, genomeId } = props;

if (row.gene) {
return (
<td rowSpan={row.gene.rowspan > 1 ? row.gene.rowspan : undefined}>
<VepResultsGene {...row.gene} genomeId="grch38" />
<VepResultsGene {...row.gene} genomeId={genomeId} />
</td>
);
} else if (row.consequence.feature_type === null) {
Expand Down

0 comments on commit c264b7b

Please sign in to comment.