-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1601 from GMOD/color_by_base
Add ability to color by per-base quality in alignment tracks
- Loading branch information
Showing
5 changed files
with
318 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
plugins/alignments/src/PileupRenderer/PileupLayoutSession.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import deepEqual from 'deep-equal' | ||
import { LayoutSession } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType' | ||
import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema' | ||
import SerializableFilterChain from '@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain' | ||
import GranularRectLayout from '@jbrowse/core/util/layouts/GranularRectLayout' | ||
import MultiLayout from '@jbrowse/core/util/layouts/MultiLayout' | ||
import { readConfObject } from '@jbrowse/core/configuration' | ||
|
||
export interface PileupLayoutSessionProps { | ||
config: AnyConfigurationModel | ||
bpPerPx: number | ||
filters: SerializableFilterChain | ||
sortedBy: unknown | ||
showSoftClip: unknown | ||
} | ||
|
||
type MyMultiLayout = MultiLayout<GranularRectLayout<unknown>, unknown> | ||
interface CachedPileupLayout { | ||
layout: MyMultiLayout | ||
config: AnyConfigurationModel | ||
filters: SerializableFilterChain | ||
sortedBy: unknown | ||
showSoftClip: boolean | ||
} | ||
// Sorting and revealing soft clip changes the layout of Pileup renderer | ||
// Adds extra conditions to see if cached layout is valid | ||
export class PileupLayoutSession extends LayoutSession { | ||
sortedBy: unknown | ||
|
||
showSoftClip = false | ||
|
||
constructor(args: PileupLayoutSessionProps) { | ||
super(args) | ||
this.config = args.config | ||
} | ||
|
||
cachedLayoutIsValid(cachedLayout: CachedPileupLayout) { | ||
return ( | ||
super.cachedLayoutIsValid(cachedLayout) && | ||
this.showSoftClip === cachedLayout.showSoftClip && | ||
deepEqual(this.sortedBy, cachedLayout.sortedBy) | ||
) | ||
} | ||
|
||
cachedLayout: CachedPileupLayout | undefined | ||
|
||
get layout(): MyMultiLayout { | ||
if (!this.cachedLayout || !this.cachedLayoutIsValid(this.cachedLayout)) { | ||
this.cachedLayout = { | ||
layout: this.makeLayout(), | ||
config: readConfObject(this.config), | ||
filters: this.filters, | ||
sortedBy: this.sortedBy, | ||
showSoftClip: this.showSoftClip, | ||
} | ||
} | ||
return this.cachedLayout.layout | ||
} | ||
} |
Oops, something went wrong.