Skip to content

Commit

Permalink
Convert to zero-based coordinates on import (GMOD#301)
Browse files Browse the repository at this point in the history
* Convert to zero-based coordinates on import

* need comment from Garrett

* tmp commit

* tmp commit

* More adjustments to display as 1-based

---------

Co-authored-by: Kyosti Sutinen <[email protected]>
  • Loading branch information
garrettjstevens and kyostiebi authored Oct 31, 2023
1 parent 9819c4f commit b98b5d4
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
.eslintrc.js
esm/
coverage/
4 changes: 2 additions & 2 deletions packages/apollo-common/src/AssemblySpecificChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function createFeature(
gffId: '',
refSeq,
type,
start,
start: start - 1,
end,
}
if (gff3Feature.length > 1) {
Expand Down Expand Up @@ -329,7 +329,7 @@ function createFeature(
}
}
}
return { start: subStart, end: subEnd, phase: parsedPhase }
return { start: subStart - 1, end: subEnd, phase: parsedPhase }
})
}
if (strand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export class ApolloTextSearchAdapter
new BaseResult({
label: query,
trackId: this.trackId,
locString: `${feature.refSeq?.name}:${feature.start}..${feature.end}`,
locString: `${feature.refSeq?.name}:${feature.start + 1}..${
feature.end
}`,
}),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,26 @@ export abstract class Glyph {
if (!lastLoc) {
return
}
start = lastLoc?.start
end = lastLoc?.end
length = lastLoc?.end - lastLoc?.start
;({ start } = lastLoc)
;({ end } = lastLoc)
length = lastLoc.end - lastLoc.start

if (discontinuousLocations.length <= 2) {
for (const [i, loc] of discontinuousLocations.entries()) {
location += `${loc.start.toString()}-${loc.end.toString()}`
location += `${loc.start + 1}${loc.end}`
if (i !== discontinuousLocations.length - 1) {
location += ','
}
}
} else {
const [firstLoc] = discontinuousLocations
location += `${firstLoc.start}-${firstLoc.end},..,${start}-${end}`
location += `${firstLoc.start + 1}${firstLoc.end},…,${
lastLoc.start + 1
}${lastLoc.end}`
}
} else {
;({ end, length, start } = feature)
location += `${start.toString()}-${end.toString()}`
location += `${start + 1}${end}`
}

let startPx =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ export const Feature = observer(function Feature({
{discontinuousLocations.map((loc, index) => (
<NumberCell
key={`${_id}:${loc.start},${loc.phase}`}
initialValue={loc.start}
initialValue={loc.start + 1}
notifyError={notifyError}
onChangeCommitted={(newStart) =>
handleFeatureStartChange(
changeManager,
feature,
discontinuousLocations[index].start,
newStart,
newStart - 1,
index,
)
}
Expand All @@ -241,14 +241,14 @@ export const Feature = observer(function Feature({
</div>
) : (
<NumberCell
initialValue={start}
initialValue={start + 1}
notifyError={notifyError}
onChangeCommitted={(newStart) =>
handleFeatureStartChange(
changeManager,
feature,
start,
newStart,
newStart - 1,
)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function AddChildFeature({
}: AddChildFeatureProps) {
const { notify } = session as unknown as AbstractSessionModel
const [end, setEnd] = useState(String(sourceFeature.end))
const [start, setStart] = useState(String(sourceFeature.start))
const [start, setStart] = useState(String(sourceFeature.start + 1))
const [type, setType] = useState('')
const [phase, setPhase] = useState('')
const [phaseAsNumber, setPhaseAsNumber] = useState<PhaseEnum>()
Expand Down Expand Up @@ -102,7 +102,7 @@ export function AddChildFeature({
_id: new ObjectID().toHexString(),
gffId: '',
refSeq: sourceFeature.refSeq,
start: Number(start),
start: Number(start) - 1,
end: Number(end),
type,
phase: phaseAsNumber,
Expand Down
6 changes: 3 additions & 3 deletions packages/jbrowse-plugin-apollo/src/components/AddFeature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function AddFeature({
}: AddFeatureProps) {
const { notify } = session as unknown as AbstractSessionModel
const [end, setEnd] = useState(String(region.end))
const [start, setStart] = useState(String(region.start))
const [start, setStart] = useState(String(region.start + 1))
const [type, setType] = useState('')
const [phase, setPhase] = useState('')
const [strand, setStrand] = useState<1 | -1 | undefined>()
Expand Down Expand Up @@ -83,7 +83,7 @@ export function AddFeature({
_id: id,
gffId: '',
refSeq: refSeqId,
start: Number(start),
start: Number(start) - 1,
end: Number(end),
type,
phase: phaseAsNumber,
Expand Down Expand Up @@ -169,7 +169,7 @@ export function AddFeature({
type="number"
fullWidth
variant="outlined"
value={start}
value={Number(start)}
onChange={(e) => setStart(e.target.value)}
/>
<TextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function createFeature(gff3Feature: GFF3Feature): AnnotationFeatureSnapshot {
gffId: '',
refSeq: refName,
type,
start,
start: start - 1,
end,
}
if (gff3Feature.length > 1) {
Expand Down Expand Up @@ -297,7 +297,7 @@ function createFeature(gff3Feature: GFF3Feature): AnnotationFeatureSnapshot {
}
}
}
return { start: subStart, end: subEnd, phase: parsedPhase }
return { start: subStart - 1, end: subEnd, phase: parsedPhase }
})
}
if (strand) {
Expand Down

0 comments on commit b98b5d4

Please sign in to comment.