-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathlayoutFeature.test.ts
More file actions
94 lines (84 loc) · 2.37 KB
/
layoutFeature.test.ts
File metadata and controls
94 lines (84 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { PileupLayout } from '@jbrowse/core/util/layouts'
import { getPileupLayoutSpan, layoutFeature } from './layoutFeature.ts'
import type { Mismatch } from '../shared/types.ts'
import type { Feature } from '@jbrowse/core/util'
function makeFeature(
id: string,
start: number,
end: number,
mismatches: Mismatch[],
): Feature {
return {
id: () => id,
get(name: string) {
if (name === 'start') {
return start
}
if (name === 'end') {
return end
}
if (name === 'mismatches') {
return mismatches
}
return undefined
},
} as Feature
}
test('soft clip layout expansion is capped by maxClippingSize', () => {
const layout = new PileupLayout({
featureHeight: 7,
spacing: 0,
maxHeight: 1200,
})
const feature = makeFeature('r1', 100_000, 100_100, [
{ type: 'softclip', start: 0, cliplen: 50_000 },
{ type: 'softclip', start: 99, cliplen: 40_000 },
])
layoutFeature({
feature,
layout,
showSoftClip: true,
heightPx: 7,
displayMode: 'normal',
maxClippingSize: 10_000,
})
const tuple = layout.getRectangles().get('r1')
expect(tuple).toBeDefined()
const [left, , right] = tuple!
expect(left).toBe(90_000)
expect(right).toBe(110_100)
})
test('soft clip sums per side then applies cap', () => {
const layout = new PileupLayout({
featureHeight: 7,
spacing: 0,
maxHeight: 1200,
})
const feature = makeFeature('r1', 1000, 1100, [
{ type: 'softclip', start: 0, cliplen: 3000 },
{ type: 'softclip', start: 0, cliplen: 4000 },
])
layoutFeature({
feature,
layout,
showSoftClip: true,
heightPx: 7,
displayMode: 'normal',
maxClippingSize: 5000,
})
const tuple = layout.getRectangles().get('r1')
expect(tuple).toBeDefined()
const [left, , right] = tuple!
expect(left).toBe(-4000)
expect(right).toBe(1100)
})
test('getPileupLayoutSpan left edge can be left of a read with lower genomic start (#4671)', () => {
const laterStart = makeFeature('a', 5000, 5100, [
{ type: 'softclip', start: 0, cliplen: 6000 },
])
const earlierStart = makeFeature('b', 1000, 2000, [])
const { s: sa } = getPileupLayoutSpan(laterStart, true, 10_000)
const { s: sb } = getPileupLayoutSpan(earlierStart, true, 10_000)
expect(laterStart.get('start')).toBeGreaterThan(earlierStart.get('start'))
expect(sa).toBeLessThan(sb)
})