From 28bd3ed9a4b1a03aeee9ddf9da6015d7679880e9 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:38:01 -0800 Subject: [PATCH] fixup! Require strand in calculateStackPosition --- src/util/entropyCreateStateFromJsons.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/util/entropyCreateStateFromJsons.ts b/src/util/entropyCreateStateFromJsons.ts index f3c2fe763..06720476b 100644 --- a/src/util/entropyCreateStateFromJsons.ts +++ b/src/util/entropyCreateStateFromJsons.ts @@ -352,12 +352,13 @@ function calculateStackPosition( strand: Strand, ): number { /* List of CDSs, sorted by their earliest occurrence in the genome (for any segment) */ - let cdss = genes.reduce((acc: CDS[], gene) => [...acc, ...gene.cds], []); - cdss = cdss.filter((cds) => cds.strand===strand); - cdss.sort((a, b) => - Math.min(...a.segments.map((s) => s.rangeGenome[0])) < Math.min(...b.segments.map((s) => s.rangeGenome[0])) ? - -1 : 1 - ); + const cdss = genes + .reduce((acc: CDS[], gene) => [...acc, ...gene.cds], []) + .filter((cds) => cds.strand===strand) + .sort((a, b) => + Math.min(...a.segments.map((s) => s.rangeGenome[0])) < Math.min(...b.segments.map((s) => s.rangeGenome[0])) ? + -1 : 1 + ); let stack: CDS[] = []; // current CDSs in stack for (const newCds of cdss) { /* remove any CDS from the stack which has ended (completely) before this one starts */