From d673eaff8897cff4c2f0304dc61dabf427201736 Mon Sep 17 00:00:00 2001 From: Shashank Budhanuru Ramaraju Date: Mon, 2 Dec 2024 10:57:41 +0000 Subject: [PATCH 1/2] add protein sequence --- .../TranscriptSequence.tsx | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx b/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx index 4cbe5485..f4dfab8f 100644 --- a/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx +++ b/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx @@ -1,6 +1,6 @@ import { AnnotationFeature } from '@apollo-annotation/mst' import { splitStringIntoChunks } from '@apollo-annotation/shared' -import { revcom } from '@jbrowse/core/util' +import { defaultCodonTable, revcom } from '@jbrowse/core/util' import { Button, MenuItem, @@ -18,7 +18,7 @@ import { ApolloSessionModel } from '../session' const SEQUENCE_WRAP_LENGTH = 60 type SegmentType = 'upOrDownstream' | 'UTR' | 'CDS' | 'intron' | 'protein' -type SegmentListType = 'CDS' | 'cDNA' | 'genomic' +type SegmentListType = 'CDS' | 'cDNA' | 'genomic' | 'protein' interface SequenceSegment { type: SegmentType @@ -121,6 +121,28 @@ function getSequenceSegments( segments.push({ type: 'CDS', sequenceLines, locs }) return segments } + case 'protein': { + let wholeSequence = '' + const [firstLocation] = cdsLocations + const locs: { min: number; max: number }[] = [] + for (const loc of firstLocation) { + let sequence = getSequence(loc.min, loc.max) + if (strand === -1) { + sequence = revcom(sequence) + } + wholeSequence += sequence + locs.push({ min: loc.min, max: loc.max }) + } + let protein = '' + for (let i = 0; i < wholeSequence.length; i += 3) { + let codonSeq: string = wholeSequence.slice(i, i + 3).toUpperCase() + protein += + defaultCodonTable[codonSeq as keyof typeof defaultCodonTable] || '&' + } + const sequenceLines = splitStringIntoChunks(protein, SEQUENCE_WRAP_LENGTH) + segments.push({ type: 'protein', sequenceLines, locs }) + return segments + } } } @@ -238,6 +260,7 @@ export const TranscriptSequence = observer(function TranscriptSequence({ CDS cDNA Genomic + Protein Date: Mon, 2 Dec 2024 11:06:35 +0000 Subject: [PATCH 2/2] fix lint --- .../src/FeatureDetailsWidget/TranscriptSequence.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx b/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx index f4dfab8f..8a508421 100644 --- a/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx +++ b/packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx @@ -135,7 +135,7 @@ function getSequenceSegments( } let protein = '' for (let i = 0; i < wholeSequence.length; i += 3) { - let codonSeq: string = wholeSequence.slice(i, i + 3).toUpperCase() + const codonSeq: string = wholeSequence.slice(i, i + 3).toUpperCase() protein += defaultCodonTable[codonSeq as keyof typeof defaultCodonTable] || '&' }