@jbrowse/plugin-alignments 2.16.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +1 -2
  2. package/dist/AlignmentsFeatureDetail/getSAFeatures.js +2 -2
  3. package/dist/AlignmentsFeatureDetail/stateModelFactory.d.ts +1 -1
  4. package/dist/BamAdapter/BamAdapter.d.ts +3 -2
  5. package/dist/BamAdapter/BamAdapter.js +34 -11
  6. package/dist/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -17
  7. package/dist/BamAdapter/BamSlightlyLazyFeature.js +42 -72
  8. package/dist/CramAdapter/CramAdapter.d.ts +4 -3
  9. package/dist/CramAdapter/CramAdapter.js +24 -7
  10. package/dist/CramAdapter/CramSlightlyLazyFeature.d.ts +21 -27
  11. package/dist/CramAdapter/CramSlightlyLazyFeature.js +74 -73
  12. package/dist/CramAdapter/util.d.ts +1 -10
  13. package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +1 -1
  14. package/dist/LinearAlignmentsDisplay/index.js +2 -2
  15. package/dist/LinearAlignmentsDisplay/{models/model.d.ts → model.d.ts} +6 -3
  16. package/dist/LinearAlignmentsDisplay/{models/model.js → model.js} +11 -7
  17. package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +6 -27
  18. package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +43 -21
  19. package/dist/LinearPileupDisplay/components/ColorByTagDialog.d.ts +5 -4
  20. package/dist/LinearPileupDisplay/components/ColorByTagDialog.js +3 -1
  21. package/dist/LinearPileupDisplay/components/GroupByDialog.js +8 -6
  22. package/dist/LinearPileupDisplay/components/SortByTagDialog.js +6 -4
  23. package/dist/LinearPileupDisplay/model.d.ts +40 -40
  24. package/dist/LinearPileupDisplay/model.js +118 -41
  25. package/dist/LinearReadArcsDisplay/components/ReactComponent.js +1 -1
  26. package/dist/LinearReadArcsDisplay/model.d.ts +22 -21
  27. package/dist/LinearReadArcsDisplay/model.js +13 -14
  28. package/dist/LinearReadCloudDisplay/components/ReactComponent.js +1 -1
  29. package/dist/LinearReadCloudDisplay/model.d.ts +14 -22
  30. package/dist/LinearReadCloudDisplay/model.js +12 -13
  31. package/dist/LinearSNPCoverageDisplay/components/Tooltip.js +49 -19
  32. package/dist/LinearSNPCoverageDisplay/index.js +3 -2
  33. package/dist/LinearSNPCoverageDisplay/{models/model.d.ts → model.d.ts} +3 -13
  34. package/dist/LinearSNPCoverageDisplay/{models/model.js → model.js} +71 -45
  35. package/dist/MismatchParser/cigarToMismatches.d.ts +3 -0
  36. package/dist/MismatchParser/cigarToMismatches.js +94 -0
  37. package/dist/MismatchParser/getNextRefPos.d.ts +4 -0
  38. package/dist/MismatchParser/getNextRefPos.js +40 -0
  39. package/dist/MismatchParser/index.d.ts +4 -29
  40. package/dist/MismatchParser/index.js +10 -327
  41. package/dist/MismatchParser/mdToMismatches.d.ts +3 -0
  42. package/dist/MismatchParser/mdToMismatches.js +80 -0
  43. package/dist/ModificationParser/index.d.ts +19 -0
  44. package/dist/ModificationParser/index.js +144 -0
  45. package/dist/PileupRPC/methods/GetGlobalValueForTag.js +1 -2
  46. package/dist/PileupRPC/methods/GetReducedFeatures.d.ts +1 -1
  47. package/dist/PileupRPC/methods/GetReducedFeatures.js +19 -16
  48. package/dist/PileupRPC/methods/GetVisibleModifications.d.ts +2 -1
  49. package/dist/PileupRPC/methods/GetVisibleModifications.js +9 -6
  50. package/dist/PileupRenderer/PileupLayoutSession.d.ts +8 -7
  51. package/dist/PileupRenderer/PileupRenderer.d.ts +6 -14
  52. package/dist/PileupRenderer/PileupRenderer.js +7 -5
  53. package/dist/PileupRenderer/renderAlignment.js +17 -4
  54. package/dist/PileupRenderer/renderAlignmentShape.js +102 -21
  55. package/dist/PileupRenderer/renderMethylation.d.ts +2 -1
  56. package/dist/PileupRenderer/renderMethylation.js +17 -9
  57. package/dist/PileupRenderer/renderMismatches.js +19 -19
  58. package/dist/PileupRenderer/renderModifications.d.ts +3 -2
  59. package/dist/PileupRenderer/renderModifications.js +31 -34
  60. package/dist/PileupRenderer/renderPerBaseLettering.d.ts +2 -1
  61. package/dist/PileupRenderer/renderPerBaseLettering.js +1 -3
  62. package/dist/PileupRenderer/renderPerBaseQuality.d.ts +2 -1
  63. package/dist/PileupRenderer/renderPerBaseQuality.js +1 -3
  64. package/dist/PileupRenderer/renderSoftClipping.js +6 -6
  65. package/dist/PileupRenderer/sortUtil.d.ts +2 -7
  66. package/dist/PileupRenderer/sortUtil.js +13 -13
  67. package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +10 -5
  68. package/dist/SNPCoverageAdapter/generateCoverageBins.d.ts +13 -9
  69. package/dist/SNPCoverageAdapter/generateCoverageBins.js +269 -166
  70. package/dist/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +2 -1
  71. package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js +171 -54
  72. package/dist/shared/color.d.ts +0 -10
  73. package/dist/shared/color.js +1 -7
  74. package/{esm/shared → dist/shared/components}/BaseDisplayComponent.d.ts +2 -2
  75. package/{esm/shared → dist/shared/components}/FilterByTagDialog.d.ts +3 -3
  76. package/dist/shared/{FilterByTagDialog.js → components/FilterByTagDialog.js} +5 -1
  77. package/dist/shared/fetchChains.js +1 -2
  78. package/dist/shared/getMaximumModificationAtEachPosition.d.ts +8 -0
  79. package/dist/shared/getMaximumModificationAtEachPosition.js +42 -0
  80. package/dist/shared/getUniqueModifications.d.ts +14 -0
  81. package/dist/shared/getUniqueModifications.js +16 -0
  82. package/dist/shared/getUniqueTags.d.ts +15 -0
  83. package/dist/shared/getUniqueTags.js +18 -0
  84. package/dist/shared/types.d.ts +94 -0
  85. package/dist/shared/util.d.ts +8 -0
  86. package/dist/shared/util.js +26 -0
  87. package/dist/util.d.ts +6 -3
  88. package/dist/util.js +24 -29
  89. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +1 -2
  90. package/esm/AlignmentsFeatureDetail/getSAFeatures.js +2 -2
  91. package/esm/AlignmentsFeatureDetail/stateModelFactory.d.ts +1 -1
  92. package/esm/BamAdapter/BamAdapter.d.ts +3 -2
  93. package/esm/BamAdapter/BamAdapter.js +31 -8
  94. package/esm/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -17
  95. package/esm/BamAdapter/BamSlightlyLazyFeature.js +43 -73
  96. package/esm/CramAdapter/CramAdapter.d.ts +4 -3
  97. package/esm/CramAdapter/CramAdapter.js +22 -5
  98. package/esm/CramAdapter/CramSlightlyLazyFeature.d.ts +21 -27
  99. package/esm/CramAdapter/CramSlightlyLazyFeature.js +74 -73
  100. package/esm/CramAdapter/util.d.ts +1 -10
  101. package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +1 -1
  102. package/esm/LinearAlignmentsDisplay/index.js +2 -2
  103. package/esm/LinearAlignmentsDisplay/{models/model.d.ts → model.d.ts} +6 -3
  104. package/esm/LinearAlignmentsDisplay/{models/model.js → model.js} +11 -7
  105. package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +6 -27
  106. package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +45 -23
  107. package/esm/LinearPileupDisplay/components/ColorByTagDialog.d.ts +5 -4
  108. package/esm/LinearPileupDisplay/components/ColorByTagDialog.js +3 -1
  109. package/esm/LinearPileupDisplay/components/GroupByDialog.js +8 -6
  110. package/esm/LinearPileupDisplay/components/SortByTagDialog.js +6 -4
  111. package/esm/LinearPileupDisplay/model.d.ts +40 -40
  112. package/esm/LinearPileupDisplay/model.js +119 -42
  113. package/esm/LinearReadArcsDisplay/components/ReactComponent.js +1 -1
  114. package/esm/LinearReadArcsDisplay/model.d.ts +22 -21
  115. package/esm/LinearReadArcsDisplay/model.js +14 -15
  116. package/esm/LinearReadCloudDisplay/components/ReactComponent.js +1 -1
  117. package/esm/LinearReadCloudDisplay/model.d.ts +14 -22
  118. package/esm/LinearReadCloudDisplay/model.js +13 -14
  119. package/esm/LinearSNPCoverageDisplay/components/Tooltip.js +49 -19
  120. package/esm/LinearSNPCoverageDisplay/index.js +3 -2
  121. package/esm/LinearSNPCoverageDisplay/{models/model.d.ts → model.d.ts} +3 -13
  122. package/esm/LinearSNPCoverageDisplay/{models/model.js → model.js} +72 -46
  123. package/esm/MismatchParser/cigarToMismatches.d.ts +3 -0
  124. package/esm/MismatchParser/cigarToMismatches.js +91 -0
  125. package/esm/MismatchParser/getNextRefPos.d.ts +4 -0
  126. package/esm/MismatchParser/getNextRefPos.js +37 -0
  127. package/esm/MismatchParser/index.d.ts +4 -29
  128. package/esm/MismatchParser/index.js +5 -317
  129. package/esm/MismatchParser/mdToMismatches.d.ts +3 -0
  130. package/esm/MismatchParser/mdToMismatches.js +77 -0
  131. package/esm/ModificationParser/index.d.ts +19 -0
  132. package/esm/ModificationParser/index.js +138 -0
  133. package/esm/PileupRPC/methods/GetGlobalValueForTag.js +1 -2
  134. package/esm/PileupRPC/methods/GetReducedFeatures.d.ts +1 -1
  135. package/esm/PileupRPC/methods/GetReducedFeatures.js +19 -16
  136. package/esm/PileupRPC/methods/GetVisibleModifications.d.ts +2 -1
  137. package/esm/PileupRPC/methods/GetVisibleModifications.js +9 -6
  138. package/esm/PileupRenderer/PileupLayoutSession.d.ts +8 -7
  139. package/esm/PileupRenderer/PileupRenderer.d.ts +6 -14
  140. package/esm/PileupRenderer/PileupRenderer.js +8 -6
  141. package/esm/PileupRenderer/renderAlignment.js +17 -4
  142. package/esm/PileupRenderer/renderAlignmentShape.js +102 -21
  143. package/esm/PileupRenderer/renderMethylation.d.ts +2 -1
  144. package/esm/PileupRenderer/renderMethylation.js +17 -9
  145. package/esm/PileupRenderer/renderMismatches.js +19 -19
  146. package/esm/PileupRenderer/renderModifications.d.ts +3 -2
  147. package/esm/PileupRenderer/renderModifications.js +30 -33
  148. package/esm/PileupRenderer/renderPerBaseLettering.d.ts +2 -1
  149. package/esm/PileupRenderer/renderPerBaseLettering.js +1 -3
  150. package/esm/PileupRenderer/renderPerBaseQuality.d.ts +2 -1
  151. package/esm/PileupRenderer/renderPerBaseQuality.js +1 -3
  152. package/esm/PileupRenderer/renderSoftClipping.js +6 -6
  153. package/esm/PileupRenderer/sortUtil.d.ts +2 -7
  154. package/esm/PileupRenderer/sortUtil.js +13 -13
  155. package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js +10 -5
  156. package/esm/SNPCoverageAdapter/generateCoverageBins.d.ts +13 -9
  157. package/esm/SNPCoverageAdapter/generateCoverageBins.js +269 -166
  158. package/esm/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +2 -1
  159. package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js +171 -54
  160. package/esm/shared/color.d.ts +0 -10
  161. package/esm/shared/color.js +0 -6
  162. package/{dist/shared → esm/shared/components}/BaseDisplayComponent.d.ts +2 -2
  163. package/{dist/shared → esm/shared/components}/FilterByTagDialog.d.ts +3 -3
  164. package/esm/shared/{FilterByTagDialog.js → components/FilterByTagDialog.js} +5 -1
  165. package/esm/shared/fetchChains.js +1 -2
  166. package/esm/shared/getMaximumModificationAtEachPosition.d.ts +8 -0
  167. package/esm/shared/getMaximumModificationAtEachPosition.js +39 -0
  168. package/esm/shared/getUniqueModifications.d.ts +14 -0
  169. package/esm/shared/getUniqueModifications.js +13 -0
  170. package/esm/shared/getUniqueTags.d.ts +15 -0
  171. package/esm/shared/getUniqueTags.js +15 -0
  172. package/esm/shared/types.d.ts +94 -0
  173. package/esm/shared/util.d.ts +8 -0
  174. package/esm/shared/util.js +23 -0
  175. package/esm/util.d.ts +6 -3
  176. package/esm/util.js +22 -26
  177. package/package.json +4 -4
  178. package/dist/LinearPileupDisplay/components/ColorByModificationsDialog.d.ts +0 -15
  179. package/dist/LinearPileupDisplay/components/ColorByModificationsDialog.js +0 -41
  180. package/dist/LinearPileupDisplay/components/ModificationsTable.d.ts +0 -4
  181. package/dist/LinearPileupDisplay/components/ModificationsTable.js +0 -28
  182. package/dist/SNPCoverageAdapter/util.d.ts +0 -25
  183. package/dist/shared/index.d.ts +0 -49
  184. package/dist/shared/index.js +0 -41
  185. package/esm/LinearPileupDisplay/components/ColorByModificationsDialog.d.ts +0 -15
  186. package/esm/LinearPileupDisplay/components/ColorByModificationsDialog.js +0 -36
  187. package/esm/LinearPileupDisplay/components/ModificationsTable.d.ts +0 -4
  188. package/esm/LinearPileupDisplay/components/ModificationsTable.js +0 -22
  189. package/esm/SNPCoverageAdapter/util.d.ts +0 -25
  190. package/esm/shared/index.d.ts +0 -49
  191. package/esm/shared/index.js +0 -36
  192. /package/dist/LinearAlignmentsDisplay/{models/alignmentsModel.d.ts → alignmentsModel.d.ts} +0 -0
  193. /package/dist/LinearAlignmentsDisplay/{models/alignmentsModel.js → alignmentsModel.js} +0 -0
  194. /package/dist/LinearAlignmentsDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  195. /package/dist/LinearAlignmentsDisplay/{models/configSchema.js → configSchema.js} +0 -0
  196. /package/dist/LinearAlignmentsDisplay/{models/util.d.ts → util.d.ts} +0 -0
  197. /package/dist/LinearAlignmentsDisplay/{models/util.js → util.js} +0 -0
  198. /package/dist/LinearSNPCoverageDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  199. /package/dist/LinearSNPCoverageDisplay/{models/configSchema.js → configSchema.js} +0 -0
  200. /package/dist/shared/{BaseDisplayComponent.js → components/BaseDisplayComponent.js} +0 -0
  201. /package/dist/shared/{renderSvg.d.ts → renderSvgUtil.d.ts} +0 -0
  202. /package/dist/shared/{renderSvg.js → renderSvgUtil.js} +0 -0
  203. /package/dist/{SNPCoverageAdapter/util.js → shared/types.js} +0 -0
  204. /package/esm/LinearAlignmentsDisplay/{models/alignmentsModel.d.ts → alignmentsModel.d.ts} +0 -0
  205. /package/esm/LinearAlignmentsDisplay/{models/alignmentsModel.js → alignmentsModel.js} +0 -0
  206. /package/esm/LinearAlignmentsDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  207. /package/esm/LinearAlignmentsDisplay/{models/configSchema.js → configSchema.js} +0 -0
  208. /package/esm/LinearAlignmentsDisplay/{models/util.d.ts → util.d.ts} +0 -0
  209. /package/esm/LinearAlignmentsDisplay/{models/util.js → util.js} +0 -0
  210. /package/esm/LinearSNPCoverageDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  211. /package/esm/LinearSNPCoverageDisplay/{models/configSchema.js → configSchema.js} +0 -0
  212. /package/esm/shared/{BaseDisplayComponent.js → components/BaseDisplayComponent.js} +0 -0
  213. /package/esm/shared/{renderSvg.d.ts → renderSvgUtil.d.ts} +0 -0
  214. /package/esm/shared/{renderSvg.js → renderSvgUtil.js} +0 -0
  215. /package/esm/{SNPCoverageAdapter/util.js → shared/types.js} +0 -0
@@ -1,45 +1,42 @@
1
- import { bpSpanPx } from '@jbrowse/core/util';
2
- import { getModificationPositions, getModificationProbabilities, getNextRefPos, parseCigar, } from '../MismatchParser';
3
- import { getTagAlt } from '../util';
1
+ import { bpSpanPx, max, sum } from '@jbrowse/core/util';
2
+ // locals
4
3
  import { fillRect } from './util';
5
- import { colord } from '@jbrowse/core/util/colord';
4
+ import { alphaColor } from '../shared/util';
5
+ import { getMaxProbModAtEachPosition } from '../shared/getMaximumModificationAtEachPosition';
6
6
  // render modifications stored in MM tag in BAM
7
- //
8
- // ML stores probabilities as array of numerics and MP is scaled phred scores
9
- // https://github.com/samtools/hts-specs/pull/418/files#diff-e765c6479316309f56b636f88189cdde8c40b854c7bdcce9ee7fe87a4e76febcR596
10
- //
11
- // if we have ML or Ml, it is an 8bit probability, divide by 255
12
- //
13
- // if we have MP or Mp it is phred scaled ASCII, which can go up to 90 but
14
- // has very high likelihood basecalls at that point, we really only care
15
- // about low qual calls <20 approx
16
- export function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }) {
7
+ export function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }) {
8
+ var _a, _b, _c;
17
9
  const { feature, topPx, heightPx } = feat;
18
- const { modificationTagMap = {} } = renderArgs;
10
+ const { colorBy, visibleModifications = {} } = renderArgs;
19
11
  const seq = feature.get('seq');
20
12
  if (!seq) {
21
13
  return;
22
14
  }
23
- const mm = getTagAlt(feature, 'MM', 'Mm') || '';
24
- const cigar = feature.get('CIGAR');
25
15
  const start = feature.get('start');
26
- const strand = feature.get('strand');
27
- const cigarOps = parseCigar(cigar);
28
- const probabilities = getModificationProbabilities(feature);
29
- const modifications = getModificationPositions(mm, seq, strand);
30
- // probIndex applies across multiple modifications e.g.
31
- let probIndex = 0;
32
- for (const { type, positions } of modifications) {
33
- const col = modificationTagMap[type] || 'black';
34
- const base = colord(col);
35
- for (const readPos of getNextRefPos(cigarOps, positions)) {
36
- const r = start + readPos;
37
- const [leftPx, rightPx] = bpSpanPx(r, r + 1, region, bpPerPx);
38
- const prob = (probabilities === null || probabilities === void 0 ? void 0 : probabilities[probIndex]) || 0;
39
- const c = prob !== 1 ? base.alpha(prob + 0.1).toHslString() : col;
16
+ const isolatedModification = (_a = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _a === void 0 ? void 0 : _a.isolatedModification;
17
+ const twoColor = (_b = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _b === void 0 ? void 0 : _b.twoColor;
18
+ (_c = getMaxProbModAtEachPosition(feature, cigarOps)) === null || _c === void 0 ? void 0 : _c.forEach(({ allProbs, prob, type }, pos) => {
19
+ const r = start + pos;
20
+ const [leftPx, rightPx] = bpSpanPx(r, r + 1, region, bpPerPx);
21
+ const mod = visibleModifications[type];
22
+ if (!mod) {
23
+ console.warn(`${type} not known yet`);
24
+ return;
25
+ }
26
+ if (isolatedModification && mod.type !== isolatedModification) {
27
+ return;
28
+ }
29
+ const col = mod.color || 'black';
30
+ const s = 1 - sum(allProbs);
31
+ if (twoColor && s > max(allProbs)) {
32
+ const c = alphaColor('blue', s);
40
33
  const w = rightPx - leftPx + 0.5;
41
34
  fillRect(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
42
- probIndex++;
43
35
  }
44
- }
36
+ else {
37
+ const c = alphaColor(col, prob);
38
+ const w = rightPx - leftPx + 0.5;
39
+ fillRect(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
40
+ }
41
+ });
45
42
  }
@@ -1,6 +1,6 @@
1
1
  import { Region } from '@jbrowse/core/util';
2
2
  import { LayoutFeature } from './util';
3
- export declare function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, }: {
3
+ export declare function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, cigarOps, }: {
4
4
  ctx: CanvasRenderingContext2D;
5
5
  feat: LayoutFeature;
6
6
  region: Region;
@@ -10,4 +10,5 @@ export declare function renderPerBaseLettering({ ctx, feat, region, bpPerPx, col
10
10
  charWidth: number;
11
11
  charHeight: number;
12
12
  canvasWidth: number;
13
+ cigarOps: string[];
13
14
  }): void;
@@ -1,11 +1,9 @@
1
1
  import { bpSpanPx } from '@jbrowse/core/util';
2
- import { parseCigar } from '../MismatchParser';
3
2
  import { fillRect } from './util';
4
- export function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, }) {
3
+ export function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, cigarOps, }) {
5
4
  const heightLim = charHeight - 2;
6
5
  const { feature, topPx, heightPx } = feat;
7
6
  const seq = feature.get('seq');
8
- const cigarOps = parseCigar(feature.get('CIGAR'));
9
7
  const w = 1 / bpPerPx;
10
8
  const start = feature.get('start');
11
9
  let soffset = 0;
@@ -1,9 +1,10 @@
1
1
  import { Region } from '@jbrowse/core/util';
2
2
  import { LayoutFeature } from './util';
3
- export declare function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, }: {
3
+ export declare function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, cigarOps, }: {
4
4
  ctx: CanvasRenderingContext2D;
5
5
  feat: LayoutFeature;
6
6
  region: Region;
7
7
  bpPerPx: number;
8
8
  canvasWidth: number;
9
+ cigarOps: string[];
9
10
  }): void;
@@ -1,11 +1,9 @@
1
1
  import { bpSpanPx } from '@jbrowse/core/util';
2
- import { parseCigar } from '../MismatchParser';
3
2
  import { fillRect } from './util';
4
- export function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, }) {
3
+ export function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, cigarOps, }) {
5
4
  const { feature, topPx, heightPx } = feat;
6
5
  const qual = feature.get('qual') || '';
7
6
  const scores = qual.split(' ').map(val => +val);
8
- const cigarOps = parseCigar(feature.get('CIGAR'));
9
7
  const w = 1 / bpPerPx;
10
8
  const start = feature.get('start');
11
9
  let soffset = 0; // sequence offset
@@ -1,8 +1,7 @@
1
1
  import { readConfObject, } from '@jbrowse/core/configuration';
2
2
  import { bpSpanPx } from '@jbrowse/core/util';
3
- // locals
4
- import { parseCigar } from '../MismatchParser';
5
3
  import { fillRect, getCharWidthHeight } from './util';
4
+ import { parseCigar } from '../MismatchParser';
6
5
  export function renderSoftClipping({ ctx, feat, renderArgs, config, theme, colorForBase, canvasWidth, }) {
7
6
  const { feature, topPx, heightPx } = feat;
8
7
  const { regions, bpPerPx } = renderArgs;
@@ -16,12 +15,13 @@ export function renderSoftClipping({ ctx, feat, renderArgs, config, theme, color
16
15
  return;
17
16
  }
18
17
  const heightLim = charHeight - 2;
19
- const CIGAR = parseCigar(feature.get('CIGAR'));
20
18
  let seqOffset = 0;
21
19
  let refOffset = 0;
22
- for (let i = 0; i < CIGAR.length; i += 2) {
23
- const op = CIGAR[i + 1];
24
- const len = +CIGAR[i];
20
+ const CIGAR = feature.get('CIGAR');
21
+ const cigarOps = parseCigar(CIGAR);
22
+ for (let i = 0; i < cigarOps.length; i += 2) {
23
+ const op = cigarOps[i + 1];
24
+ const len = +cigarOps[i];
25
25
  if (op === 'S') {
26
26
  for (let k = 0; k < len; k++) {
27
27
  const base = seq[seqOffset + k];
@@ -1,8 +1,3 @@
1
1
  import { Feature } from '@jbrowse/core/util';
2
- interface SortObject {
3
- pos: number;
4
- type: string;
5
- tag?: string;
6
- }
7
- export declare const sortFeature: (features: Map<string, Feature>, sortedBy: SortObject) => Map<string, Feature>;
8
- export {};
2
+ import { SortedBy } from '../shared/types';
3
+ export declare const sortFeature: (features: Map<string, Feature>, sortedBy: SortedBy) => Map<string, Feature>;
@@ -40,29 +40,29 @@ export const sortFeature = (features, sortedBy) => {
40
40
  // first sort all mismatches, then all reference bases at the end
41
41
  case 'Base pair': {
42
42
  const baseSortArray = [];
43
- featuresInCenterLine.forEach(feature => {
43
+ for (const feature of featuresInCenterLine) {
44
44
  const mismatches = feature.get('mismatches');
45
- mismatches.forEach(mismatch => {
45
+ for (const m of mismatches) {
46
46
  const start = feature.get('start');
47
- const offset = start + mismatch.start + 1;
48
- const consuming = mismatch.type === 'insertion' || mismatch.type === 'softclip';
49
- const len = consuming ? 0 : mismatch.length;
47
+ const offset = start + m.start + 1;
48
+ const consuming = m.type === 'insertion' || m.type === 'softclip';
49
+ const len = consuming ? 0 : m.length;
50
50
  if (pos >= offset && pos < offset + len) {
51
- baseSortArray.push([feature.id(), mismatch]);
51
+ baseSortArray.push([feature.id(), m]);
52
52
  }
53
- });
54
- });
53
+ }
54
+ }
55
55
  const baseMap = new Map(baseSortArray);
56
56
  featuresInCenterLine.sort((a, b) => {
57
57
  const aMismatch = baseMap.get(a.id());
58
58
  const bMismatch = baseMap.get(b.id());
59
59
  const acode = bMismatch === null || bMismatch === void 0 ? void 0 : bMismatch.base.toUpperCase();
60
60
  const bcode = aMismatch === null || aMismatch === void 0 ? void 0 : aMismatch.base.toUpperCase();
61
- if (acode === bcode && acode === '*') {
62
- // @ts-expect-error
63
- return aMismatch.length - bMismatch.length;
64
- }
65
- return ((acode ? acode.charCodeAt(0) : 0) - (bcode ? bcode.charCodeAt(0) : 0));
61
+ return acode === bcode && acode === '*'
62
+ ? // @ts-expect-error
63
+ aMismatch.length - bMismatch.length
64
+ : (acode ? acode.charCodeAt(0) : 0) -
65
+ (bcode ? bcode.charCodeAt(0) : 0);
66
66
  });
67
67
  break;
68
68
  }
@@ -4,8 +4,8 @@ import { ObservableCreate } from '@jbrowse/core/util/rxjs';
4
4
  import { toArray } from 'rxjs/operators';
5
5
  import { firstValueFrom } from 'rxjs';
6
6
  // locals
7
- import generateCoverageBins from './generateCoverageBins';
8
7
  import { fetchSequence } from '../util';
8
+ import { generateCoverageBins } from './generateCoverageBins';
9
9
  export default class SNPCoverageAdapter extends BaseFeatureDataAdapter {
10
10
  async configure() {
11
11
  var _a, _b;
@@ -33,14 +33,19 @@ export default class SNPCoverageAdapter extends BaseFeatureDataAdapter {
33
33
  getFeatures(region, opts = {}) {
34
34
  return ObservableCreate(async (observer) => {
35
35
  const { subadapter } = await this.configure();
36
- const feats = await firstValueFrom(subadapter.getFeatures(region, opts).pipe(toArray()));
37
- const { bins, skipmap } = await generateCoverageBins(feats, region, opts, arg => this.fetchSequence(arg));
36
+ const features = await firstValueFrom(subadapter.getFeatures(region, opts).pipe(toArray()));
37
+ const { bins, skipmap } = await generateCoverageBins({
38
+ features,
39
+ region,
40
+ opts,
41
+ fetchSequence: (region) => this.fetchSequence(region),
42
+ });
38
43
  bins.forEach((bin, index) => {
39
44
  const start = region.start + index;
40
45
  observer.next(new SimpleFeature({
41
46
  id: `${this.id}-${start}`,
42
47
  data: {
43
- score: bin.total,
48
+ score: bin.depth,
44
49
  snpinfo: bin,
45
50
  start,
46
51
  end: start + 1,
@@ -58,7 +63,7 @@ export default class SNPCoverageAdapter extends BaseFeatureDataAdapter {
58
63
  end: skip.end,
59
64
  strand: skip.strand,
60
65
  score: skip.score,
61
- xs: skip.xs,
66
+ effectiveStrand: skip.effectiveStrand,
62
67
  },
63
68
  }));
64
69
  });
@@ -1,13 +1,17 @@
1
1
  import { AugmentedRegion as Region } from '@jbrowse/core/util/types';
2
- import { Feature } from '@jbrowse/core/util/simpleFeature';
3
- import { Bin, SkipMap } from './util';
4
- export default function generateCoverageBins(features: Feature[], region: Region, opts: {
2
+ import { Feature } from '@jbrowse/core/util';
3
+ import { ColorBy, PreBaseCoverageBin, SkipMap } from '../shared/types';
4
+ interface Opts {
5
5
  bpPerPx?: number;
6
- colorBy?: {
7
- type: string;
8
- tag?: string;
9
- };
10
- }, fetchSequence: (arg: Region) => Promise<string>): Promise<{
11
- bins: Bin[];
6
+ colorBy?: ColorBy;
7
+ }
8
+ export declare function generateCoverageBins({ fetchSequence, features, region, opts, }: {
9
+ features: Feature[];
10
+ region: Region;
11
+ opts: Opts;
12
+ fetchSequence: (arg: Region) => Promise<string>;
13
+ }): Promise<{
14
+ bins: PreBaseCoverageBin[];
12
15
  skipmap: SkipMap;
13
16
  }>;
17
+ export {};