@teselagen/ove 0.7.27 → 0.7.28

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 (304) hide show
  1. package/AASliver.js +187 -0
  2. package/AddLaddersDialog.js +82 -0
  3. package/AdditionalCutsiteInfoDialog.js +599 -0
  4. package/AlignmentView/Mismatches.d.ts +3 -3
  5. package/AlignmentVisibilityTool.js +105 -0
  6. package/AnnotationContainerHolder.js +20 -0
  7. package/AnnotationPositioner.js +27 -0
  8. package/AutoAnnotate.js +501 -0
  9. package/AutoAnnotateBpMatchingDialog.js +208 -0
  10. package/Axis.js +151 -0
  11. package/AxisNumbers.js +35 -0
  12. package/Browser.js +106 -0
  13. package/Caret.js +63 -0
  14. package/Chromatogram.js +293 -0
  15. package/CircularDnaSequence.js +73 -0
  16. package/CircularView/Labels/index.d.ts +1 -1
  17. package/CircularView/index.d.ts +0 -1
  18. package/CircularZoomMinimap.js +16 -0
  19. package/ColorPicker.js +30 -0
  20. package/CommandHotkeyHandler.js +44 -0
  21. package/CreateAnnotationsPage.d.ts +4 -4
  22. package/CreateAnnotationsPage.js +98 -0
  23. package/Cutsite.js +18 -0
  24. package/CutsiteProperties.js +176 -0
  25. package/CutsiteSelectionLayers.js +47 -0
  26. package/Cutsites.js +271 -0
  27. package/DeletionLayer.js +28 -0
  28. package/DigestTool/Ladder.d.ts +1 -1
  29. package/DropHandler.css +21 -0
  30. package/DropHandler.js +64 -0
  31. package/EditCaretPosition.js +234 -0
  32. package/EditTrackNameDialog.js +30 -0
  33. package/Feature.js +83 -0
  34. package/FeatureProperties.js +6 -0
  35. package/FillWindow.js +47 -0
  36. package/GenbankView.js +74 -0
  37. package/GeneralProperties.js +117 -0
  38. package/GenericAnnotationProperties.js +406 -0
  39. package/GlobalDialog.js +73 -0
  40. package/GlobalDialogUtils.js +110 -0
  41. package/GoToDialog.js +25 -0
  42. package/HorizontalPanelDragHandle.js +35 -0
  43. package/Keyboard.js +85 -0
  44. package/Labels.js +327 -0
  45. package/Ladder.css +20 -0
  46. package/Ladder.js +303 -0
  47. package/MeltingTemp.js +85 -0
  48. package/Menlo.ttf +0 -0
  49. package/Minimap.js +515 -0
  50. package/Mismatches.js +134 -0
  51. package/Monaco.ttf +0 -0
  52. package/MultipleSeqsDetectedOnImportDialog.js +74 -0
  53. package/Orf.js +109 -0
  54. package/OrfProperties.js +117 -0
  55. package/Orfs.js +35 -0
  56. package/PCRTool.js +179 -0
  57. package/PairwiseAlignmentView.js +68 -0
  58. package/Part.js +34 -0
  59. package/PartProperties.js +9 -0
  60. package/PassThrough.js +3 -0
  61. package/PerformantSelectionLayer.js +32 -0
  62. package/PinchHelper.js +24 -0
  63. package/PointedAnnotation.js +347 -0
  64. package/PositionAnnotationOnCircle.js +26 -0
  65. package/Primer.js +41 -0
  66. package/PrimerProperties.js +19 -0
  67. package/Reflex/index.d.ts +0 -1
  68. package/ReflexContainer.js +802 -0
  69. package/ReflexElement.js +160 -0
  70. package/ReflexEvents.js +77 -0
  71. package/ReflexSplitter.js +205 -0
  72. package/RenameSequenceDialog.js +7 -0
  73. package/RotateCircularViewSlider.js +93 -0
  74. package/RowView/index.d.ts +0 -1
  75. package/SelectDialog.js +150 -0
  76. package/SequenceName.js +15 -0
  77. package/SimpleCircularOrLinearView.js +381 -0
  78. package/SimpleOligoPreview.js +39 -0
  79. package/SingleEnzymeCutsiteInfo.js +139 -0
  80. package/ToolBar/ToolbarItem.d.ts +1 -3
  81. package/ToolbarItem.js +192 -0
  82. package/Translation.js +198 -0
  83. package/TranslationProperties.js +149 -0
  84. package/UncontrolledSliderWithPlusMinusBtns.css +5 -0
  85. package/UncontrolledSliderWithPlusMinusBtns.js +134 -0
  86. package/VeTopRightContainer.js +12 -0
  87. package/ZoomCircularViewSlider.js +62 -0
  88. package/ZoomLinearView.js +47 -0
  89. package/addAlignment.js +6 -0
  90. package/addMetaToActionCreators.js +12 -0
  91. package/addWrappedAddons.js +20 -0
  92. package/alignmentTool.js +503 -0
  93. package/alignments.js +379 -0
  94. package/annotationLabelVisibility.js +2 -0
  95. package/annotationSearchSelector.js +24 -0
  96. package/annotationTypes.js +35 -0
  97. package/annotationVisibility.js +196 -0
  98. package/annotationsToSupport.js +104 -0
  99. package/arrayToObjWithIds.js +17 -0
  100. package/arrayUtils.js +19 -0
  101. package/array_move.js +10 -0
  102. package/calculateTickMarkPositionsForGivenRange.js +47 -0
  103. package/caretPosition.js +27 -0
  104. package/cdsFeaturesSelector.js +9 -0
  105. package/charWidth.js +22 -0
  106. package/circular.js +19 -0
  107. package/circularSelector.js +4 -0
  108. package/clickAndDragUtils.js +576 -0
  109. package/coerceInitialValue.js +7 -0
  110. package/combineReducersDontIgnoreKeys.js +12 -0
  111. package/commandUtils.js +20 -0
  112. package/constants.js +2 -0
  113. package/copyOptions.js +34 -0
  114. package/createFragmentLines.js +120 -0
  115. package/createMergedDefaultStateReducer.js +30 -0
  116. package/createMetaAction.js +12 -0
  117. package/createSequenceInputPopup.js +290 -0
  118. package/createSequenceInputPopupStyle.css +87 -0
  119. package/createSimpleDialog.js +89 -0
  120. package/createYourOwnEnzyme.js +39 -0
  121. package/cutsiteLabelColorSelector.js +6 -0
  122. package/cutsiteTool.js +88 -0
  123. package/cutsitesByRangeSelector.js +5 -0
  124. package/cutsitesSelector.js +61 -0
  125. package/darkmode.css +98 -0
  126. package/defaultConfig.js +150 -0
  127. package/deletionLayers.js +36 -0
  128. package/description.js +21 -0
  129. package/digestTool.js +34 -0
  130. package/dnaToColor.js +17 -0
  131. package/downloadTool.js +39 -0
  132. package/draggableClassnames.js +5 -0
  133. package/drawAnnotations.js +440 -0
  134. package/drawDirectedPiePiece.js +142 -0
  135. package/editTool.js +49 -0
  136. package/editorSelector.js +2 -0
  137. package/editorUtils.js +205 -0
  138. package/estimateRowHeight.js +184 -0
  139. package/featureLengthsToHide.js +27 -0
  140. package/featureTool.js +34 -0
  141. package/features.js +19 -0
  142. package/featuresSelector.js +8 -0
  143. package/filteredCutsitesSelector.js +136 -0
  144. package/filteredFeaturesSelector.js +32 -0
  145. package/filteredPartsSelector.js +57 -0
  146. package/filteredPrimersSelector.js +27 -0
  147. package/filteredRestrictionEnzymesSelector.js +1 -0
  148. package/find.png +0 -0
  149. package/findTool.js +79 -0
  150. package/findToolConstants.js +1 -0
  151. package/frameTranslations.js +52 -0
  152. package/fullscreen.png +0 -0
  153. package/getAdditionalEnzymesSelector.js +46 -0
  154. package/getAngleForPositionMidpoint.js +3 -0
  155. package/getAnnotationClassnames.js +12 -0
  156. package/getAnnotationNameAndStartStopString.js +61 -0
  157. package/getBpsPerRow.js +19 -0
  158. package/getCutsiteLabelHeights.js +56 -0
  159. package/getGapMap.js +12 -0
  160. package/getGaps.js +27 -0
  161. package/getInternalLabel.js +40 -0
  162. package/getOveHotkeyDefs.js +12 -0
  163. package/getPairwiseOverviewLinearViewOptions.js +38 -0
  164. package/getRangeAnglesSpecial.js +12 -0
  165. package/getStructuredBases.js +97 -0
  166. package/getTrackFromEvent.js +25 -0
  167. package/getVisibleStartEnd.js +7 -0
  168. package/getXStartAndWidthFromNonCircularRange.js +12 -0
  169. package/getXStartAndWidthOfRangeWrtRow.js +27 -0
  170. package/getXStartAndWidthOfRowAnnotation.js +19 -0
  171. package/getYOffset.js +15 -0
  172. package/hoveredAnnotation.js +24 -0
  173. package/{html2canvas.esm--JN4fLQL.js → html2canvas.esm-DiGWN1gP.js} +187 -229
  174. package/{html2canvas.esm-B7d7VJmQ.cjs → html2canvas.esm-J1esNpMJ.cjs} +187 -229
  175. package/importTool.js +27 -0
  176. package/index.cjs.js +48165 -47142
  177. package/index.es.js +47699 -46676
  178. package/index.js +71 -0
  179. package/inlineFindTool.js +38 -0
  180. package/isElementInViewport.js +29 -0
  181. package/isEnzymeFilterAndSelector.js +1 -0
  182. package/isTargetWithinEl.js +6 -0
  183. package/labelLineIntensity.js +25 -0
  184. package/labelSize.js +23 -0
  185. package/ladderDefaults.js +25 -0
  186. package/lastSavedId.js +20 -0
  187. package/lineageLines.js +11 -0
  188. package/linear.png +0 -0
  189. package/makeStore.js +34 -0
  190. package/massageTickSpacing.js +19 -0
  191. package/materiallyAvailable.js +19 -0
  192. package/middleware.js +112 -0
  193. package/minimumOrfSize.js +24 -0
  194. package/minimumOrfSizeSelector.js +2 -0
  195. package/modalActions.js +3 -0
  196. package/moveCaret.js +58 -0
  197. package/name.js +19 -0
  198. package/normalizeAngle.js +3 -0
  199. package/normalizeAngleRange.js +9 -0
  200. package/oligoTool.js +30 -0
  201. package/onlyUpdateForKeysDeep.js +31 -0
  202. package/orfFrameToColorMap.js +10 -0
  203. package/orfTool.js +136 -0
  204. package/orfsSelector.js +15 -0
  205. package/ove.css +12107 -0
  206. package/package.json +6 -5
  207. package/panelsShown.js +294 -0
  208. package/partLengthsToHide.js +23 -0
  209. package/partOverhangs.js +6 -0
  210. package/partTagSearch.js +69 -0
  211. package/partTool.js +45 -0
  212. package/parts.js +19 -0
  213. package/partsSelector.js +8 -0
  214. package/pie.png +0 -0
  215. package/polarToSpecialCartesian.js +7 -0
  216. package/positionCutsites.js +6 -0
  217. package/prepareRowData.js +64 -0
  218. package/primerBases.js +221 -0
  219. package/primerLengthsToHide.js +27 -0
  220. package/primers.js +19 -0
  221. package/primersSelector.js +8 -0
  222. package/print.png +0 -0
  223. package/printTool.js +31 -0
  224. package/propertiesTool.js +40 -0
  225. package/proteinUtils.js +3 -0
  226. package/pureNoFunc.js +18 -0
  227. package/readOnly.js +25 -0
  228. package/redoTool.js +30 -0
  229. package/reflex-styles.css +128 -0
  230. package/reflex-styles.css.map +9 -0
  231. package/relaxLabelAngles.js +157 -0
  232. package/relaxLabels_DEPRECATED.js +105 -0
  233. package/replacementLayers.js +36 -0
  234. package/restrictionEnzymes.js +52 -0
  235. package/restrictionEnzymesSelector.js +34 -0
  236. package/rowviewContants.js +3 -0
  237. package/ruler.css +89 -0
  238. package/save.png +0 -0
  239. package/saveTool.js +44 -0
  240. package/searchLayersSelector.js +71 -0
  241. package/selectedAnnotations.js +89 -0
  242. package/selectedAnnotationsSelector.js +1 -0
  243. package/selectedCutsitesSelector.js +21 -0
  244. package/selectedPartTags.js +21 -0
  245. package/selectionLayer.js +25 -0
  246. package/selectors/annotationSearchSelector.d.ts +1 -1
  247. package/sequence.js +12 -0
  248. package/sequenceDataHistory.js +43 -0
  249. package/sequenceDataSelector.js +2 -0
  250. package/sequenceLengthSelector.js +5 -0
  251. package/sequenceSelector.js +4 -0
  252. package/sharedActionCreators.js +0 -0
  253. package/shouldFlipText.js +4 -0
  254. package/shouldRerender.js +27 -0
  255. package/showFileDialog.js +25 -0
  256. package/showGCContent.js +23 -0
  257. package/show_cut_sites.png +0 -0
  258. package/show_features.png +0 -0
  259. package/show_orfs.png +0 -0
  260. package/show_primers.png +0 -0
  261. package/simpleDialog.css +13 -0
  262. package/specialCutsiteFilterOptions.js +22 -0
  263. package/src/Editor/DropHandler.js +2 -1
  264. package/src/Editor/index.js +0 -2
  265. package/src/RowItem/StackedAnnotations/getStructuredBases.js +20 -6
  266. package/src/ToolBar/cutsiteTool.js +1 -1
  267. package/src/helperComponents/PropertiesDialog/TranslationProperties.js +2 -1
  268. package/style.css +3 -12100
  269. package/tagsToBoldSelector.js +2 -0
  270. package/toggle_views.svg +1 -0
  271. package/toolBar.js +23 -0
  272. package/translationSearchMatchesSelector.js +14 -0
  273. package/translations.js +20 -0
  274. package/translationsRawSelector.js +8 -0
  275. package/translationsSelector.js +137 -0
  276. package/typeField.js +24 -0
  277. package/undoTool.js +30 -0
  278. package/updateEditor.d.ts +1 -3
  279. package/updateEditor.js +200 -0
  280. package/updateLabelsForInViewFeatures.js +55 -0
  281. package/updateLabelsForInViewFeaturesCircView.js +41 -0
  282. package/updateTrackHelper.js +58 -0
  283. package/uppercaseSequenceMapFont.js +25 -0
  284. package/upsertDeleteActionGenerator.js +31 -0
  285. package/useAAColorType.js +8 -0
  286. package/useAdditionalOrfStartCodons.js +24 -0
  287. package/useAnnotationLimits.js +42 -0
  288. package/useChromatogramPrefs.js +31 -0
  289. package/useFormValue.js +7 -0
  290. package/useLadders.js +6 -0
  291. package/useMeltingTemp.js +7 -0
  292. package/useTmType.js +10 -0
  293. package/userDefinedHandlersAndOpts.js +61 -0
  294. package/utils/getAnnotationNameAndStartStopString.d.ts +1 -5
  295. package/utils/selectionLayer.d.ts +2 -2
  296. package/utils.js +37 -0
  297. package/versionHistory.js +26 -0
  298. package/versionHistoryTool.js +21 -0
  299. package/viewSubmenu.js +479 -0
  300. package/visibilityTool.js +39 -0
  301. package/withEditorInteractions/getBpsPerRow.d.ts +1 -3
  302. package/withHover.js +113 -0
  303. package/withRestrictionEnzymes.js +15 -0
  304. package/index.umd.js +0 -188322
package/alignments.js ADDED
@@ -0,0 +1,379 @@
1
+ import {
2
+ tidyUpSequenceData /* generateSequenceData */,
3
+ condensePairwiseAlignmentDifferences
4
+ } from "@teselagen/sequence-utils";
5
+ import { convertBasePosTraceToPerBpTrace } from "@teselagen/bio-parsers";
6
+ import shortid from "shortid";
7
+
8
+ import addDashesForMatchStartAndEndForTracks from "./utils/addDashesForMatchStartAndEndForTracks";
9
+
10
+ import { /* createReducer, */ createAction } from "redux-act";
11
+ import { omit } from "lodash-es";
12
+
13
+ const alignmentAnnotationSettings = {
14
+ axis: true,
15
+ axisNumbers: true,
16
+ chromatogram: false,
17
+ dnaColors: false,
18
+ features: false,
19
+ parts: false,
20
+ reverseSequence: false,
21
+ sequence: true,
22
+ translations: true,
23
+ orfs: false,
24
+ orfTranslations: false,
25
+ cdsFeatureTranslations: false,
26
+ cutsites: false,
27
+ primers: false,
28
+ compactNames: false
29
+ };
30
+
31
+ const defaultVisibilities = {
32
+ alignmentAnnotationVisibility: alignmentAnnotationSettings,
33
+ pairwise_alignmentAnnotationVisibility: alignmentAnnotationSettings,
34
+ alignmentAnnotationLabelVisibility: {
35
+ features: false,
36
+ parts: false,
37
+ cutsites: false
38
+ },
39
+ pairwise_alignmentAnnotationLabelVisibility: {
40
+ features: false,
41
+ parts: false,
42
+ cutsites: false
43
+ }
44
+ };
45
+ const defaultVisibilityTypes = Object.keys(defaultVisibilities);
46
+
47
+ try {
48
+ defaultVisibilityTypes.forEach(type => {
49
+ const newVal = JSON.parse(window.localStorage.getItem(type));
50
+ if (newVal)
51
+ defaultVisibilities[type] = {
52
+ ...defaultVisibilities[type],
53
+ ...newVal
54
+ };
55
+ });
56
+ } catch (e) {
57
+ console.error("error setting localstorage visibility config", e);
58
+ }
59
+
60
+ // ------------------------------------
61
+ // Actions
62
+ // ------------------------------------
63
+ export const upsertAlignmentRun = createAction("UPSERT_ALIGNMENT_RUN");
64
+ export const removeAlignmentFromRedux = createAction(
65
+ "REMOVE_ALIGNMENT_FROM_REDUX"
66
+ );
67
+ export const updateAlignmentViewVisibility = createAction(
68
+ "UPDATE_ALIGNMENT_VIEW_VISIBILITY"
69
+ );
70
+ export const alignmentRunUpdate = createAction("ALIGNMENT_RUN_UPDATE");
71
+
72
+ const highlightRangeProps = {
73
+ color: "red",
74
+ hideCarets: true,
75
+ ignoreGaps: true
76
+ };
77
+ function addHighlightedDifferences(alignmentTracks) {
78
+ return alignmentTracks.map(track => {
79
+ if (track.isUnmapped) {
80
+ return track;
81
+ }
82
+ const sequenceData = tidyUpSequenceData(track.sequenceData, {
83
+ doNotRemoveInvalidChars: true
84
+ });
85
+ const matchHighlightRanges = getRangeMatchesBetweenTemplateAndNonTemplate(
86
+ alignmentTracks[0].alignmentData.sequence,
87
+ track.alignmentData.sequence
88
+ );
89
+ // .filter by the user-specified mismatch overrides (initially [])
90
+ const mismatches = matchHighlightRanges.filter(({ isMatch }) => !isMatch);
91
+ return {
92
+ ...track,
93
+ sequenceData,
94
+ matchHighlightRanges,
95
+ additionalSelectionLayers: matchHighlightRanges
96
+ .filter(({ isMatch }) => !isMatch)
97
+ .map(range => {
98
+ return { ...range, ...highlightRangeProps };
99
+ }),
100
+ mismatches
101
+ };
102
+ });
103
+ }
104
+
105
+ // alignmentTracks = addHighlightedDifferences(alignmentTracks);
106
+
107
+ // ------------------------------------
108
+ // Reducer
109
+ // ------------------------------------
110
+
111
+ export default (state = {}, { payload = {}, type }) => {
112
+ if (type === "ALIGNMENT_RUN_UPDATE") {
113
+ const { alignmentId } = payload;
114
+ const newState = {
115
+ ...state,
116
+ [alignmentId]: {
117
+ ...state[alignmentId],
118
+ ...payload
119
+ }
120
+ };
121
+ return newState;
122
+ }
123
+
124
+ if (type === "UPDATE_ALIGNMENT_VIEW_VISIBILITY") {
125
+ defaultVisibilityTypes.forEach(type => {
126
+ if (
127
+ (type.startsWith("pairwise_") && payload.pairwiseAlignments) ||
128
+ (!type.startsWith("pairwise_") && !payload.pairwiseAlignments)
129
+ ) {
130
+ defaultVisibilities[type] = {
131
+ ...defaultVisibilities[type],
132
+ ...payload[type.replace("pairwise_", "")]
133
+ };
134
+
135
+ localStorage.setItem(
136
+ type,
137
+ JSON.stringify({
138
+ ...defaultVisibilities[type],
139
+ ...payload[type.replace("pairwise_", "")]
140
+ })
141
+ );
142
+ }
143
+ });
144
+ return {
145
+ ...state,
146
+ [payload.id]: { ...payload }
147
+ };
148
+ }
149
+ if (type === "UPSERT_ALIGNMENT_RUN") {
150
+ const { id } = payload;
151
+ const payloadToUse = {
152
+ stateTrackingId: state[id]?.stateTrackingId ? shortid() : "initialLoadId",
153
+ alignmentType: state[id]?.alignmentType,
154
+ ...payload,
155
+ //assign default visibilities
156
+ ...defaultVisibilityTypes.reduce((acc, type) => {
157
+ if (
158
+ (type.startsWith("pairwise_") && payload.pairwiseAlignments) ||
159
+ (!type.startsWith("pairwise_") && !payload.pairwiseAlignments)
160
+ ) {
161
+ acc[type.replace("pairwise_", "")] = {
162
+ ...defaultVisibilities[type],
163
+ ...payload[type.replace("pairwise_", "")]
164
+ };
165
+ }
166
+ return acc;
167
+ }, {})
168
+ };
169
+ if (payloadToUse.pairwiseAlignments) {
170
+ if (
171
+ payloadToUse.pairwiseAlignments[0][0].alignmentData.matchStart !==
172
+ undefined
173
+ ) {
174
+ payloadToUse.pairwiseAlignments = payloadToUse.pairwiseAlignments.map(
175
+ addDashesForMatchStartAndEndForTracks
176
+ );
177
+ }
178
+ const templateSeq = payloadToUse.pairwiseAlignments[0][0];
179
+ //we need to get all of the sequences in a single alignment (turning inserts into single BP red highlights)
180
+ const pairwiseOverviewAlignmentTracks = [
181
+ {
182
+ //add the template seq as the first track in the Pairwise Alignment Overview
183
+ ...templateSeq,
184
+ sequenceData: tidyUpSequenceData(templateSeq.sequenceData, {
185
+ doNotRemoveInvalidChars: true
186
+ }),
187
+ alignmentData: { sequence: templateSeq.sequenceData.sequence } //remove the gaps from the template sequence
188
+ }
189
+ ]; // start with just the template seq in there!
190
+
191
+ payloadToUse.pairwiseAlignments.forEach(([template, alignedSeq]) => {
192
+ const condensedSeq = condensePairwiseAlignmentDifferences(
193
+ template.alignmentData.sequence,
194
+ alignedSeq.alignmentData.sequence
195
+ );
196
+ let re = /r+/gi;
197
+ let match;
198
+ const additionalSelectionLayers = [];
199
+ while ((match = re.exec(condensedSeq)) != null) {
200
+ additionalSelectionLayers.push({
201
+ start: match.index,
202
+ end: match.index + match[0].length - 1,
203
+ ...highlightRangeProps
204
+ });
205
+ }
206
+ re = /g+/gi;
207
+ // let match;
208
+ while ((match = re.exec(condensedSeq)) != null) {
209
+ additionalSelectionLayers.push({
210
+ start: match.index,
211
+ end: match.index + match[0].length - 1,
212
+ ...highlightRangeProps,
213
+ color: "grey"
214
+ });
215
+ }
216
+
217
+ const alignedSeqMinusInserts = {
218
+ ...alignedSeq,
219
+ sequenceData: {
220
+ ...tidyUpSequenceData(alignedSeq.sequenceData, {
221
+ doNotRemoveInvalidChars: true
222
+ }),
223
+ sequence: template.sequenceData.sequence
224
+ },
225
+ additionalSelectionLayers,
226
+ alignmentData: {
227
+ sequence: condensedSeq
228
+ }
229
+ };
230
+ pairwiseOverviewAlignmentTracks.push(alignedSeqMinusInserts);
231
+ });
232
+ payloadToUse.pairwiseOverviewAlignmentTracks =
233
+ pairwiseOverviewAlignmentTracks;
234
+ payloadToUse.pairwiseAlignments = payloadToUse.pairwiseAlignments.map(
235
+ addHighlightedDifferences
236
+ );
237
+ }
238
+ if (payloadToUse.alignmentTracks) {
239
+ payloadToUse.alignmentTracks = addHighlightedDifferences(
240
+ payloadToUse.alignmentTracks
241
+ );
242
+ }
243
+ //check for issues
244
+ let hasError = checkForIssues(
245
+ payloadToUse.alignmentTracks,
246
+ payload.alignmentType
247
+ );
248
+ (payloadToUse.pairwiseAlignments || []).forEach(alignment => {
249
+ const error = alignment;
250
+ if (error) {
251
+ hasError = error;
252
+ }
253
+ });
254
+ return {
255
+ ...state,
256
+ [payload.id]: {
257
+ ...payloadToUse,
258
+ hasError
259
+ }
260
+ };
261
+ }
262
+ if (type === "REMOVE_ALIGNMENT_FROM_REDUX") {
263
+ const { id } = payload;
264
+ state = omit(state, [id]);
265
+ }
266
+ return state;
267
+ };
268
+
269
+ //returns an array like so: [{start: 0, end: 4, isMatch: false}, {start,end,isMatch} ... etc]
270
+ function getRangeMatchesBetweenTemplateAndNonTemplate(tempSeq, nonTempSeq) {
271
+ //assume all sequences are the same length (with gap characters "-" in some places)
272
+ //loop through all non template sequences and compare them with the template
273
+
274
+ const seqLength = nonTempSeq.length;
275
+ const ranges = [];
276
+ // const startIndex = "".match/[-]/ Math.max(0, .indexOf("-"));
277
+ const nonTempSeqWithoutLeadingDashes = nonTempSeq.replace(/^-+/g, "");
278
+ const nonTempSeqWithoutTrailingDashes = nonTempSeq.replace(/-+$/g, "");
279
+
280
+ const startIndex = seqLength - nonTempSeqWithoutLeadingDashes.length;
281
+ const endIndex =
282
+ seqLength - (seqLength - nonTempSeqWithoutTrailingDashes.length);
283
+ for (let index = startIndex; index < endIndex; index++) {
284
+ const isMatch =
285
+ tempSeq[index].toLowerCase() === nonTempSeq[index].toLowerCase();
286
+ const previousRange = ranges[ranges.length - 1];
287
+ if (previousRange) {
288
+ if (previousRange.isMatch === isMatch) {
289
+ previousRange.end++;
290
+ } else {
291
+ ranges.push({
292
+ start: index,
293
+ end: index,
294
+ isMatch
295
+ });
296
+ }
297
+ } else {
298
+ ranges.push({
299
+ start: startIndex,
300
+ end: startIndex,
301
+ isMatch
302
+ });
303
+ }
304
+ }
305
+ return ranges;
306
+ }
307
+
308
+ function checkForIssues(alignmentTracks, alignmentType) {
309
+ if (
310
+ !alignmentTracks ||
311
+ !alignmentTracks[0] ||
312
+ !alignmentTracks[0].alignmentData
313
+ ) {
314
+ return;
315
+ }
316
+
317
+ const alignmentTrackLength = alignmentTracks[0].alignmentData.sequence.length;
318
+ let hasError;
319
+ alignmentTracks.some(track => {
320
+ if (track.alignmentData.sequence.length !== alignmentTrackLength) {
321
+ console.error("incorrect length", alignmentTracks);
322
+
323
+ return "incorrect length";
324
+ }
325
+ if (
326
+ track.chromatogramData &&
327
+ track.sequenceData.sequence.length !==
328
+ track.chromatogramData.baseCalls.length
329
+ ) {
330
+ console.error("incorrect chromatogram length", alignmentTracks);
331
+
332
+ return "incorrect chromatogram length";
333
+ }
334
+ if (track.chromatogramData && !track.chromatogramData.baseTraces) {
335
+ if (!track.chromatogramData.basePos) {
336
+ console.error("corrupted chromatogram data", alignmentTracks);
337
+ return "corrupted chromatogram data";
338
+ }
339
+ track.chromatogramData = convertBasePosTraceToPerBpTrace(
340
+ track.chromatogramData
341
+ );
342
+ }
343
+ if (
344
+ alignmentType !== "Parallel Part Creation" &&
345
+ track.sequenceData.sequence.length !==
346
+ track.alignmentData.sequence.replace(/-/g, "").length
347
+ ) {
348
+ console.error(
349
+ "sequence data length does not match alignment data w/o gaps"
350
+ );
351
+ console.error(
352
+ "track.sequenceData.sequence:",
353
+ track.sequenceData.sequence
354
+ );
355
+ console.error(
356
+ "track.sequenceData.sequence.length:",
357
+ track.sequenceData.sequence.length
358
+ );
359
+ console.error(
360
+ "track.alignmentData.sequence:",
361
+ track.alignmentData.sequence
362
+ );
363
+ console.error(
364
+ 'track.alignmentData.sequence.replace(/-/g,""):',
365
+ track.alignmentData.sequence.replace(/-/g, "")
366
+ );
367
+ console.error(
368
+ 'track.alignmentData.sequence.replace(/-/g,"").length:',
369
+ track.alignmentData.sequence.replace(/-/g, "").length
370
+ );
371
+ hasError = "sequence data length does not match alignment data w/o gaps";
372
+ return true;
373
+ }
374
+ return false;
375
+ });
376
+ if (hasError) {
377
+ return hasError;
378
+ }
379
+ }
@@ -0,0 +1,2 @@
1
+ const sequenceDataSelector = state => state.sequenceData;
2
+ export default sequenceDataSelector;
@@ -0,0 +1,24 @@
1
+ import { createSelector } from "reselect";
2
+ import { filter } from "lodash-es";
3
+ export const searchableTypes = ["parts", "features", "primers"];
4
+
5
+ function annotationSearchSelector(isOpen, searchString, ...rest) {
6
+ if (!searchString || !isOpen) {
7
+ return [];
8
+ }
9
+ return searchableTypes.map((type, i) => {
10
+ const annotations = rest[i];
11
+ return filter(annotations, ann =>
12
+ ann.name
13
+ .toLowerCase()
14
+ .includes(searchString ? searchString.toLowerCase() : "")
15
+ );
16
+ });
17
+ }
18
+
19
+ export default createSelector(
20
+ state => state.findTool && state.findTool.isOpen,
21
+ state => state.findTool && state.findTool.searchText,
22
+ ...searchableTypes.map(type => state => state.sequenceData[type]),
23
+ annotationSearchSelector
24
+ );
@@ -0,0 +1,35 @@
1
+ export const userDefinedTypes = [
2
+ "parts",
3
+ "features",
4
+ "translations",
5
+ "primers"
6
+ ];
7
+
8
+ export const userDefinedTypesMap = userDefinedTypes.reduce(function (
9
+ nextVal,
10
+ key
11
+ ) {
12
+ nextVal[key] = key;
13
+ return nextVal;
14
+ // looks like this:
15
+ //{
16
+ // parts: 'parts',
17
+ // features: 'features',
18
+ // translations: 'translations',
19
+ // primers: 'primers',
20
+ // }
21
+ }, {});
22
+
23
+ export const derivedDataTypes = ["cutsites", "orfs"];
24
+ export const derivedDataTypesMap = derivedDataTypes.reduce(function (
25
+ nextVal,
26
+ key
27
+ ) {
28
+ nextVal[key] = key;
29
+ return nextVal;
30
+ }, {});
31
+ export function getSingular(type) {
32
+ return type.slice(0, -1);
33
+ }
34
+
35
+ export const allTypes = [...userDefinedTypes, ...derivedDataTypes];
@@ -0,0 +1,196 @@
1
+ import { omit } from "lodash-es";
2
+
3
+ //./caretPosition.js
4
+
5
+ import createAction from "./utils/createMetaAction";
6
+ import createMergedDefaultStateReducer from "./utils/createMergedDefaultStateReducer";
7
+
8
+ export const visibilityDefaultValues = {
9
+ featureTypesToHide: {},
10
+ featureIndividualToHide: {},
11
+ partIndividualToHide: {},
12
+ primerIndividualToHide: {},
13
+ features: true,
14
+ warnings: true,
15
+ assemblyPieces: true,
16
+ chromatogram: true,
17
+ lineageAnnotations: true,
18
+ translations: true,
19
+ parts: true,
20
+ orfs: false,
21
+ orfTranslations: false,
22
+ cdsFeatureTranslations: true,
23
+ axis: true,
24
+ cutsites: true,
25
+ // cutsites: true,
26
+ cutsitesInSequence: true,
27
+ primers: true,
28
+ dnaColors: false,
29
+ sequence: true,
30
+ reverseSequence: true,
31
+ fivePrimeThreePrimeHints: true,
32
+ axisNumbers: true
33
+ };
34
+
35
+ // ------------------------------------
36
+ // Actions
37
+ // ------------------------------------
38
+ export const annotationVisibilityToggle = createAction(
39
+ "annotationVisibilityToggle"
40
+ );
41
+ //eg: annotationVisibilityToggle('features')
42
+ export const annotationVisibilityHide = createAction(
43
+ "annotationVisibilityHide"
44
+ );
45
+ export const annotationVisibilityShow = createAction(
46
+ "annotationVisibilityShow"
47
+ );
48
+ export const hideFeatureTypes = createAction("hideFeatureTypes");
49
+ export const showFeatureTypes = createAction("showFeatureTypes");
50
+ export const resetFeatureTypesToHide = createAction("resetFeatureTypesToHide");
51
+ export const hideFeatureIndividual = createAction("hideFeatureIndividual");
52
+ export const showFeatureIndividual = createAction("showFeatureIndividual");
53
+ export const resetFeatureIndividualToHide = createAction(
54
+ "resetFeatureIndividualToHide"
55
+ );
56
+ export const hidePrimerIndividual = createAction("hidePrimerIndividual");
57
+ export const showPrimerIndividual = createAction("showPrimerIndividual");
58
+ export const resetPrimerIndividualToHide = createAction(
59
+ "resetPrimerIndividualToHide"
60
+ );
61
+ export const hidePartIndividual = createAction("hidePartIndividual");
62
+ export const showPartIndividual = createAction("showPartIndividual");
63
+ export const resetPartIndividualToHide = createAction(
64
+ "resetPartIndividualToHide"
65
+ );
66
+
67
+ // ------------------------------------
68
+ // Reducer
69
+ // ------------------------------------
70
+ const annotationVisibility = createMergedDefaultStateReducer(
71
+ {
72
+ [resetPartIndividualToHide]: state => {
73
+ return {
74
+ ...state,
75
+ partIndividualToHide: {}
76
+ };
77
+ },
78
+ [showPartIndividual]: (state, payload) => {
79
+ return {
80
+ ...state,
81
+ parts: true,
82
+ partIndividualToHide: omit(state.partIndividualToHide, payload)
83
+ };
84
+ },
85
+ [hidePartIndividual]: (state, payload) => {
86
+ return {
87
+ ...state,
88
+ partIndividualToHide: {
89
+ ...state.partIndividualToHide,
90
+ ...payload.reduce((acc, key) => {
91
+ acc[key] = true;
92
+ return acc;
93
+ }, {})
94
+ }
95
+ };
96
+ },
97
+ [resetFeatureIndividualToHide]: state => {
98
+ return {
99
+ ...state,
100
+ featureIndividualToHide: {}
101
+ };
102
+ },
103
+ [showFeatureIndividual]: (state, payload) => {
104
+ return {
105
+ ...state,
106
+ features: true,
107
+ featureIndividualToHide: omit(state.featureIndividualToHide, payload)
108
+ };
109
+ },
110
+ [hideFeatureIndividual]: (state, payload) => {
111
+ return {
112
+ ...state,
113
+ featureIndividualToHide: {
114
+ ...state.featureIndividualToHide,
115
+ ...payload.reduce((acc, key) => {
116
+ acc[key] = true;
117
+ return acc;
118
+ }, {})
119
+ }
120
+ };
121
+ },
122
+ [resetPrimerIndividualToHide]: state => {
123
+ return {
124
+ ...state,
125
+ primerIndividualToHide: {}
126
+ };
127
+ },
128
+ [showPrimerIndividual]: (state, payload) => {
129
+ return {
130
+ ...state,
131
+ primers: true,
132
+ primerIndividualToHide: omit(state.primerIndividualToHide, payload)
133
+ };
134
+ },
135
+ [hidePrimerIndividual]: (state, payload) => {
136
+ return {
137
+ ...state,
138
+ primerIndividualToHide: {
139
+ ...state.primerIndividualToHide,
140
+ ...payload.reduce((acc, key) => {
141
+ acc[key] = true;
142
+ return acc;
143
+ }, {})
144
+ }
145
+ };
146
+ },
147
+ [resetFeatureTypesToHide]: state => {
148
+ return {
149
+ ...state,
150
+ featureTypesToHide: {}
151
+ };
152
+ },
153
+ [showFeatureTypes]: (state, payload) => {
154
+ return {
155
+ ...state,
156
+ featureTypesToHide: omit(state.featureTypesToHide, payload)
157
+ };
158
+ },
159
+ [hideFeatureTypes]: (state, payload) => {
160
+ return {
161
+ ...state,
162
+ featureTypesToHide: {
163
+ ...state.featureTypesToHide,
164
+ ...payload.reduce((acc, key) => {
165
+ acc[key] = true;
166
+ return acc;
167
+ }, {})
168
+ }
169
+ };
170
+ },
171
+ [annotationVisibilityToggle]: (state, payload) => {
172
+ return {
173
+ ...state,
174
+ [payload]: !state[payload],
175
+ ...(payload === "orfs" && state.orfs === state.orfTranslations
176
+ ? { orfTranslations: !state.orfTranslations }
177
+ : null)
178
+ };
179
+ },
180
+ [annotationVisibilityHide]: (state, payload) => {
181
+ return {
182
+ ...state,
183
+ [payload]: false
184
+ };
185
+ },
186
+ [annotationVisibilityShow]: (state, payload) => {
187
+ return {
188
+ ...state,
189
+ [payload]: true
190
+ };
191
+ }
192
+ },
193
+ visibilityDefaultValues
194
+ );
195
+
196
+ export default annotationVisibility;