@jbrowse/plugin-alignments 3.6.5 → 3.7.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 (241) hide show
  1. package/dist/AlignmentsFeatureDetail/stateModelFactory.d.ts +4 -4
  2. package/dist/CramAdapter/CramAdapter.js +1 -1
  3. package/dist/CramAdapter/CramSlightlyLazyFeature.js +8 -7
  4. package/dist/CramAdapter/{util.js → readFeaturesToCIGAR.js} +4 -5
  5. package/dist/CramAdapter/readFeaturesToMismatches.d.ts +5 -0
  6. package/dist/CramAdapter/readFeaturesToMismatches.js +106 -0
  7. package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +6 -2
  8. package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +17 -2
  9. package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +2 -2
  10. package/dist/LinearPileupDisplay/components/GroupByDialog.js +4 -4
  11. package/dist/LinearPileupDisplay/components/SetModificationThresholdDialog.d.ts +10 -0
  12. package/dist/LinearPileupDisplay/components/SetModificationThresholdDialog.js +39 -0
  13. package/dist/LinearPileupDisplay/doAfterAttach.d.ts +1 -0
  14. package/dist/LinearPileupDisplay/doAfterAttach.js +3 -2
  15. package/dist/LinearPileupDisplay/model.d.ts +20 -2
  16. package/dist/LinearPileupDisplay/model.js +39 -4
  17. package/dist/LinearReadArcsDisplay/index.js +1 -1
  18. package/dist/LinearReadArcsDisplay/model.d.ts +23 -30
  19. package/dist/LinearReadArcsDisplay/model.js +5 -86
  20. package/dist/LinearReadCloudDisplay/components/ReactComponent.js +84 -2
  21. package/dist/LinearReadCloudDisplay/components/SetFeatureHeightDialog.d.ts +10 -0
  22. package/dist/LinearReadCloudDisplay/components/SetFeatureHeightDialog.js +26 -0
  23. package/dist/LinearReadCloudDisplay/configSchema.d.ts +7 -0
  24. package/dist/LinearReadCloudDisplay/configSchema.js +5 -0
  25. package/dist/LinearReadCloudDisplay/drawFeatsAbstract.js +13 -0
  26. package/dist/LinearReadCloudDisplay/drawFeatsCloud.js +24 -0
  27. package/dist/LinearReadCloudDisplay/drawFeatsCommon.d.ts +23 -0
  28. package/dist/LinearReadCloudDisplay/drawFeatsCommon.js +198 -0
  29. package/dist/LinearReadCloudDisplay/drawFeatsStack.d.ts +2 -0
  30. package/dist/LinearReadCloudDisplay/drawFeatsStack.js +36 -0
  31. package/dist/LinearReadCloudDisplay/index.js +1 -1
  32. package/dist/LinearReadCloudDisplay/model.d.ts +51 -31
  33. package/dist/LinearReadCloudDisplay/model.js +93 -78
  34. package/dist/LinearSNPCoverageDisplay/components/TooltipContents.d.ts +3 -0
  35. package/dist/LinearSNPCoverageDisplay/components/TooltipContents.js +148 -19
  36. package/dist/LinearSNPCoverageDisplay/model.js +14 -3
  37. package/dist/MismatchParser/cigarToMismatches.js +1 -0
  38. package/dist/ModificationParser/detectSimplexModifications.d.ts +4 -0
  39. package/dist/ModificationParser/detectSimplexModifications.js +20 -0
  40. package/dist/ModificationParser/getModPositions.d.ts +1 -1
  41. package/dist/ModificationParser/getModPositions.js +13 -16
  42. package/dist/PileupRPC/methods/GetVisibleModifications.d.ts +4 -1
  43. package/dist/PileupRPC/methods/GetVisibleModifications.js +16 -3
  44. package/dist/PileupRenderer/PileupRenderer.d.ts +6 -1
  45. package/dist/PileupRenderer/PileupRenderer.js +11 -14
  46. package/dist/PileupRenderer/components/PileupRendering.d.ts +8 -15
  47. package/dist/PileupRenderer/components/PileupRendering.js +18 -2
  48. package/dist/PileupRenderer/makeImageData.d.ts +5 -2
  49. package/dist/PileupRenderer/makeImageData.js +37 -6
  50. package/dist/PileupRenderer/{getAlignmentShapeColor.js → renderers/getAlignmentShapeColor.js} +2 -2
  51. package/{esm/PileupRenderer → dist/PileupRenderer/renderers}/renderAlignment.d.ts +6 -3
  52. package/dist/PileupRenderer/{renderAlignment.js → renderers/renderAlignment.js} +12 -3
  53. package/{esm/PileupRenderer → dist/PileupRenderer/renderers}/renderAlignmentShape.d.ts +2 -2
  54. package/dist/PileupRenderer/{renderAlignmentShape.js → renderers/renderAlignmentShape.js} +1 -1
  55. package/dist/PileupRenderer/{renderMethylation.d.ts → renderers/renderMethylation.d.ts} +2 -2
  56. package/dist/PileupRenderer/{renderMethylation.js → renderers/renderMethylation.js} +2 -2
  57. package/dist/PileupRenderer/{renderMismatches.d.ts → renderers/renderMismatches.d.ts} +6 -3
  58. package/dist/PileupRenderer/{renderMismatches.js → renderers/renderMismatches.js} +29 -5
  59. package/dist/PileupRenderer/{renderModifications.d.ts → renderers/renderModifications.d.ts} +6 -3
  60. package/dist/PileupRenderer/renderers/renderModifications.js +84 -0
  61. package/dist/PileupRenderer/{renderPerBaseLettering.d.ts → renderers/renderPerBaseLettering.d.ts} +1 -1
  62. package/dist/PileupRenderer/{renderPerBaseLettering.js → renderers/renderPerBaseLettering.js} +1 -1
  63. package/{esm/PileupRenderer → dist/PileupRenderer/renderers}/renderPerBaseQuality.d.ts +1 -1
  64. package/dist/PileupRenderer/{renderPerBaseQuality.js → renderers/renderPerBaseQuality.js} +1 -1
  65. package/dist/PileupRenderer/{renderSoftClipping.d.ts → renderers/renderSoftClipping.d.ts} +2 -2
  66. package/dist/PileupRenderer/{renderSoftClipping.js → renderers/renderSoftClipping.js} +2 -2
  67. package/dist/PileupRenderer/types.d.ts +6 -0
  68. package/dist/SNPCoverageAdapter/generateCoverageBins.js +5 -4
  69. package/dist/SNPCoverageAdapter/processModifications.js +14 -4
  70. package/dist/SNPCoverageRenderer/makeImage.js +44 -33
  71. package/dist/SNPCoverageRenderer/types.d.ts +1 -0
  72. package/dist/shared/LinearReadDisplayBaseMixin.d.ts +24 -0
  73. package/dist/shared/LinearReadDisplayBaseMixin.js +50 -0
  74. package/dist/shared/LinearReadDisplayWithLayoutMixin.d.ts +11 -0
  75. package/dist/shared/LinearReadDisplayWithLayoutMixin.js +24 -0
  76. package/dist/shared/LinearReadDisplayWithPairFiltersMixin.d.ts +11 -0
  77. package/dist/shared/LinearReadDisplayWithPairFiltersMixin.js +27 -0
  78. package/dist/shared/afterAttach.js +3 -2
  79. package/dist/shared/chainToSimpleFeature.d.ts +3 -0
  80. package/dist/shared/chainToSimpleFeature.js +43 -0
  81. package/dist/shared/chevron.d.ts +1 -0
  82. package/dist/shared/chevron.js +27 -0
  83. package/dist/shared/color.d.ts +43 -6
  84. package/dist/shared/color.js +101 -22
  85. package/dist/shared/components/BaseDisplayComponent.d.ts +12 -3
  86. package/dist/shared/components/BaseDisplayComponent.js +2 -2
  87. package/dist/shared/components/SetFeatureHeightDialog.d.ts +10 -0
  88. package/dist/shared/components/SetFeatureHeightDialog.js +26 -0
  89. package/dist/shared/components/SetMaxHeightDialog.d.ts +8 -0
  90. package/dist/shared/components/SetMaxHeightDialog.js +28 -0
  91. package/dist/shared/drawLongReadChains.d.ts +24 -0
  92. package/dist/shared/drawLongReadChains.js +104 -0
  93. package/dist/shared/drawPairChains.d.ts +24 -0
  94. package/dist/shared/drawPairChains.js +94 -0
  95. package/dist/shared/flatbushType.d.ts +12 -0
  96. package/dist/shared/flatbushType.js +2 -0
  97. package/dist/shared/getUniqueModifications.d.ts +4 -1
  98. package/dist/shared/menuItems.d.ts +23 -0
  99. package/dist/shared/menuItems.js +89 -0
  100. package/dist/shared/modificationData.d.ts +6 -0
  101. package/dist/shared/modificationData.js +22 -0
  102. package/dist/shared/primaryStrand.d.ts +3 -0
  103. package/dist/shared/primaryStrand.js +24 -0
  104. package/dist/shared/types.d.ts +2 -0
  105. package/dist/shared/util.d.ts +2 -0
  106. package/dist/shared/util.js +6 -1
  107. package/dist/util.d.ts +1 -6
  108. package/dist/util.js +4 -15
  109. package/esm/AlignmentsFeatureDetail/stateModelFactory.d.ts +4 -4
  110. package/esm/CramAdapter/CramAdapter.js +1 -1
  111. package/esm/CramAdapter/CramSlightlyLazyFeature.js +2 -1
  112. package/esm/CramAdapter/{util.js → readFeaturesToCIGAR.js} +4 -5
  113. package/esm/CramAdapter/readFeaturesToMismatches.d.ts +5 -0
  114. package/esm/CramAdapter/readFeaturesToMismatches.js +103 -0
  115. package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +6 -2
  116. package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +17 -2
  117. package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +2 -2
  118. package/esm/LinearPileupDisplay/components/GroupByDialog.js +4 -4
  119. package/esm/LinearPileupDisplay/components/SetModificationThresholdDialog.d.ts +10 -0
  120. package/esm/LinearPileupDisplay/components/SetModificationThresholdDialog.js +37 -0
  121. package/esm/LinearPileupDisplay/doAfterAttach.d.ts +1 -0
  122. package/esm/LinearPileupDisplay/doAfterAttach.js +3 -2
  123. package/esm/LinearPileupDisplay/model.d.ts +20 -2
  124. package/esm/LinearPileupDisplay/model.js +39 -4
  125. package/esm/LinearReadArcsDisplay/index.js +1 -1
  126. package/esm/LinearReadArcsDisplay/model.d.ts +23 -30
  127. package/esm/LinearReadArcsDisplay/model.js +5 -83
  128. package/esm/LinearReadCloudDisplay/components/ReactComponent.js +86 -4
  129. package/esm/LinearReadCloudDisplay/components/SetFeatureHeightDialog.d.ts +10 -0
  130. package/esm/LinearReadCloudDisplay/components/SetFeatureHeightDialog.js +24 -0
  131. package/esm/LinearReadCloudDisplay/configSchema.d.ts +7 -0
  132. package/esm/LinearReadCloudDisplay/configSchema.js +5 -0
  133. package/esm/LinearReadCloudDisplay/drawFeatsAbstract.d.ts +2 -0
  134. package/esm/LinearReadCloudDisplay/drawFeatsAbstract.js +10 -0
  135. package/esm/LinearReadCloudDisplay/drawFeatsCloud.d.ts +2 -0
  136. package/esm/LinearReadCloudDisplay/drawFeatsCloud.js +21 -0
  137. package/esm/LinearReadCloudDisplay/drawFeatsCommon.d.ts +23 -0
  138. package/esm/LinearReadCloudDisplay/drawFeatsCommon.js +187 -0
  139. package/esm/LinearReadCloudDisplay/drawFeatsStack.d.ts +2 -0
  140. package/esm/LinearReadCloudDisplay/drawFeatsStack.js +30 -0
  141. package/esm/LinearReadCloudDisplay/index.js +1 -1
  142. package/esm/LinearReadCloudDisplay/model.d.ts +51 -31
  143. package/esm/LinearReadCloudDisplay/model.js +94 -76
  144. package/esm/LinearSNPCoverageDisplay/components/TooltipContents.d.ts +3 -0
  145. package/esm/LinearSNPCoverageDisplay/components/TooltipContents.js +149 -20
  146. package/esm/LinearSNPCoverageDisplay/model.js +14 -3
  147. package/esm/MismatchParser/cigarToMismatches.js +1 -0
  148. package/esm/ModificationParser/detectSimplexModifications.d.ts +4 -0
  149. package/esm/ModificationParser/detectSimplexModifications.js +17 -0
  150. package/esm/ModificationParser/getModPositions.d.ts +1 -1
  151. package/esm/ModificationParser/getModPositions.js +13 -16
  152. package/esm/PileupRPC/methods/GetVisibleModifications.d.ts +4 -1
  153. package/esm/PileupRPC/methods/GetVisibleModifications.js +16 -3
  154. package/esm/PileupRenderer/PileupRenderer.d.ts +6 -1
  155. package/esm/PileupRenderer/PileupRenderer.js +11 -14
  156. package/esm/PileupRenderer/components/PileupRendering.d.ts +8 -15
  157. package/esm/PileupRenderer/components/PileupRendering.js +16 -3
  158. package/esm/PileupRenderer/makeImageData.d.ts +5 -2
  159. package/esm/PileupRenderer/makeImageData.js +34 -6
  160. package/esm/PileupRenderer/{getAlignmentShapeColor.js → renderers/getAlignmentShapeColor.js} +2 -2
  161. package/{dist/PileupRenderer → esm/PileupRenderer/renderers}/renderAlignment.d.ts +6 -3
  162. package/esm/PileupRenderer/{renderAlignment.js → renderers/renderAlignment.js} +12 -3
  163. package/{dist/PileupRenderer → esm/PileupRenderer/renderers}/renderAlignmentShape.d.ts +2 -2
  164. package/esm/PileupRenderer/{renderAlignmentShape.js → renderers/renderAlignmentShape.js} +1 -1
  165. package/esm/PileupRenderer/{renderMethylation.d.ts → renderers/renderMethylation.d.ts} +2 -2
  166. package/esm/PileupRenderer/{renderMethylation.js → renderers/renderMethylation.js} +2 -2
  167. package/esm/PileupRenderer/{renderMismatches.d.ts → renderers/renderMismatches.d.ts} +6 -3
  168. package/esm/PileupRenderer/{renderMismatches.js → renderers/renderMismatches.js} +29 -5
  169. package/esm/PileupRenderer/{renderModifications.d.ts → renderers/renderModifications.d.ts} +6 -3
  170. package/esm/PileupRenderer/renderers/renderModifications.js +81 -0
  171. package/esm/PileupRenderer/{renderPerBaseLettering.d.ts → renderers/renderPerBaseLettering.d.ts} +1 -1
  172. package/esm/PileupRenderer/{renderPerBaseLettering.js → renderers/renderPerBaseLettering.js} +1 -1
  173. package/{dist/PileupRenderer → esm/PileupRenderer/renderers}/renderPerBaseQuality.d.ts +1 -1
  174. package/esm/PileupRenderer/{renderPerBaseQuality.js → renderers/renderPerBaseQuality.js} +1 -1
  175. package/esm/PileupRenderer/{renderSoftClipping.d.ts → renderers/renderSoftClipping.d.ts} +2 -2
  176. package/esm/PileupRenderer/{renderSoftClipping.js → renderers/renderSoftClipping.js} +2 -2
  177. package/esm/PileupRenderer/types.d.ts +6 -0
  178. package/esm/SNPCoverageAdapter/generateCoverageBins.js +5 -4
  179. package/esm/SNPCoverageAdapter/processModifications.js +14 -4
  180. package/esm/SNPCoverageRenderer/makeImage.js +44 -33
  181. package/esm/SNPCoverageRenderer/types.d.ts +1 -0
  182. package/esm/shared/LinearReadDisplayBaseMixin.d.ts +24 -0
  183. package/esm/shared/LinearReadDisplayBaseMixin.js +47 -0
  184. package/esm/shared/LinearReadDisplayWithLayoutMixin.d.ts +11 -0
  185. package/esm/shared/LinearReadDisplayWithLayoutMixin.js +21 -0
  186. package/esm/shared/LinearReadDisplayWithPairFiltersMixin.d.ts +11 -0
  187. package/esm/shared/LinearReadDisplayWithPairFiltersMixin.js +24 -0
  188. package/esm/shared/afterAttach.js +3 -2
  189. package/esm/shared/chainToSimpleFeature.d.ts +3 -0
  190. package/esm/shared/chainToSimpleFeature.js +40 -0
  191. package/esm/shared/chevron.d.ts +1 -0
  192. package/esm/shared/chevron.js +24 -0
  193. package/esm/shared/color.d.ts +43 -6
  194. package/esm/shared/color.js +96 -20
  195. package/esm/shared/components/BaseDisplayComponent.d.ts +12 -3
  196. package/esm/shared/components/BaseDisplayComponent.js +2 -2
  197. package/esm/shared/components/SetFeatureHeightDialog.d.ts +10 -0
  198. package/esm/shared/components/SetFeatureHeightDialog.js +24 -0
  199. package/esm/shared/components/SetMaxHeightDialog.d.ts +8 -0
  200. package/esm/shared/components/SetMaxHeightDialog.js +26 -0
  201. package/esm/shared/drawLongReadChains.d.ts +24 -0
  202. package/esm/shared/drawLongReadChains.js +101 -0
  203. package/esm/shared/drawPairChains.d.ts +24 -0
  204. package/esm/shared/drawPairChains.js +91 -0
  205. package/esm/shared/flatbushType.d.ts +12 -0
  206. package/esm/shared/flatbushType.js +1 -0
  207. package/esm/shared/getUniqueModifications.d.ts +4 -1
  208. package/esm/shared/menuItems.d.ts +23 -0
  209. package/esm/shared/menuItems.js +49 -0
  210. package/esm/shared/modificationData.d.ts +6 -0
  211. package/esm/shared/modificationData.js +18 -0
  212. package/esm/shared/primaryStrand.d.ts +3 -0
  213. package/esm/shared/primaryStrand.js +20 -0
  214. package/esm/shared/types.d.ts +2 -0
  215. package/esm/shared/util.d.ts +2 -0
  216. package/esm/shared/util.js +4 -0
  217. package/esm/util.d.ts +1 -6
  218. package/esm/util.js +2 -14
  219. package/package.json +6 -6
  220. package/dist/LinearReadCloudDisplay/drawFeats.js +0 -27
  221. package/dist/LinearReadCloudDisplay/drawLongReadChains.d.ts +0 -11
  222. package/dist/LinearReadCloudDisplay/drawLongReadChains.js +0 -64
  223. package/dist/LinearReadCloudDisplay/drawPairChains.d.ts +0 -17
  224. package/dist/LinearReadCloudDisplay/drawPairChains.js +0 -94
  225. package/dist/PileupRenderer/renderModifications.js +0 -44
  226. package/esm/LinearReadCloudDisplay/drawFeats.js +0 -24
  227. package/esm/LinearReadCloudDisplay/drawLongReadChains.d.ts +0 -11
  228. package/esm/LinearReadCloudDisplay/drawLongReadChains.js +0 -61
  229. package/esm/LinearReadCloudDisplay/drawPairChains.d.ts +0 -17
  230. package/esm/LinearReadCloudDisplay/drawPairChains.js +0 -90
  231. package/esm/PileupRenderer/renderModifications.js +0 -41
  232. /package/dist/CramAdapter/{util.d.ts → readFeaturesToCIGAR.d.ts} +0 -0
  233. /package/dist/LinearReadCloudDisplay/{drawFeats.d.ts → drawFeatsAbstract.d.ts} +0 -0
  234. /package/{esm/LinearReadCloudDisplay/drawFeats.d.ts → dist/LinearReadCloudDisplay/drawFeatsCloud.d.ts} +0 -0
  235. /package/dist/PileupRenderer/{getAlignmentShapeColor.d.ts → renderers/getAlignmentShapeColor.d.ts} +0 -0
  236. /package/dist/{LinearReadCloudDisplay/util.d.ts → shared/canvasUtils.d.ts} +0 -0
  237. /package/dist/{LinearReadCloudDisplay/util.js → shared/canvasUtils.js} +0 -0
  238. /package/esm/CramAdapter/{util.d.ts → readFeaturesToCIGAR.d.ts} +0 -0
  239. /package/esm/PileupRenderer/{getAlignmentShapeColor.d.ts → renderers/getAlignmentShapeColor.d.ts} +0 -0
  240. /package/esm/{LinearReadCloudDisplay/util.d.ts → shared/canvasUtils.d.ts} +0 -0
  241. /package/esm/{LinearReadCloudDisplay/util.js → shared/canvasUtils.js} +0 -0
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAlignmentShapeColor = getAlignmentShapeColor;
4
4
  const configuration_1 = require("@jbrowse/core/configuration");
5
- const colorBy_1 = require("./colorBy");
6
- const color_1 = require("../shared/color");
5
+ const color_1 = require("../../shared/color");
6
+ const colorBy_1 = require("../colorBy");
7
7
  function getAlignmentShapeColor({ colorType, tag, feature, config, defaultColor, colorTagMap, }) {
8
8
  switch (colorType) {
9
9
  case 'insertSize':
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { FlatbushItem, ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  export declare function renderAlignment({ ctx, feat, renderArgs, colorMap, colorContrastMap, charWidth, charHeight, defaultColor, canvasWidth, }: {
4
4
  ctx: CanvasRenderingContext2D;
5
5
  feat: LayoutFeature;
@@ -10,4 +10,7 @@ export declare function renderAlignment({ ctx, feat, renderArgs, colorMap, color
10
10
  charHeight: number;
11
11
  defaultColor: boolean;
12
12
  canvasWidth: number;
13
- }): void;
13
+ }): {
14
+ coords: number[];
15
+ items: FlatbushItem[];
16
+ };
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderAlignment = renderAlignment;
4
4
  const getAlignmentShapeColor_1 = require("./getAlignmentShapeColor");
5
5
  const renderAlignmentShape_1 = require("./renderAlignmentShape");
6
+ const renderMethylation_1 = require("./renderMethylation");
6
7
  const renderModifications_1 = require("./renderModifications");
7
8
  const renderPerBaseLettering_1 = require("./renderPerBaseLettering");
8
9
  const renderPerBaseQuality_1 = require("./renderPerBaseQuality");
9
- const MismatchParser_1 = require("../MismatchParser");
10
- const renderMethylation_1 = require("./renderMethylation");
10
+ const MismatchParser_1 = require("../../MismatchParser");
11
11
  function renderAlignment({ ctx, feat, renderArgs, colorMap, colorContrastMap, charWidth, charHeight, defaultColor, canvasWidth, }) {
12
+ const items = [];
13
+ const coords = [];
12
14
  const { config, bpPerPx, regions, colorBy, colorTagMap = {} } = renderArgs;
13
15
  const { tag = '', type: colorType = '' } = colorBy || {};
14
16
  const { feature } = feat;
@@ -53,7 +55,7 @@ function renderAlignment({ ctx, feat, renderArgs, colorMap, colorContrastMap, ch
53
55
  }
54
56
  case 'modifications': {
55
57
  const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
56
- (0, renderModifications_1.renderModifications)({
58
+ const ret = (0, renderModifications_1.renderModifications)({
57
59
  ctx,
58
60
  feat,
59
61
  region,
@@ -62,6 +64,12 @@ function renderAlignment({ ctx, feat, renderArgs, colorMap, colorContrastMap, ch
62
64
  canvasWidth,
63
65
  cigarOps,
64
66
  });
67
+ for (let i = 0, l = ret.coords.length; i < l; i++) {
68
+ coords.push(ret.coords[i]);
69
+ }
70
+ for (let i = 0, l = ret.items.length; i < l; i++) {
71
+ items.push(ret.items[i]);
72
+ }
65
73
  break;
66
74
  }
67
75
  case 'methylation': {
@@ -78,4 +86,5 @@ function renderAlignment({ ctx, feat, renderArgs, colorMap, colorContrastMap, ch
78
86
  break;
79
87
  }
80
88
  }
89
+ return { coords, items };
81
90
  }
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  export declare function renderAlignmentShape({ ctx, feat, renderArgs, }: {
4
4
  ctx: CanvasRenderingContext2D;
5
5
  feat: LayoutFeature;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderAlignmentShape = renderAlignmentShape;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const MismatchParser_1 = require("../MismatchParser");
5
+ const MismatchParser_1 = require("../../MismatchParser");
6
6
  function renderAlignmentShape({ ctx, feat, renderArgs, }) {
7
7
  const { regions, bpPerPx } = renderArgs;
8
8
  const { heightPx, topPx, feature } = feat;
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  import type { Region } from '@jbrowse/core/util';
4
4
  export declare function renderMethylation({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }: {
5
5
  ctx: CanvasRenderingContext2D;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderMethylation = renderMethylation;
4
4
  const util_1 = require("@jbrowse/core/util");
5
5
  const colord_1 = require("@jbrowse/core/util/colord");
6
- const util_2 = require("./util");
7
- const getMethBins_1 = require("../ModificationParser/getMethBins");
6
+ const getMethBins_1 = require("../../ModificationParser/getMethBins");
7
+ const util_2 = require("../util");
8
8
  function renderMethylation({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }) {
9
9
  const { regionSequence } = renderArgs;
10
10
  const { feature, topPx, heightPx } = feat;
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { FlatbushItem, ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  export declare function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInsertionIndicatorScale, mismatchAlpha, charWidth, charHeight, colorMap, colorContrastMap, hideSmallIndels, canvasWidth, drawSNPsMuted, drawIndels, }: {
4
4
  ctx: CanvasRenderingContext2D;
5
5
  feat: LayoutFeature;
@@ -15,4 +15,7 @@ export declare function renderMismatches({ ctx, feat, renderArgs, minSubfeatureW
15
15
  charWidth: number;
16
16
  charHeight: number;
17
17
  canvasWidth: number;
18
- }): void;
18
+ }): {
19
+ coords: number[];
20
+ items: FlatbushItem[];
21
+ };
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderMismatches = renderMismatches;
4
4
  const util_1 = require("@jbrowse/core/util");
5
5
  const colord_1 = require("@jbrowse/core/util/colord");
6
- const util_2 = require("./util");
6
+ const util_2 = require("../util");
7
7
  function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInsertionIndicatorScale, mismatchAlpha, charWidth, charHeight, colorMap, colorContrastMap, hideSmallIndels, canvasWidth, drawSNPsMuted, drawIndels = true, }) {
8
+ var _a;
9
+ const items = [];
10
+ const coords = [];
8
11
  const { bpPerPx, regions } = renderArgs;
9
12
  const { heightPx, topPx, feature } = feat;
10
13
  const region = regions[0];
11
14
  const start = feature.get('start');
12
15
  const pxPerBp = Math.min(1 / bpPerPx, 2);
13
- const mismatches = feature.get('mismatches');
16
+ const mismatches = (_a = feature.get('mismatches')) !== null && _a !== void 0 ? _a : [];
14
17
  const heightLim = charHeight - 2;
15
18
  const extraHorizontallyFlippedOffset = region.reversed ? 1 / bpPerPx + 1 : -1;
16
- if (!mismatches) {
17
- return;
18
- }
19
19
  for (const mismatch of mismatches) {
20
20
  const mstart = start + mismatch.start;
21
21
  const mlen = mismatch.length;
@@ -23,6 +23,11 @@ function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInse
23
23
  const [leftPx, rightPx] = (0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx);
24
24
  const widthPx = Math.max(minSubfeatureWidth, rightPx - leftPx);
25
25
  if (mismatch.type === 'mismatch') {
26
+ items.push({
27
+ type: 'mismatch',
28
+ seq: mismatch.base,
29
+ });
30
+ coords.push(leftPx, topPx, rightPx, topPx + heightPx);
26
31
  if (!drawSNPsMuted) {
27
32
  const baseColor = colorMap[mismatch.base] || '#888';
28
33
  const c = mismatchAlpha && mismatch.qual !== undefined
@@ -49,6 +54,11 @@ function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInse
49
54
  const len = mismatch.length;
50
55
  if (!hideSmallIndels || len >= 10) {
51
56
  (0, util_2.fillRect)(ctx, leftPx, topPx, Math.abs(leftPx - rightPx), heightPx, canvasWidth, colorMap.deletion);
57
+ items.push({
58
+ type: 'deletion',
59
+ seq: `${mismatch.length}`,
60
+ });
61
+ coords.push(leftPx, topPx, rightPx, topPx + heightPx);
52
62
  const txt = `${mismatch.length}`;
53
63
  const rwidth = (0, util_1.measureText)(txt, 10);
54
64
  if (widthPx >= rwidth && heightPx >= heightLim) {
@@ -65,6 +75,11 @@ function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInse
65
75
  if (!hideSmallIndels) {
66
76
  (0, util_2.fillRect)(ctx, pos, topPx, insW, heightPx, canvasWidth, colorMap.insertion);
67
77
  if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
78
+ items.push({
79
+ type: 'insertion',
80
+ seq: mismatch.insertedBases || 'unknown',
81
+ });
82
+ coords.push(leftPx - 2, topPx, leftPx + insW + 2, topPx + heightPx);
68
83
  const l = Math.round(pos - insW);
69
84
  (0, util_2.fillRect)(ctx, l, topPx, insW * 3, 1, canvasWidth);
70
85
  (0, util_2.fillRect)(ctx, l, topPx + heightPx - 1, insW * 3, 1, canvasWidth);
@@ -104,6 +119,11 @@ function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInse
104
119
  if (mismatch.type === 'insertion' && len >= 10) {
105
120
  const [leftPx] = (0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx);
106
121
  const txt = `${len}`;
122
+ items.push({
123
+ type: 'insertion',
124
+ seq: mismatch.insertedBases || 'unknown',
125
+ });
126
+ coords.push(leftPx - 3, topPx, leftPx + 4, topPx + heightPx);
107
127
  if (bpPerPx > largeInsertionIndicatorScale) {
108
128
  (0, util_2.fillRect)(ctx, leftPx - 1, topPx, 2, heightPx, canvasWidth, colorMap.insertion);
109
129
  }
@@ -121,4 +141,8 @@ function renderMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInse
121
141
  }
122
142
  }
123
143
  }
144
+ return {
145
+ coords,
146
+ items,
147
+ };
124
148
  }
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { FlatbushItem, ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  import type { Region } from '@jbrowse/core/util';
4
4
  export declare function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }: {
5
5
  ctx: CanvasRenderingContext2D;
@@ -9,4 +9,7 @@ export declare function renderModifications({ ctx, feat, region, bpPerPx, render
9
9
  renderArgs: ProcessedRenderArgs;
10
10
  canvasWidth: number;
11
11
  cigarOps: string[];
12
- }): void;
12
+ }): {
13
+ coords: number[];
14
+ items: FlatbushItem[];
15
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderModifications = renderModifications;
4
+ const util_1 = require("@jbrowse/core/util");
5
+ const MismatchParser_1 = require("../../MismatchParser");
6
+ const getModPositions_1 = require("../../ModificationParser/getModPositions");
7
+ const getModProbabilities_1 = require("../../ModificationParser/getModProbabilities");
8
+ const getMaximumModificationAtEachPosition_1 = require("../../shared/getMaximumModificationAtEachPosition");
9
+ const modificationData_1 = require("../../shared/modificationData");
10
+ const util_2 = require("../../shared/util");
11
+ const util_3 = require("../../util");
12
+ const util_4 = require("../util");
13
+ function renderModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, cigarOps, }) {
14
+ var _a, _b, _c, _d, _e;
15
+ const items = [];
16
+ const coords = [];
17
+ const { feature, topPx, heightPx } = feat;
18
+ const { colorBy, visibleModifications = {} } = renderArgs;
19
+ const seq = feature.get('seq');
20
+ if (!seq) {
21
+ return { coords, items };
22
+ }
23
+ const start = feature.get('start');
24
+ const isolatedModification = (_a = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _a === void 0 ? void 0 : _a.isolatedModification;
25
+ const twoColor = (_b = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _b === void 0 ? void 0 : _b.twoColor;
26
+ const modificationThreshold = (_d = (_c = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _c === void 0 ? void 0 : _c.threshold) !== null && _d !== void 0 ? _d : 10;
27
+ const thresholdFraction = modificationThreshold / 100;
28
+ const fstrand = feature.get('strand');
29
+ const mm = (0, util_3.getTagAlt)(feature, 'MM', 'Mm') || '';
30
+ const modifications = (0, getModPositions_1.getModPositions)(mm, seq, fstrand);
31
+ const probabilities = (0, getModProbabilities_1.getModProbabilities)(feature);
32
+ const modsByPosition = new Map();
33
+ let probIndex = 0;
34
+ for (const { type, base, strand, positions } of modifications) {
35
+ for (const { ref, idx } of (0, MismatchParser_1.getNextRefPos)(cigarOps, positions)) {
36
+ const prob = (probabilities === null || probabilities === void 0 ? void 0 : probabilities[probIndex + (fstrand === -1 ? positions.length - 1 - idx : idx)]) || 0;
37
+ if (!modsByPosition.has(ref)) {
38
+ modsByPosition.set(ref, []);
39
+ }
40
+ modsByPosition.get(ref).push({ type, base, strand, prob });
41
+ }
42
+ probIndex += positions.length;
43
+ }
44
+ (_e = (0, getMaximumModificationAtEachPosition_1.getMaxProbModAtEachPosition)(feature, cigarOps)) === null || _e === void 0 ? void 0 : _e.forEach(({ allProbs, prob, type }, pos) => {
45
+ const r = start + pos;
46
+ const [leftPx, rightPx] = (0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx);
47
+ const mod = visibleModifications[type];
48
+ if (!mod) {
49
+ console.warn(`${type} not known yet`);
50
+ return;
51
+ }
52
+ if (isolatedModification && mod.type !== isolatedModification) {
53
+ return;
54
+ }
55
+ if (prob < thresholdFraction) {
56
+ return;
57
+ }
58
+ const col = mod.color || 'black';
59
+ const s = 1 - (0, util_1.sum)(allProbs);
60
+ if (twoColor && s > (0, util_1.max)(allProbs)) {
61
+ const c = (0, util_2.alphaColor)('blue', s);
62
+ const w = rightPx - leftPx + 0.5;
63
+ (0, util_4.fillRect)(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
64
+ }
65
+ else {
66
+ const c = (0, util_2.alphaColor)(col, prob);
67
+ const w = rightPx - leftPx + 0.5;
68
+ (0, util_4.fillRect)(ctx, leftPx, topPx, w, heightPx, canvasWidth, c);
69
+ }
70
+ const modsAtPos = modsByPosition.get(pos) || [];
71
+ const strandInfo = modsAtPos
72
+ .map(m => `${m.base}${m.strand}${m.type} ${(0, modificationData_1.getModificationName)(m.type)} (${(m.prob * 100).toFixed(1)}%)`)
73
+ .join('<br/>');
74
+ items.push({
75
+ type: 'modification',
76
+ seq: strandInfo || mod.base,
77
+ modType: type,
78
+ probability: prob,
79
+ });
80
+ coords.push(leftPx, topPx, rightPx, topPx + heightPx);
81
+ pos++;
82
+ });
83
+ return { coords, items };
84
+ }
@@ -1,4 +1,4 @@
1
- import type { LayoutFeature } from './util';
1
+ import type { LayoutFeature } from '../util';
2
2
  import type { Region } from '@jbrowse/core/util';
3
3
  export declare function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorMap, colorContrastMap, charWidth, charHeight, canvasWidth, cigarOps, }: {
4
4
  ctx: CanvasRenderingContext2D;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderPerBaseLettering = renderPerBaseLettering;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const util_2 = require("./util");
5
+ const util_2 = require("../util");
6
6
  function renderPerBaseLettering({ ctx, feat, region, bpPerPx, colorMap, colorContrastMap, charWidth, charHeight, canvasWidth, cigarOps, }) {
7
7
  const heightLim = charHeight - 2;
8
8
  const { feature, topPx, heightPx } = feat;
@@ -1,4 +1,4 @@
1
- import type { LayoutFeature } from './util';
1
+ import type { LayoutFeature } from '../util';
2
2
  import type { Region } from '@jbrowse/core/util';
3
3
  export declare function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, cigarOps, }: {
4
4
  ctx: CanvasRenderingContext2D;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderPerBaseQuality = renderPerBaseQuality;
4
4
  const util_1 = require("@jbrowse/core/util");
5
- const util_2 = require("./util");
5
+ const util_2 = require("../util");
6
6
  function renderPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, cigarOps, }) {
7
7
  const { feature, topPx, heightPx } = feat;
8
8
  const qual = feature.get('qual') || '';
@@ -1,5 +1,5 @@
1
- import type { ProcessedRenderArgs } from './types';
2
- import type { LayoutFeature } from './util';
1
+ import type { ProcessedRenderArgs } from '../types';
2
+ import type { LayoutFeature } from '../util';
3
3
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
4
4
  import type { Theme } from '@mui/material';
5
5
  export declare function renderSoftClipping({ ctx, feat, renderArgs, config, theme, colorMap, canvasWidth, }: {
@@ -3,8 +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
- const util_2 = require("./util");
7
- const MismatchParser_1 = require("../MismatchParser");
6
+ const MismatchParser_1 = require("../../MismatchParser");
7
+ const util_2 = require("../util");
8
8
  function renderSoftClipping({ ctx, feat, renderArgs, config, theme, colorMap, canvasWidth, }) {
9
9
  const { feature, topPx, heightPx } = feat;
10
10
  const { regions, bpPerPx } = renderArgs;
@@ -7,6 +7,12 @@ export interface LayoutFeature {
7
7
  topPx: number;
8
8
  feature: Feature;
9
9
  }
10
+ export interface FlatbushItem {
11
+ type: 'insertion' | 'deletion' | 'mismatch' | 'modification';
12
+ seq: string;
13
+ modType?: string;
14
+ probability?: number;
15
+ }
10
16
  export interface RenderArgsDeserialized extends BoxRenderArgsDeserialized {
11
17
  colorBy?: ColorBy;
12
18
  colorTagMap?: Record<string, string>;
@@ -13,6 +13,7 @@ async function generateCoverageBins({ fetchSequence, features, region, opts, })
13
13
  const bins = [];
14
14
  const start2 = Math.max(0, region.start - 1);
15
15
  const diff = region.start - start2;
16
+ let regionSequence;
16
17
  let start = performance.now();
17
18
  for (const feature of features) {
18
19
  if (performance.now() - start > 400) {
@@ -25,11 +26,11 @@ async function generateCoverageBins({ fetchSequence, features, region, opts, })
25
26
  region,
26
27
  });
27
28
  if ((colorBy === null || colorBy === void 0 ? void 0 : colorBy.type) === 'modifications') {
28
- const regionSequence = (await fetchSequence({
29
+ regionSequence !== null && regionSequence !== void 0 ? regionSequence : (regionSequence = (await fetchSequence({
29
30
  ...region,
30
31
  start: start2,
31
32
  end: region.end + 1,
32
- })) || '';
33
+ })) || '');
33
34
  (0, processModifications_1.processModifications)({
34
35
  feature,
35
36
  colorBy,
@@ -39,11 +40,11 @@ async function generateCoverageBins({ fetchSequence, features, region, opts, })
39
40
  });
40
41
  }
41
42
  else if ((colorBy === null || colorBy === void 0 ? void 0 : colorBy.type) === 'methylation') {
42
- const regionSequence = (await fetchSequence({
43
+ regionSequence !== null && regionSequence !== void 0 ? regionSequence : (regionSequence = (await fetchSequence({
43
44
  ...region,
44
45
  start: start2,
45
46
  end: region.end + 1,
46
- })) || '';
47
+ })) || '');
47
48
  (0, processReferenceCpGs_1.processReferenceCpGs)({
48
49
  feature,
49
50
  bins,
@@ -3,18 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processModifications = processModifications;
4
4
  const util_1 = require("@jbrowse/core/util");
5
5
  const util_2 = require("./util");
6
+ const MismatchParser_1 = require("../MismatchParser");
6
7
  const getMaximumModificationAtEachPosition_1 = require("../shared/getMaximumModificationAtEachPosition");
7
8
  function processModifications({ feature, colorBy, region, bins, regionSequence, }) {
8
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
9
10
  const fstart = feature.get('start');
10
11
  const fstrand = feature.get('strand');
11
12
  const fend = feature.get('end');
12
13
  const twoColor = (_a = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _a === void 0 ? void 0 : _a.twoColor;
13
14
  const isolatedModification = (_b = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _b === void 0 ? void 0 : _b.isolatedModification;
14
- (_c = (0, getMaximumModificationAtEachPosition_1.getMaxProbModAtEachPosition)(feature)) === null || _c === void 0 ? void 0 : _c.forEach(({ allProbs, prob, type }, pos) => {
15
+ const seq = feature.get('seq');
16
+ const modificationThreshold = (_d = (_c = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _c === void 0 ? void 0 : _c.threshold) !== null && _d !== void 0 ? _d : 10;
17
+ const thresholdFraction = modificationThreshold / 100;
18
+ if (!seq) {
19
+ return;
20
+ }
21
+ const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
22
+ (_e = (0, getMaximumModificationAtEachPosition_1.getMaxProbModAtEachPosition)(feature, cigarOps)) === null || _e === void 0 ? void 0 : _e.forEach(({ allProbs, prob, type }, pos) => {
15
23
  if (isolatedModification && type !== isolatedModification) {
16
24
  return;
17
25
  }
26
+ if (prob < thresholdFraction) {
27
+ return;
28
+ }
18
29
  const epos = pos + fstart - region.start;
19
30
  if (epos >= 0 && epos < bins.length && pos + fstart < fend) {
20
31
  if (bins[epos] === undefined) {
@@ -35,9 +46,9 @@ function processModifications({ feature, colorBy, region, bins, regionSequence,
35
46
  noncov: {},
36
47
  };
37
48
  }
38
- const s = 1 - (0, util_1.sum)(allProbs);
39
49
  const bin = bins[epos];
40
50
  bin.refbase = regionSequence[epos];
51
+ const s = 1 - (0, util_1.sum)(allProbs);
41
52
  if (twoColor && s > (0, util_1.max)(allProbs)) {
42
53
  (0, util_2.incWithProbabilities)(bin, fstrand, 'nonmods', `nonmod_${type}`, s);
43
54
  }
@@ -45,6 +56,5 @@ function processModifications({ feature, colorBy, region, bins, regionSequence,
45
56
  (0, util_2.incWithProbabilities)(bin, fstrand, 'mods', `mod_${type}`, prob);
46
57
  }
47
58
  }
48
- pos++;
49
59
  });
50
60
  }
@@ -16,9 +16,26 @@ const complementBase = {
16
16
  T: 'A',
17
17
  };
18
18
  const fudgeFactor = 0.6;
19
+ function calculateModificationCounts({ base, isSimplex, refbase, snps, ref, score0, }) {
20
+ var _a, _b, _c, _d;
21
+ if (base === 'N') {
22
+ return { modifiable: score0, detectable: score0 };
23
+ }
24
+ const cmp = complementBase[base];
25
+ const baseCount = (((_a = snps[base]) === null || _a === void 0 ? void 0 : _a.entryDepth) || 0) + (refbase === base ? ref.entryDepth : 0);
26
+ const complCount = (((_b = snps[cmp]) === null || _b === void 0 ? void 0 : _b.entryDepth) || 0) + (refbase === cmp ? ref.entryDepth : 0);
27
+ const modifiable = baseCount + complCount;
28
+ const detectable = isSimplex
29
+ ? (((_c = snps[base]) === null || _c === void 0 ? void 0 : _c['1']) || 0) +
30
+ (((_d = snps[cmp]) === null || _d === void 0 ? void 0 : _d['-1']) || 0) +
31
+ (refbase === base ? ref['1'] : 0) +
32
+ (refbase === cmp ? ref['-1'] : 0)
33
+ : modifiable;
34
+ return { modifiable, detectable };
35
+ }
19
36
  async function makeImage(ctx, props) {
20
37
  var _a;
21
- const { features, regions, bpPerPx, colorBy, displayCrossHatches, visibleModifications = {}, scaleOpts, height: unadjustedHeight, theme: configTheme, config: cfg, ticks, stopToken, } = props;
38
+ const { features, regions, bpPerPx, colorBy, displayCrossHatches, visibleModifications = {}, simplexModifications = [], scaleOpts, height: unadjustedHeight, theme: configTheme, config: cfg, ticks, stopToken, } = props;
22
39
  const theme = (0, ui_1.createJBrowseTheme)(configTheme);
23
40
  const region = regions[0];
24
41
  const width = (region.end - region.start) / bpPerPx;
@@ -70,8 +87,9 @@ async function makeImage(ctx, props) {
70
87
  const drawingModifications = colorBy.type === 'modifications';
71
88
  const drawingMethylation = colorBy.type === 'methylation';
72
89
  const isolatedModification = (_a = colorBy.modifications) === null || _a === void 0 ? void 0 : _a.isolatedModification;
90
+ const simplexSet = new Set(simplexModifications);
73
91
  (0, util_1.forEachWithStopTokenCheck)(features.values(), stopToken, feature => {
74
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
+ var _a;
75
93
  if (feature.get('type') === 'skip') {
76
94
  return;
77
95
  }
@@ -83,9 +101,10 @@ async function makeImage(ctx, props) {
83
101
  let curr = 0;
84
102
  const refbase = (_a = snpinfo.refbase) === null || _a === void 0 ? void 0 : _a.toUpperCase();
85
103
  const { nonmods, mods, snps, ref } = snpinfo;
86
- for (const m of Object.keys(nonmods).sort().reverse()) {
87
- const mod = visibleModifications[m.replace('nonmod_', '')] ||
88
- visibleModifications[m.replace('mod_', '')];
104
+ const nonmodKeys = Object.keys(nonmods).sort().reverse();
105
+ for (const m of nonmodKeys) {
106
+ const modKey = m.replace(/^(nonmod_|mod_)/, '');
107
+ const mod = visibleModifications[modKey];
89
108
  if (!mod) {
90
109
  console.warn(`${m} not known yet`);
91
110
  continue;
@@ -93,19 +112,14 @@ async function makeImage(ctx, props) {
93
112
  if (isolatedModification && mod.type !== isolatedModification) {
94
113
  continue;
95
114
  }
96
- const cmp = complementBase[mod.base];
97
- const detectable = mod.base === 'N'
98
- ? score0
99
- : (((_b = snps[mod.base]) === null || _b === void 0 ? void 0 : _b.entryDepth) || 0) +
100
- (((_c = snps[cmp]) === null || _c === void 0 ? void 0 : _c.entryDepth) || 0) +
101
- (refbase === mod.base ? ref['1'] : 0) +
102
- (refbase === cmp ? ref['-1'] : 0);
103
- const modifiable = mod.base === 'N'
104
- ? score0
105
- : (((_d = snps[mod.base]) === null || _d === void 0 ? void 0 : _d.entryDepth) || 0) +
106
- (((_e = snps[cmp]) === null || _e === void 0 ? void 0 : _e.entryDepth) || 0) +
107
- (refbase === mod.base ? ref.entryDepth : 0) +
108
- (refbase === cmp ? ref.entryDepth : 0);
115
+ const { modifiable, detectable } = calculateModificationCounts({
116
+ base: mod.base,
117
+ isSimplex: simplexSet.has(mod.type),
118
+ refbase,
119
+ snps,
120
+ ref,
121
+ score0,
122
+ });
109
123
  const { entryDepth, avgProbability = 0 } = snpinfo.nonmods[m];
110
124
  const modFraction = (modifiable / score0) * (entryDepth / detectable);
111
125
  const nonModColor = 'blue';
@@ -116,8 +130,10 @@ async function makeImage(ctx, props) {
116
130
  ctx.fillRect(Math.round(leftPx), bottom - (curr + modFraction * height), w, modFraction * height);
117
131
  curr += modFraction * height;
118
132
  }
119
- for (const m of Object.keys(mods).sort().reverse()) {
120
- const mod = visibleModifications[m.replace('mod_', '')];
133
+ const modKeys = Object.keys(mods).sort().reverse();
134
+ for (const m of modKeys) {
135
+ const modKey = m.replace('mod_', '');
136
+ const mod = visibleModifications[modKey];
121
137
  if (!mod) {
122
138
  console.warn(`${m} not known yet`);
123
139
  continue;
@@ -125,19 +141,14 @@ async function makeImage(ctx, props) {
125
141
  if (isolatedModification && mod.type !== isolatedModification) {
126
142
  continue;
127
143
  }
128
- const cmp = complementBase[mod.base];
129
- const detectable = mod.base === 'N'
130
- ? score0
131
- : (((_f = snps[mod.base]) === null || _f === void 0 ? void 0 : _f.entryDepth) || 0) +
132
- (((_g = snps[cmp]) === null || _g === void 0 ? void 0 : _g.entryDepth) || 0) +
133
- (refbase === mod.base ? ref['1'] : 0) +
134
- (refbase === cmp ? ref['-1'] : 0);
135
- const modifiable = mod.base === 'N'
136
- ? score0
137
- : (((_h = snps[mod.base]) === null || _h === void 0 ? void 0 : _h.entryDepth) || 0) +
138
- (((_j = snps[cmp]) === null || _j === void 0 ? void 0 : _j.entryDepth) || 0) +
139
- (refbase === mod.base ? ref.entryDepth : 0) +
140
- (refbase === cmp ? ref.entryDepth : 0);
144
+ const { modifiable, detectable } = calculateModificationCounts({
145
+ base: mod.base,
146
+ isSimplex: simplexSet.has(mod.type),
147
+ refbase,
148
+ snps,
149
+ ref,
150
+ score0,
151
+ });
141
152
  const { entryDepth, avgProbability = 0 } = mods[m];
142
153
  const modFraction = (modifiable / score0) * (entryDepth / detectable);
143
154
  const baseColor = mod.color || 'black';
@@ -15,6 +15,7 @@ export interface RenderArgsDeserializedWithFeatures extends RenderArgsDeserializ
15
15
  };
16
16
  displayCrossHatches: boolean;
17
17
  visibleModifications?: Record<string, ModificationTypeWithColor>;
18
+ simplexModifications?: string[];
18
19
  statusCallback?: (arg: string) => void;
19
20
  colorBy: ColorBy;
20
21
  }
@@ -0,0 +1,24 @@
1
+ import type { ChainData } from './fetchChains';
2
+ import type { ColorBy, FilterBy } from './types';
3
+ export declare function LinearReadDisplayBaseMixin(): import("mobx-state-tree").IModelType<{
4
+ filterBySetting: import("mobx-state-tree").IType<FilterBy | undefined, FilterBy | undefined, FilterBy | undefined>;
5
+ colorBySetting: import("mobx-state-tree").IType<ColorBy | undefined, ColorBy | undefined, ColorBy | undefined>;
6
+ }, {
7
+ loading: boolean;
8
+ chainData: ChainData | undefined;
9
+ lastDrawnOffsetPx: number | undefined;
10
+ lastDrawnBpPerPx: number;
11
+ ref: HTMLCanvasElement | null;
12
+ } & {
13
+ setLastDrawnOffsetPx(n: number): void;
14
+ setLastDrawnBpPerPx(n: number): void;
15
+ setLoading(f: boolean): void;
16
+ setRef(ref: HTMLCanvasElement | null): void;
17
+ setColorScheme(colorBy: {
18
+ type: string;
19
+ }): void;
20
+ setChainData(args: ChainData): void;
21
+ setFilterBy(filter: FilterBy): void;
22
+ } & {
23
+ readonly drawn: boolean;
24
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;