synteny-core
Auto-generated from exported functions tagged #api in the source. See
imports and re-exports for how to
import these from a plugin.
assignTrackColors
Map each overlaid track to the color it draws in under the track field.
Two passes so an automatic slot never duplicates a color the user pinned by hand: pass one reserves every explicit color, pass two hands each remaining track the next palette entry that isn't reserved. Past the end of the palette it wraps rather than falling back to a hash — a hashed color collides ~20% of the time at four tracks, and distinguishability is the whole point.
Positional, so colors reshuffle when tracks are added, hidden, or reordered. That is intended: this is a within-view distinguishability aid, not a stable identity. Anything worth keeping gets pinned.
// type signature
(tracks: readonly PalettableTrack[]) => Map<string, string>attributeOf
The per-feature attribute a field reads: mapq is the comparative
adapters' mappingQual, which they omit for MAPQ 255, so it paints and
keys as no value; any other field reads its own name.
// type signature
(field: string) => stringBAND_GROUND_COLOR
The color a comparative band is painted on, for every surface that has to
agree about it: the two backends' clear, the pre-blended indel wedges, every
mark, tick, label halo and outline (getContrastText of it), the legend
chips and the SVG export.
Light in every theme. The ribbons are translucent color that reads as tint over a light ground and as murk over a dark one, so a dark theme's paper made a whole-genome band nearly unreadable. The band is the one sheet in the app that keeps its own ground. The dotplot's plot area is the same sheet, since it paints the same color schemes, whose default is black.
// type signature
"#fff"bandInk
The inks a band draws in, off its own ground rather than the page theme, at the light theme's weights: a dark theme's text and dividers are white and vanish on the band.
// type signature
() => { text: string; divider: string; gridline: string; stripe: string; }bandPalette
The light palette, whose paper is BAND_GROUND_COLOR. Chrome on the band
that has a palette token of its own, such as the dotplot's gridlines and
region boundaries, reads it here and so matches the light theme in either
mode.
// type signature
JBrowsePaletteblendOverGround
Composite a CSS color over ground by a, returning an opaque rgb(...).
The synteny canvas draws every ribbon at the view's global alpha over the
band's ground (shadeFill in syntenyTypes.slang / resolveInstanceFill in the
Canvas2D renderer), so a full-saturation legend swatch reads wrong — a red
match ribbon shows as salmon over a white band, a blue deletion as pale blue.
Blending the legend chip the same way keeps the key matched to what's actually
on screen, which means blending it over the SAME ground the renderers cleared
to rather than over an assumed white.
// type signature
(color: string, a: number, ground: string) => stringcarriedSyntenySettings
What a view holding SyntenyColorsMixin hands the view it opens on the same
alignments: the color it paints by, which a view on its default scheme
leaves to the new view's own, the pinned track colors, the unlabelled
filter and the length filter. Opacity stays each view's own default, since a
linear ribbon, a dotplot point and a circle's ribbon draw at densities of
their own.
// type signature
(view: SyntenyColorsModel) => { trackColors: IKeyValueMap<string>; hideUnlabelled: boolean; minAlignmentLength: number; color?: ModelSnapshotType<Record<string, any>> | undefined; }colorByMenuItems
The color-by menu shared by the dotplot and linear-synteny palette buttons and the multi-way synteny track's Color by...: the structural modes the surface paints, the measurements one hop in, the text-column rows while one is painting, and the per-track swatches once more than one track overlays.
// type signature
(target: ColorByMenuTarget) => MenuItem[]colorByMenuTargetFor
Project a view carrying TrackColorsMixin onto the menu builder's input.
track is offered once two tracks overlay, and reference where the view
says it has a reference to anchor on.
// type signature
(model: TrackColorsModel) => ColorByMenuTargetcolorByScales
The active mode's key as color scales — what a view's colorScales lists,
and so what ChromeLegend and SvgLegend draw. A ramp keeps its own end
labels (identity's 0% and 100%, dN/dS's ≥2) through format, and is
followed by a no-value row once a row carried no value; chips are blended
over the band's ground by the view's alpha, so the key matches the
on-screen composited ribbon colors, subject to legendChipColor's
legibility floor; a mode with no fixed key (a color per sequence name) is a
note row saying so. A threshold keys its bins as chips. title is
color.title as written: unset keeps the field's own heading, '' draws
none.
// type signature
(field: string, { alpha, title, ...opts }?: { pointBased?: boolean | undefined; cigarOps?: number | undefined; trackChips?: ColorChip[] | undefined; attributeRanges?: Record<string, AttributeRange> | undefined; hideUnlabelled?: boolean | undefined; missingColor?: string | undefined; labels?: readonly string[] | undefined; descending?: boolean | undefined; paint?: SyntenyColorPaint | undefined; } & { alpha?: number | undefined; title?: string | undefined; }) => ColorScale[]ColorBySelector
The palette button both comparative headers render, over the view's
TrackColorsMixin: what the view draws and whether it has a reference to
anchor on are the view's own hooks, so the button takes nothing else.
// type signature
({ model, }: { model: TrackColorsModel; }) => ElementcolorByShortLabel
Short human-readable title for the floating legend header: a measurement's preset title, and a column's own name, which is the point of it — the reader named it.
// type signature
(field: string) => stringComparativeTrackModel
The slice of a track model a comparative view reads off its track list.
Annotated at every site that walks a synteny view's levels[].tracks or a
dotplot's tracks, because those arrays type out as any: the level model is
deliberately IAnyModelType to break a real type cycle, and any propagates
through the array and switches off checking on everything read from it. The
any let getConf(t.configuration, ...) compile where getConf wants the
MODEL, and the call threw at runtime reading
configuration.configuration.adapter. With this interface the compiler checks
those calls again.
createOpacityFunction
Each feature's fade, 0 to 1, as a share of opacityLevel; undefined while
opacity draws its constant. A feature with no value for the field draws
at the level.
viewRanges is the domain a number column fades across, the view's
accumulated one as the color ramp's is, and fetchRanges the fetch's own,
whose label lists a text column's values index.
// type signature
({ setting, attributes, viewRanges, fetchRanges, }: { setting: SyntenyOpacitySnapshot; attributes: Record<string, Float32Array<ArrayBufferLike>>; viewRanges: Record<string, AttributeRange>; fetchRanges: Record<string, AttributeRange>; }) => ((index: number) => number) | undefinedfeatureColorInputs
The lanes createComparativeColorFunction reads, built from features a
display holds on the main thread rather than from a worker's payload. ends
answers a feature's two refNames in the order the color modes read them:
query paints by the first and target by the second.
// type signature
(features: readonly Feature[], ends: (feature: Feature) => readonly [string, string], channelNames: readonly string[]) => ColorFunctionInputsidentityFadeMenuItem
The Identity fade toggle of a view carrying SyntenyViewMixin: opacity
read from identity, or back to the constant.
// type signature
(model: { opacityField: string; setOpacityField: (field: string) => void; }) => MenuItemisMeasureField
Whether field is a preset measurement. An own-property lookup: a field
spelled toString is a column nobody declared, not Object's method.
// type signature
(field: string) => field is "dnds" | "identity" | "mapq" | "syntenicDepth"LEGEND_CHIP_ALPHA_FLOOR
The alpha a legend chip is blended at however faint the ribbons are.
Matching the chip to the composited ribbon is right down to a point and then inverts: the linear-synteny default alpha is 0.25, and at that value every chip washes to within a few percent of white, so a key meant to say "blue is this track, orange is that one" identifies nothing. Below the floor the chip gives up exactness for the one job it has. The ribbons themselves still draw at the real alpha.
// type signature
0.45legendChipColor
blendOverGround for a legend chip, floored at LEGEND_CHIP_ALPHA_FLOOR.
// type signature
(color: string, alpha: number, ground: string) => stringLIFTED_DISPLAY_KEYS
The display keys liftSyntenyViewSettings moves onto the view, by display
type, for a validator reading a v4.3.0 session.
// type signature
Record<string, readonly string[]>LIFTED_VIEW_KEYS
The view keys liftSyntenyViewSettings converts, which the two views name
as their launch keys' passThrough so a validator accepts them.
// type signature
readonly ["colorBy", "alpha"]liftSyntenyViewSettings
A linear synteny or dotplot view snapshot's v4.3.0 settings, lifted onto the
view: colorBy (a mode string), alpha and minAlignmentLength sat on each
synteny display, colorBy lands as color and alpha as opacity.
Launch links the genomes portal handed out carry the mode string on the
view itself, which lifts the same way.
// type signature
(snap: Snap | undefined) => Snap | undefinedminLengthMenuItem
The Min length row of a view carrying SyntenyViewMixin.
// type signature
(model: { minAlignmentLength: number; setMinAlignmentLength: (value: number) => void; }) => MenuItemnameColorCss
One name's chromosome-painting color, resolved against an assembly's refName list and handed back as CSS — what a Canvas2D overlay needs, where the renderers want packed ABGR.
The single-name form of the LUT above, because a second reader has turned up that is not painting features: the off-screen mate marks stand for alignments to a contig the facing row is not showing, and a mark colored like the ribbons to that contig is what says a ribbon did not vanish, it moved. Two palettes would put a mark and its ribbons in different colors, which is exactly the drift this module exists to prevent — see the header.
// type signature
(refName: string, namePosition: RefNamePosition | undefined) => stringopacityFadeOf
The part of opacity the color pass reads: undefined for the constant,
else the mapping with range as shares of its most opaque entry, so a
mapping scaled alike at both ends answers the same.
// type signature
(setting: SyntenyOpacitySnapshot) => SyntenyOpacitySnapshot | undefinedopacityLevel
The opacity every alignment is drawn at before its own fade: the constant,
defaultValue while it is unset, or under a field the most opaque value
its range reaches.
// type signature
(setting: SyntenyOpacitySnapshot, defaultValue: number, ranges?: Record<string, AttributeRange> | undefined) => numberopacityMenuItem
The Opacity row of a view carrying SyntenyViewMixin, reset to that view's
own default. Under a field it moves the field's most opaque end.
// type signature
(model: { opacityLevel: number; defaultOpacity: number; setOpacity: (value: number) => void; colorSurface: () => SyntenyColorSurface; }) => MenuItemopacityRangeAt
range rescaled so the mapping's most opaque end lands on value,
keeping each entry's share of it. A threshold or a text column with no
range written draws every bin at the level, so it gets one value per bin
rather than the number column's default fade.
// type signature
(setting: SyntenyOpacitySnapshot, value: number, ranges?: Record<string, AttributeRange> | undefined) => string[]paintedField
The field a synteny color object paints by, or '' while it paints its
constant: scale: 'none', or no field named. Read through the one resolver
every display's color object goes through.
// type signature
({ value, scale, field, domain, }: SyntenyColorSnapshot) => stringrefNamePositionFor
The RefNamePosition a chromosome-painting field hands its palette out by:
query reads the first of the alignment's two assemblies, target the
second. Undefined for any other field, and while that assembly loads.
// type signature
(field: string, [queryAssembly, targetAssembly]: readonly (string | undefined)[], assemblyManager: { get: (name: string) => { getRefNamePosition: RefNamePosition; } | undefined; }) => RefNamePosition | undefinedresolveNumericMode
How a numeric field paints under paint: a preset measurement through its
preset, and a column a track declares on a viridis ramp over the span seen,
labelled with the actual numbers, the honest reading when nothing declares
what the column's range is supposed to be. A written scale names a ramp
or a threshold's bins either way. Undefined for the constant, a structural
field and a text column.
// type signature
(field: string, ranges?: Record<string, AttributeRange>, paint?: SyntenyColorPaint) => NumericMode | undefinedstrandLevels
Each strand's color under paint, forward then reverse: the universal
strand preset's, or range's in domain order where the color object
writes them, and the name labels gives it, if any.
// type signature
({ domain, range }: SyntenyColorPaint, labels?: readonly string[]) => { value: "-1" | "1"; color: string; label: string | undefined; }[]SYNTENY_FIELD_PRESETS
The fields every comparative view paints through a preset: core's
measurements, so identity and mapq paint here as they do on the MAF and
alignments displays.
// type signature
{ readonly mapq: {…}; readonly identity: {…}; readonly dnds: { readonly scale: "linear"; readonly domainMin: 0; readonly domainMax: 2; readonly domainMid: 1; readonly scheme: "blueyellowred"; readonly title: "dN/dS"; }; readonly syntenicDepth: { readonly scale: "threshold"; readonly domain: readonly ["2", "3"]; readonly range: readonly ["#bdbdbd", "#fdae6b", "#e6550d"]; readonly labels: readonly ["One-to-one", "Shared by 2 genes", "Shared by 3 or more"]; readonly title: "Syntenic depth"; }; }syntenyColorFor
The color object that paints by field, written over current: display-kit's
colorForField, the rule every display's Color by pick writes by.
// type signature
(field: string, current: SyntenyColorSnapshot) => SyntenyColorSnapshotRelated links
- Developer guide: Dependencies and re-exports