Skip to content

Commit

Permalink
Add header to transcript sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Nov 13, 2024
1 parent e0f6628 commit fe6d77c
Showing 1 changed file with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type SegmentListType = 'CDS' | 'cDNA' | 'genomic'
interface SequenceSegment {
type: SegmentType
sequenceLines: string[]
locs: { min: number; max: number }[]
}

function getSequenceSegments(
Expand Down Expand Up @@ -54,7 +55,11 @@ function getSequenceSegments(
sequence,
SEQUENCE_WRAP_LENGTH,
)
segments.push({ type, sequenceLines })
segments.push({

Check warning on line 58 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#L58

Added line #L58 was not covered by tests
type,
sequenceLines,
locs: [{ min: loc.min, max: loc.max }],
})
continue

Check warning on line 63 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#L63

Added line #L63 was not covered by tests
}
if (previousSegment.type === type) {
Expand All @@ -65,6 +70,7 @@ function getSequenceSegments(
previousSegmentFirstLine,
...splitStringIntoChunks(newSequence, SEQUENCE_WRAP_LENGTH),
]
previousSegment.locs.push({ min: loc.min, max: loc.max })
} else {
const count = segments.reduce(

Check warning on line 75 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#L73-L75

Added lines #L73 - L75 were not covered by tests
(accumulator, currentSegment) =>
Expand All @@ -90,6 +96,7 @@ function getSequenceSegments(
segments.push({

Check warning on line 96 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#L96

Added line #L96 was not covered by tests
type,
sequenceLines: [newSegmentFirstLine, ...newSegmentRemainderLines],
locs: [{ min: loc.min, max: loc.max }],
})
}
}
Expand All @@ -98,18 +105,20 @@ function getSequenceSegments(
case 'CDS': {
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 110 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#L105-L110

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

Check warning on line 112 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#L112

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

Check warning on line 115 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#L114-L115

Added lines #L114 - L115 were not covered by tests
}
const sequenceLines = splitStringIntoChunks(

Check warning on line 117 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#L117

Added line #L117 was not covered by tests
wholeSequence,
SEQUENCE_WRAP_LENGTH,
)
segments.push({ type: 'CDS', sequenceLines })
segments.push({ type: 'CDS', sequenceLines, locs })
return segments

Check warning on line 122 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#L121-L122

Added lines #L121 - L122 were not covered by tests
}
}
Expand Down Expand Up @@ -193,6 +202,23 @@ export const TranscriptSequence = observer(function TranscriptSequence({
refData.getSequence(min, max),

Check warning on line 202 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#L201-L202

Added lines #L201 - L202 were not covered by tests
)
: []
const locationIntervals: { min: number; max: number }[] = []

Check warning on line 205 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#L204-L205

Added lines #L204 - L205 were not covered by tests
if (showSequence) {
const allLocs = sequenceSegments.flatMap((segment) => segment.locs)
let [previous] = allLocs
for (let i = 1; i < allLocs.length; i++) {

Check warning on line 209 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#L207-L209

Added lines #L207 - L209 were not covered by tests
if (previous.min === allLocs[i].max || previous.max === allLocs[i].min) {
previous = {

Check warning on line 211 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#L211

Added line #L211 was not covered by tests
min: Math.min(previous.min, allLocs[i].min),
max: Math.max(previous.max, allLocs[i].max),
}
} else {
locationIntervals.push(previous)
previous = allLocs[i]

Check warning on line 217 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#L215-L217

Added lines #L215 - L217 were not covered by tests
}
}
locationIntervals.push(previous)

Check warning on line 220 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#L220

Added line #L220 was not covered by tests
}

return (
<>
Expand All @@ -210,8 +236,8 @@ export const TranscriptSequence = observer(function TranscriptSequence({
onChange={handleChangeSeqOption}
>
<MenuItem value="CDS">CDS</MenuItem>
<MenuItem value={'cDNA'}>cDNA</MenuItem>
<MenuItem value={'genomic'}>Genomic</MenuItem>
<MenuItem value="cDNA">cDNA</MenuItem>
<MenuItem value="genomic">Genomic</MenuItem>
</Select>
<Paper
style={{
Expand All @@ -221,6 +247,16 @@ export const TranscriptSequence = observer(function TranscriptSequence({
}}
ref={seqRef}
>
&gt;{refSeq.name}:
{locationIntervals
.map((interval) =>
feature.strand === 1
? `${interval.min + 1}-${interval.max}`
: `${interval.max}-${interval.min + 1}`,

Check warning on line 255 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#L254-L255

Added lines #L254 - L255 were not covered by tests
)
.join(';')}
({feature.strand === 1 ? '+' : '-'})
<br />
{sequenceSegments.map((segment, index) => (
<span

Check warning on line 261 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#L261

Added line #L261 was not covered by tests
key={`${segment.type}-${index}`}
Expand Down

0 comments on commit fe6d77c

Please sign in to comment.