Skip to content

Commit 34b5fa3

Browse files
committed
Refactorings
1 parent 3e40589 commit 34b5fa3

File tree

8 files changed

+134
-223
lines changed

8 files changed

+134
-223
lines changed

plugins/alignments/src/LinearAlignmentsDisplay/components/WebGLAlignmentsComponent.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import {
2-
TooLargeMessage,
3-
} from '@jbrowse/plugin-linear-genome-view'
1+
import { TooLargeMessage } from '@jbrowse/plugin-linear-genome-view'
42
import { observer } from 'mobx-react'
53

64
import BlockMsg from './BlockMsg.tsx'

plugins/alignments/src/LinearAlignmentsDisplay/components/WebGLChainComponent.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import {
4-
FloatingLegend,
5-
} from '@jbrowse/plugin-linear-genome-view'
3+
import { FloatingLegend } from '@jbrowse/plugin-linear-genome-view'
64
import { observer } from 'mobx-react'
75

86
import { YSCALEBAR_LABEL_OFFSET } from '../model.ts'

plugins/alignments/src/LinearAlignmentsDisplay/components/alignmentComponentUtils.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
import { colord } from '@jbrowse/core/util/colord'
99

10+
import { INTERBASE_TYPES } from './hitTesting.ts'
1011
import { fillColor } from '../../shared/color.ts'
1112

1213
import type { ColorPalette, RGBColor, WebGLRenderer } from './WebGLRenderer'
13-
import { INTERBASE_TYPES } from './hitTesting.ts'
14-
15-
import type { CigarHitResult, IndicatorHitResult, CoverageHitResult, SashimiArcHitResult } from './hitTesting'
14+
import type {
15+
CigarHitResult,
16+
CoverageHitResult,
17+
IndicatorHitResult,
18+
SashimiArcHitResult,
19+
} from './hitTesting'
1620
import type { WebGLPileupDataResult } from '../../RenderWebGLPileupDataRPC/types'
1721
import type { Theme } from '@mui/material'
1822

@@ -252,8 +256,7 @@ export function formatIndicatorTooltip(
252256
blockRpcData: WebGLPileupDataResult | undefined,
253257
refName: string | undefined,
254258
) {
255-
const posOffset =
256-
indicatorHit.position - (blockRpcData?.regionStart ?? 0)
259+
const posOffset = indicatorHit.position - (blockRpcData?.regionStart ?? 0)
257260
const tooltipBin = blockRpcData?.tooltipData[posOffset]
258261

259262
if (tooltipBin) {
@@ -296,8 +299,7 @@ export function formatCoverageTooltip(
296299
blockRpcData: WebGLPileupDataResult | undefined,
297300
refName: string | undefined,
298301
) {
299-
const posOffset =
300-
coverageHit.position - (blockRpcData?.regionStart ?? 0)
302+
const posOffset = coverageHit.position - (blockRpcData?.regionStart ?? 0)
301303
const tooltipBin = blockRpcData?.tooltipData[posOffset]
302304

303305
if (tooltipBin || coverageHit.depth > 0) {
@@ -342,11 +344,7 @@ export function formatCoverageTooltip(
342344

343345
export function formatSashimiTooltip(sashimiHit: SashimiArcHitResult) {
344346
const strandLabel =
345-
sashimiHit.strand === 1
346-
? '+'
347-
: sashimiHit.strand === -1
348-
? '-'
349-
: 'unknown'
347+
sashimiHit.strand === 1 ? '+' : sashimiHit.strand === -1 ? '-' : 'unknown'
350348
return JSON.stringify({
351349
type: 'sashimi',
352350
start: sashimiHit.start,
@@ -359,7 +357,18 @@ export function formatSashimiTooltip(sashimiHit: SashimiArcHitResult) {
359357

360358
export function formatFeatureTooltip(
361359
featureId: string,
362-
getFeatureInfoById: (id: string) => { id: string; name: string; start: number; end: number; strand: string; refName: string } | undefined,
360+
getFeatureInfoById: (
361+
id: string,
362+
) =>
363+
| {
364+
id: string
365+
name: string
366+
start: number
367+
end: number
368+
strand: string
369+
refName: string
370+
}
371+
| undefined,
363372
) {
364373
const info = getFeatureInfoById(featureId)
365374
if (info) {

plugins/alignments/src/LinearAlignmentsDisplay/components/hitTestPipeline.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export type HitTestResult =
2626
featureHit?: { id: string; index: number }
2727
resolved: ResolvedBlock
2828
}
29-
| { type: 'feature'; hit: { id: string; index: number }; resolved: ResolvedBlock }
29+
| {
30+
type: 'feature'
31+
hit: { id: string; index: number }
32+
resolved: ResolvedBlock
33+
}
3034
| { type: 'none' }
3135

3236
interface HitTestOptions {

plugins/alignments/src/LinearAlignmentsDisplay/components/openFeatureWidget.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import {
77

88
import { CIGAR_TYPE_LABELS } from './alignmentComponentUtils.ts'
99

10-
import type { CigarHitResult, IndicatorHitResult, CoverageHitResult } from './hitTesting.ts'
10+
import type {
11+
CigarHitResult,
12+
CoverageHitResult,
13+
IndicatorHitResult,
14+
} from './hitTesting.ts'
1115
import type { WebGLPileupDataResult } from '../../RenderWebGLPileupDataRPC/types.ts'
1216

1317
interface ModelForWidget {
@@ -39,8 +43,7 @@ export function openIndicatorWidget(
3943
refName: string,
4044
blockRpcData: WebGLPileupDataResult | undefined,
4145
) {
42-
const posOffset =
43-
indicatorHit.position - (blockRpcData?.regionStart ?? 0)
46+
const posOffset = indicatorHit.position - (blockRpcData?.regionStart ?? 0)
4447
const tooltipBin = blockRpcData?.tooltipData[posOffset]
4548

4649
const featureData: Record<string, unknown> = {
@@ -53,8 +56,7 @@ export function openIndicatorWidget(
5356
}
5457

5558
if (tooltipBin) {
56-
const interbaseEntry =
57-
tooltipBin.interbase[indicatorHit.indicatorType]
59+
const interbaseEntry = tooltipBin.interbase[indicatorHit.indicatorType]
5860
if (interbaseEntry) {
5961
featureData.count = `${interbaseEntry.count}/${tooltipBin.depth}`
6062
featureData.size =
@@ -68,8 +70,7 @@ export function openIndicatorWidget(
6870
featureData.depth = tooltipBin.depth
6971
} else {
7072
const { counts } = indicatorHit
71-
featureData.count =
72-
counts.insertion + counts.softclip + counts.hardclip
73+
featureData.count = counts.insertion + counts.softclip + counts.hardclip
7374
}
7475

7576
showWidget(model, featureData)
@@ -81,22 +82,15 @@ export function openCoverageWidget(
8182
refName: string,
8283
blockRpcData: WebGLPileupDataResult | undefined,
8384
) {
84-
const posOffset =
85-
coverageHit.position - (blockRpcData?.regionStart ?? 0)
85+
const posOffset = coverageHit.position - (blockRpcData?.regionStart ?? 0)
8686
const tooltipBin = blockRpcData?.tooltipData[posOffset]
8787

8888
const hasSNPs = coverageHit.snps.some(
89-
s =>
90-
s.base === 'A' ||
91-
s.base === 'C' ||
92-
s.base === 'G' ||
93-
s.base === 'T',
89+
s => s.base === 'A' || s.base === 'C' || s.base === 'G' || s.base === 'T',
9490
)
9591
const hasInterbase = coverageHit.snps.some(
9692
s =>
97-
s.base === 'insertion' ||
98-
s.base === 'softclip' ||
99-
s.base === 'hardclip',
93+
s.base === 'insertion' || s.base === 'softclip' || s.base === 'hardclip',
10094
)
10195
if (!hasSNPs && !hasInterbase && !tooltipBin) {
10296
return

plugins/alignments/src/LinearAlignmentsDisplay/components/useAlignmentsBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import {
2626
openIndicatorWidget,
2727
} from './openFeatureWidget.ts'
2828

29-
import type { ResolvedBlock } from './hitTesting.ts'
3029
import type { CloudTicks } from './CloudYScaleBar.tsx'
3130
import type { CoverageTicks } from './CoverageYScaleBar.tsx'
31+
import type { ResolvedBlock } from './hitTesting.ts'
3232
import type { WebGLArcsDataResult } from '../../RenderWebGLArcsDataRPC/types.ts'
3333
import type { WebGLPileupDataResult } from '../../RenderWebGLPileupDataRPC/types.ts'
3434
import type {

0 commit comments

Comments
 (0)