@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
@@ -2,47 +2,44 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderModifications = renderModifications;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const MismatchParser_1 = require("../MismatchParser");
6
- const util_2 = require("../util");
7
- const util_3 = require("./util");
8
- const colord_1 = require("@jbrowse/core/util/colord");
5
+ // locals
6
+ const util_2 = require("./util");
7
+ const util_3 = require("../shared/util");
8
+ const getMaximumModificationAtEachPosition_1 = require("../shared/getMaximumModificationAtEachPosition");
9
9
  // render modifications stored in MM tag in BAM
10
- //
11
- // ML stores probabilities as array of numerics and MP is scaled phred scores
12
- // https://github.com/samtools/hts-specs/pull/418/files#diff-e765c6479316309f56b636f88189cdde8c40b854c7bdcce9ee7fe87a4e76febcR596
13
- //
14
- // if we have ML or Ml, it is an 8bit probability, divide by 255
15
- //
16
- // if we have MP or Mp it is phred scaled ASCII, which can go up to 90 but
17
- // has very high likelihood basecalls at that point, we really only care
18
- // about low qual calls <20 approx
19
- function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }) {
10
+ function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }) {
11
+ var _a, _b, _c;
20
12
  const { feature, topPx, heightPx } = feat;
21
- const { modificationTagMap = {} } = renderArgs;
13
+ const { colorBy, visibleModifications = {} } = renderArgs;
22
14
  const seq = feature.get('seq');
23
15
  if (!seq) {
24
16
  return;
25
17
  }
26
- const mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
27
- const cigar = feature.get('CIGAR');
28
18
  const start = feature.get('start');
29
- const strand = feature.get('strand');
30
- const cigarOps = (0, MismatchParser_1.parseCigar)(cigar);
31
- const probabilities = (0, MismatchParser_1.getModificationProbabilities)(feature);
32
- const modifications = (0, MismatchParser_1.getModificationPositions)(mm, seq, strand);
33
- // probIndex applies across multiple modifications e.g.
34
- let probIndex = 0;
35
- for (const { type, positions } of modifications) {
36
- const col = modificationTagMap[type] || 'black';
37
- const base = (0, colord_1.colord)(col);
38
- for (const readPos of (0, MismatchParser_1.getNextRefPos)(cigarOps, positions)) {
39
- const r = start + readPos;
40
- const [leftPx, rightPx] = (0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx);
41
- const prob = (probabilities === null || probabilities === void 0 ? void 0 : probabilities[probIndex]) || 0;
42
- const c = prob !== 1 ? base.alpha(prob + 0.1).toHslString() : col;
19
+ const isolatedModification = (_a = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _a === void 0 ? void 0 : _a.isolatedModification;
20
+ const twoColor = (_b = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _b === void 0 ? void 0 : _b.twoColor;
21
+ (_c = (0, getMaximumModificationAtEachPosition_1.getMaxProbModAtEachPosition)(feature, cigarOps)) === null || _c === void 0 ? void 0 : _c.forEach(({ allProbs, prob, type }, pos) => {
22
+ const r = start + pos;
23
+ const [leftPx, rightPx] = (0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx);
24
+ const mod = visibleModifications[type];
25
+ if (!mod) {
26
+ console.warn(`${type} not known yet`);
27
+ return;
28
+ }
29
+ if (isolatedModification && mod.type !== isolatedModification) {
30
+ return;
31
+ }
32
+ const col = mod.color || 'black';
33
+ const s = 1 - (0, util_1.sum)(allProbs);
34
+ if (twoColor && s > (0, util_1.max)(allProbs)) {
35
+ const c = (0, util_3.alphaColor)('blue', s);
43
36
  const w = rightPx - leftPx + 0.5;
44
- (0, util_3.fillRect)(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
45
- probIndex++;
37
+ (0, util_2.fillRect)(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
46
38
  }
47
- }
39
+ else {
40
+ const c = (0, util_3.alphaColor)(col, prob);
41
+ const w = rightPx - leftPx + 0.5;
42
+ (0, util_2.fillRect)(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
43
+ }
44
+ });
48
45
  }
@@ -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;
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderPerBaseLettering = renderPerBaseLettering;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const MismatchParser_1 = require("../MismatchParser");
6
5
  const util_2 = require("./util");
7
- function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, }) {
6
+ function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, cigarOps, }) {
8
7
  const heightLim = charHeight - 2;
9
8
  const { feature, topPx, heightPx } = feat;
10
9
  const seq = feature.get('seq');
11
- const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
12
10
  const w = 1 / bpPerPx;
13
11
  const start = feature.get('start');
14
12
  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;
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderPerBaseQuality = renderPerBaseQuality;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const MismatchParser_1 = require("../MismatchParser");
6
5
  const util_2 = require("./util");
7
- function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, }) {
6
+ function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, cigarOps, }) {
8
7
  const { feature, topPx, heightPx } = feat;
9
8
  const qual = feature.get('qual') || '';
10
9
  const scores = qual.split(' ').map(val => +val);
11
- const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
12
10
  const w = 1 / bpPerPx;
13
11
  const start = feature.get('start');
14
12
  let soffset = 0; // sequence offset
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderSoftClipping = renderSoftClipping;
4
4
  const configuration_1 = require("@jbrowse/core/configuration");
5
5
  const util_1 = require("@jbrowse/core/util");
6
- // locals
7
- const MismatchParser_1 = require("../MismatchParser");
8
6
  const util_2 = require("./util");
7
+ const MismatchParser_1 = require("../MismatchParser");
9
8
  function renderSoftClipping({ ctx, feat, renderArgs, config, theme, colorForBase, canvasWidth, }) {
10
9
  const { feature, topPx, heightPx } = feat;
11
10
  const { regions, bpPerPx } = renderArgs;
@@ -19,12 +18,13 @@ function renderSoftClipping({ ctx, feat, renderArgs, config, theme, colorForBase
19
18
  return;
20
19
  }
21
20
  const heightLim = charHeight - 2;
22
- const CIGAR = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
23
21
  let seqOffset = 0;
24
22
  let refOffset = 0;
25
- for (let i = 0; i < CIGAR.length; i += 2) {
26
- const op = CIGAR[i + 1];
27
- const len = +CIGAR[i];
23
+ const CIGAR = feature.get('CIGAR');
24
+ const cigarOps = (0, MismatchParser_1.parseCigar)(CIGAR);
25
+ for (let i = 0; i < cigarOps.length; i += 2) {
26
+ const op = cigarOps[i + 1];
27
+ const len = +cigarOps[i];
28
28
  if (op === 'S') {
29
29
  for (let k = 0; k < len; k++) {
30
30
  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>;
@@ -43,29 +43,29 @@ const sortFeature = (features, sortedBy) => {
43
43
  // first sort all mismatches, then all reference bases at the end
44
44
  case 'Base pair': {
45
45
  const baseSortArray = [];
46
- featuresInCenterLine.forEach(feature => {
46
+ for (const feature of featuresInCenterLine) {
47
47
  const mismatches = feature.get('mismatches');
48
- mismatches.forEach(mismatch => {
48
+ for (const m of mismatches) {
49
49
  const start = feature.get('start');
50
- const offset = start + mismatch.start + 1;
51
- const consuming = mismatch.type === 'insertion' || mismatch.type === 'softclip';
52
- const len = consuming ? 0 : mismatch.length;
50
+ const offset = start + m.start + 1;
51
+ const consuming = m.type === 'insertion' || m.type === 'softclip';
52
+ const len = consuming ? 0 : m.length;
53
53
  if (pos >= offset && pos < offset + len) {
54
- baseSortArray.push([feature.id(), mismatch]);
54
+ baseSortArray.push([feature.id(), m]);
55
55
  }
56
- });
57
- });
56
+ }
57
+ }
58
58
  const baseMap = new Map(baseSortArray);
59
59
  featuresInCenterLine.sort((a, b) => {
60
60
  const aMismatch = baseMap.get(a.id());
61
61
  const bMismatch = baseMap.get(b.id());
62
62
  const acode = bMismatch === null || bMismatch === void 0 ? void 0 : bMismatch.base.toUpperCase();
63
63
  const bcode = aMismatch === null || aMismatch === void 0 ? void 0 : aMismatch.base.toUpperCase();
64
- if (acode === bcode && acode === '*') {
65
- // @ts-expect-error
66
- return aMismatch.length - bMismatch.length;
67
- }
68
- return ((acode ? acode.charCodeAt(0) : 0) - (bcode ? bcode.charCodeAt(0) : 0));
64
+ return acode === bcode && acode === '*'
65
+ ? // @ts-expect-error
66
+ aMismatch.length - bMismatch.length
67
+ : (acode ? acode.charCodeAt(0) : 0) -
68
+ (bcode ? bcode.charCodeAt(0) : 0);
69
69
  });
70
70
  break;
71
71
  }
@@ -9,8 +9,8 @@ const rxjs_1 = require("@jbrowse/core/util/rxjs");
9
9
  const operators_1 = require("rxjs/operators");
10
10
  const rxjs_2 = require("rxjs");
11
11
  // locals
12
- const generateCoverageBins_1 = __importDefault(require("./generateCoverageBins"));
13
12
  const util_1 = require("../util");
13
+ const generateCoverageBins_1 = require("./generateCoverageBins");
14
14
  class SNPCoverageAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
15
15
  async configure() {
16
16
  var _a, _b;
@@ -38,14 +38,19 @@ class SNPCoverageAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
38
38
  getFeatures(region, opts = {}) {
39
39
  return (0, rxjs_1.ObservableCreate)(async (observer) => {
40
40
  const { subadapter } = await this.configure();
41
- const feats = await (0, rxjs_2.firstValueFrom)(subadapter.getFeatures(region, opts).pipe((0, operators_1.toArray)()));
42
- const { bins, skipmap } = await (0, generateCoverageBins_1.default)(feats, region, opts, arg => this.fetchSequence(arg));
41
+ const features = await (0, rxjs_2.firstValueFrom)(subadapter.getFeatures(region, opts).pipe((0, operators_1.toArray)()));
42
+ const { bins, skipmap } = await (0, generateCoverageBins_1.generateCoverageBins)({
43
+ features,
44
+ region,
45
+ opts,
46
+ fetchSequence: (region) => this.fetchSequence(region),
47
+ });
43
48
  bins.forEach((bin, index) => {
44
49
  const start = region.start + index;
45
50
  observer.next(new simpleFeature_1.default({
46
51
  id: `${this.id}-${start}`,
47
52
  data: {
48
- score: bin.total,
53
+ score: bin.depth,
49
54
  snpinfo: bin,
50
55
  start,
51
56
  end: start + 1,
@@ -63,7 +68,7 @@ class SNPCoverageAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
63
68
  end: skip.end,
64
69
  strand: skip.strand,
65
70
  score: skip.score,
66
- xs: skip.xs,
71
+ effectiveStrand: skip.effectiveStrand,
67
72
  },
68
73
  }));
69
74
  });
@@ -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 {};