Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add protein sequence to transcript detail panel #486

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'

Check warning on line 3 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L3

Added line #L3 was not covered by tests
import {
Button,
MenuItem,
Expand All @@ -18,7 +18,7 @@
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 @@
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)

Check warning on line 129 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L124-L129

Added lines #L124 - L129 were not covered by tests
if (strand === -1) {
sequence = revcom(sequence)

Check warning on line 131 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L131

Added line #L131 was not covered by tests
}
wholeSequence += sequence
locs.push({ min: loc.min, max: loc.max })

Check warning on line 134 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L133-L134

Added lines #L133 - L134 were not covered by tests
}
let protein = ''
for (let i = 0; i < wholeSequence.length; i += 3) {
const codonSeq: string = wholeSequence.slice(i, i + 3).toUpperCase()
protein +=

Check warning on line 139 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L136-L139

Added lines #L136 - L139 were not covered by tests
defaultCodonTable[codonSeq as keyof typeof defaultCodonTable] || '&'
}
const sequenceLines = splitStringIntoChunks(protein, SEQUENCE_WRAP_LENGTH)
segments.push({ type: 'protein', sequenceLines, locs })
return segments

Check warning on line 144 in packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptSequence.tsx#L142-L144

Added lines #L142 - L144 were not covered by tests
}
}
}

Expand Down Expand Up @@ -238,6 +260,7 @@
<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