Skip to content

Commit

Permalink
Restore getSnapshot on individual displayedRegions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jun 21, 2021
1 parent fb246ee commit 8ed5e00
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 39 deletions.
2 changes: 0 additions & 2 deletions packages/core/assemblyManager/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,3 @@ async function loadAssemblyReaction(
return { adapterRegionsWithAssembly, refNameAliases }
}
export type Assembly = Instance<ReturnType<typeof assemblyFactory>>

export type AssemblyRegions = Assembly['regions']
2 changes: 0 additions & 2 deletions plugins/linear-genome-view/src/LinearGenomeView/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,6 @@ describe('Get Sequence for selected displayed regions', () => {
model.setDisplayedRegions([
{ assemblyName: 'volvox', refName: 'ctgA', start: 0, end: 800 },
])
expect(model.displayedParentRegions.length).toEqual(1)
expect(model.displayedParentRegionsLength).toEqual(50001)
model.setOffsets(
{
refName: 'ctgA',
Expand Down
64 changes: 29 additions & 35 deletions plugins/linear-genome-view/src/LinearGenomeView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,31 @@ export const RESIZE_HANDLE_HEIGHT = 3
export const INTER_REGION_PADDING_WIDTH = 2

export function stateModelFactory(pluginManager: PluginManager) {
const model = types
.model('LinearGenomeView', {
id: ElementId,
type: types.literal('LinearGenomeView'),
offsetPx: 0,
bpPerPx: 1,
displayedRegions: types.array(MUIRegion),
// we use an array for the tracks because the tracks are displayed in a specific
// order that we need to keep.
tracks: types.array(
pluginManager.pluggableMstType('track', 'stateModel'),
),
hideHeader: false,
hideHeaderOverview: false,
trackSelectorType: types.optional(
types.enumeration(['hierarchical']),
'hierarchical',
),
trackLabels: 'overlapping' as 'overlapping' | 'hidden' | 'offset',
showCenterLine: false,
})
return types
.compose(
BaseViewModel,
types.model('LinearGenomeView', {
id: ElementId,
type: types.literal('LinearGenomeView'),
offsetPx: 0,
bpPerPx: 1,
displayedRegions: types.array(MUIRegion),

// we use an array for the tracks because the tracks are displayed in a
// specific order that we need to keep.
tracks: types.array(
pluginManager.pluggableMstType('track', 'stateModel'),
),
hideHeader: false,
hideHeaderOverview: false,
trackSelectorType: types.optional(
types.enumeration(['hierarchical']),
'hierarchical',
),
trackLabels: 'overlapping' as 'overlapping' | 'hidden' | 'offset',
showCenterLine: false,
}),
)
.volatile(() => ({
volatileWidth: undefined as number | undefined,
minimumBlockWidth: 3,
Expand Down Expand Up @@ -332,7 +336,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
const region = self.displayedRegions[0]
const offset = bp
return {
...region,
...getSnapshot(region),
oob: true,
coord: region.reversed
? Math.floor(region.end - offset) + 1
Expand All @@ -351,7 +355,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
const offset = bp - bpSoFar
if (len + bpSoFar > bp && bpSoFar <= bp) {
return {
...region,
...getSnapshot(region),
oob: false,
offset,
coord: region.reversed
Expand Down Expand Up @@ -379,7 +383,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
const len = region.end - region.start
const offset = bp - bpSoFar + len
return {
...region,
...getSnapshot(region),
oob: true,
offset,
coord: region.reversed
Expand Down Expand Up @@ -646,15 +650,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
self.showCenterLine = !self.showCenterLine
},

setDisplayedRegions(
regions: {
start: number
end: number
refName: string
assemblyName: string
reversed?: boolean
}[],
) {
setDisplayedRegions(regions: Region[]) {
self.displayedRegions = cast(regions)
self.zoomTo(self.bpPerPx)
},
Expand Down Expand Up @@ -1376,8 +1372,6 @@ export function stateModelFactory(pluginManager: PluginManager) {
saveAs(blob, 'image.svg')
},
}))

return types.compose(BaseViewModel, model)
}

export { renderToSvg }
Expand Down

0 comments on commit 8ed5e00

Please sign in to comment.