diff --git a/packages/core/BaseFeatureWidget/BaseFeatureDetail.tsx b/packages/core/BaseFeatureWidget/BaseFeatureDetail.tsx index 98f9d5872f4..e43a4395f21 100644 --- a/packages/core/BaseFeatureWidget/BaseFeatureDetail.tsx +++ b/packages/core/BaseFeatureWidget/BaseFeatureDetail.tsx @@ -23,6 +23,7 @@ import { getSession, defaultCodonTable, generateCodonTable, + revcom, } from '../util' import { Feature } from '../util/simpleFeature' import SanitizedHTML from '../ui/SanitizedHTML' @@ -214,6 +215,17 @@ interface BaseProps extends BaseCardProps { model?: any } +function stitch(subfeats: any, feature: any, sequence: string) { + let chunks = subfeats.map((sub: any) => { + const chunk = sequence.slice(sub.start, sub.end) + return feature.strand === -1 ? revcom(chunk) : chunk + }) + if (feature.strand === -1) { + chunks = chunks.reverse() + } + return chunks.join('') +} + // display the stitched-together sequence of a gene's CDS, cDNA, or protein // sequence. this is a best effort and weird genomic phenomena could lead these // to not be 100% accurate @@ -262,6 +274,7 @@ function SequenceFeatureDetails(props: BaseProps) { const text: React.ReactNode[] = [] if (sequence && feature) { + const { strand } = feature const children = feature.subfeatures .sort((a: any, b: any) => a.start - b.start) .map((sub: any) => { @@ -280,47 +293,46 @@ function SequenceFeatureDetails(props: BaseProps) { const exons = children.filter((sub: any) => sub.type === 'exon') if (mode === 'cds') { - cds.forEach((sub: any) => { + text.push( +