Skip to content

Commit

Permalink
add protein sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Dec 2, 2024
1 parent aa3aab9 commit d673eaf
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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()

Check failure on line 138 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View workflow job for this annotation

GitHub Actions / Lint

'codonSeq' is never reassigned. Use 'const' instead
protein +=
defaultCodonTable[codonSeq as keyof typeof defaultCodonTable] || '&'
}
const sequenceLines = splitStringIntoChunks(protein, SEQUENCE_WRAP_LENGTH)
segments.push({ type: 'protein', sequenceLines, locs })
return segments
}
}
}

Expand Down Expand Up @@ -238,6 +260,7 @@ export const TranscriptSequence = observer(function TranscriptSequence({
<MenuItem value="CDS">CDS</MenuItem>
<MenuItem value="cDNA">cDNA</MenuItem>
<MenuItem value="genomic">Genomic</MenuItem>
<MenuItem value="protein">Protein</MenuItem>
</Select>
<Paper
style={{
Expand Down

0 comments on commit d673eaf

Please sign in to comment.