@teselagen/sequence-utils 0.3.38-beta.2 → 0.3.41

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 (169) hide show
  1. package/DNAComplementMap.d.ts +1 -1
  2. package/addGapsToSeqReads.d.ts +3 -16
  3. package/adjustAnnotationsToInsert.d.ts +1 -2
  4. package/adjustBpsToReplaceOrInsert.d.ts +1 -2
  5. package/aliasedEnzymesByName.d.ts +1 -37
  6. package/aminoAcidToDegenerateDnaMap.d.ts +31 -1
  7. package/aminoAcidToDegenerateRnaMap.d.ts +1 -1
  8. package/annotateSingleSeq.d.ts +4 -5
  9. package/annotationTypes.d.ts +2 -2
  10. package/autoAnnotate.d.ts +8 -17
  11. package/bioData.d.ts +58 -10
  12. package/calculateEndStability.d.ts +1 -1
  13. package/calculateNebTa.d.ts +1 -6
  14. package/calculateNebTm.d.ts +4 -6
  15. package/calculatePercentGC.d.ts +1 -1
  16. package/calculateSantaLuciaTm.d.ts +114 -28
  17. package/calculateTm.d.ts +1 -13
  18. package/computeDigestFragments.d.ts +24 -30
  19. package/condensePairwiseAlignmentDifferences.d.ts +1 -1
  20. package/convertAACaretPositionOrRangeToDna.d.ts +1 -2
  21. package/convertDnaCaretPositionOrRangeToAA.d.ts +1 -2
  22. package/cutSequenceByRestrictionEnzyme.d.ts +1 -2
  23. package/defaultEnzymesByName.d.ts +1 -2
  24. package/degenerateDnaToAminoAcidMap.d.ts +1 -1
  25. package/degenerateRnaToAminoAcidMap.d.ts +1 -1
  26. package/deleteSequenceDataAtRange.d.ts +1 -2
  27. package/diffUtils.d.ts +7 -9
  28. package/doesEnzymeChopOutsideOfRecognitionSite.d.ts +1 -2
  29. package/featureTypesAndColors.d.ts +6 -19
  30. package/filterSequenceString.d.ts +10 -14
  31. package/findApproxMatches.d.ts +1 -7
  32. package/findNearestRangeOfSequenceOverlapToPosition.d.ts +1 -2
  33. package/findOrfsInPlasmid.d.ts +11 -2
  34. package/findSequenceMatches.d.ts +1 -11
  35. package/generateAnnotations.d.ts +1 -2
  36. package/generateSequenceData.d.ts +13 -8
  37. package/getAllInsertionsInSeqReads.d.ts +1 -11
  38. package/getAminoAcidDataForEachBaseOfDna.d.ts +5 -6
  39. package/getAminoAcidFromSequenceTriplet.d.ts +1 -1
  40. package/getAminoAcidStringFromSequenceString.d.ts +1 -3
  41. package/getCodonRangeForAASliver.d.ts +4 -3
  42. package/getComplementAminoAcidStringFromSequenceString.d.ts +1 -1
  43. package/getComplementSequenceAndAnnotations.d.ts +1 -5
  44. package/getComplementSequenceString.d.ts +1 -1
  45. package/getCutsiteType.d.ts +1 -2
  46. package/getCutsitesFromSequence.d.ts +1 -2
  47. package/getDegenerateDnaStringFromAAString.d.ts +1 -1
  48. package/getDegenerateRnaStringFromAAString.d.ts +1 -1
  49. package/getDigestFragmentsForCutsites.d.ts +1 -4
  50. package/getDigestFragmentsForRestrictionEnzymes.d.ts +1 -8
  51. package/getInsertBetweenVals.d.ts +1 -2
  52. package/getLeftAndRightOfSequenceInRangeGivenPosition.d.ts +1 -2
  53. package/getOrfsFromSequence.d.ts +11 -17
  54. package/getOverlapBetweenTwoSequences.d.ts +1 -2
  55. package/getPossiblePartsFromSequenceAndEnzymes.d.ts +1 -18
  56. package/getReverseAminoAcidStringFromSequenceString.d.ts +1 -1
  57. package/getReverseComplementAminoAcidStringFromSequenceString.d.ts +1 -1
  58. package/getReverseComplementAnnotation.d.ts +1 -11
  59. package/getReverseComplementSequenceAndAnnotations.d.ts +1 -5
  60. package/getReverseComplementSequenceString.d.ts +1 -1
  61. package/getReverseSequenceString.d.ts +1 -1
  62. package/getSequenceDataBetweenRange.d.ts +1 -9
  63. package/getVirtualDigest.d.ts +10 -11
  64. package/guessIfSequenceIsDnaAndNotProtein.d.ts +1 -5
  65. package/index.cjs +491 -728
  66. package/index.d.ts +5 -8
  67. package/index.js +491 -728
  68. package/index.umd.cjs +491 -728
  69. package/insertGapsIntoRefSeq.d.ts +1 -2
  70. package/insertSequenceDataAtPositionOrRange.d.ts +1 -10
  71. package/isEnzymeType2S.d.ts +1 -2
  72. package/mapAnnotationsToRows.d.ts +1 -9
  73. package/package.json +9 -12
  74. package/prepareCircularViewData.d.ts +1 -2
  75. package/prepareRowData.d.ts +3 -7
  76. package/proteinAlphabet.d.ts +1 -1
  77. package/rotateBpsToPosition.d.ts +1 -1
  78. package/rotateSequenceDataToPosition.d.ts +1 -3
  79. package/shiftAnnotationsByLen.d.ts +3 -4
  80. package/src/autoAnnotate.test.js +1 -0
  81. package/src/getSequenceDataBetweenRange.js +11 -2
  82. package/src/getSequenceDataBetweenRange.test.js +42 -0
  83. package/src/prepareRowData_output1.json +0 -1
  84. package/threeLetterSequenceStringToAminoAcidMap.d.ts +921 -11
  85. package/tidyUpAnnotation.d.ts +11 -13
  86. package/tidyUpSequenceData.d.ts +1 -15
  87. package/src/DNAComplementMap.ts +0 -32
  88. package/src/addGapsToSeqReads.ts +0 -436
  89. package/src/adjustAnnotationsToInsert.ts +0 -20
  90. package/src/adjustBpsToReplaceOrInsert.ts +0 -73
  91. package/src/aliasedEnzymesByName.ts +0 -7366
  92. package/src/aminoAcidToDegenerateDnaMap.ts +0 -32
  93. package/src/aminoAcidToDegenerateRnaMap.ts +0 -32
  94. package/src/annotateSingleSeq.ts +0 -37
  95. package/src/annotationTypes.ts +0 -23
  96. package/src/autoAnnotate.ts +0 -290
  97. package/src/bioData.ts +0 -65
  98. package/src/calculateEndStability.ts +0 -91
  99. package/src/calculateNebTa.ts +0 -46
  100. package/src/calculateNebTm.ts +0 -132
  101. package/src/calculatePercentGC.ts +0 -3
  102. package/src/calculateSantaLuciaTm.ts +0 -184
  103. package/src/calculateTm.ts +0 -242
  104. package/src/computeDigestFragments.ts +0 -238
  105. package/src/condensePairwiseAlignmentDifferences.ts +0 -85
  106. package/src/convertAACaretPositionOrRangeToDna.ts +0 -28
  107. package/src/convertDnaCaretPositionOrRangeToAA.ts +0 -28
  108. package/src/cutSequenceByRestrictionEnzyme.ts +0 -345
  109. package/src/defaultEnzymesByName.ts +0 -280
  110. package/src/degenerateDnaToAminoAcidMap.ts +0 -5
  111. package/src/degenerateRnaToAminoAcidMap.ts +0 -5
  112. package/src/deleteSequenceDataAtRange.ts +0 -13
  113. package/src/diffUtils.ts +0 -80
  114. package/src/doesEnzymeChopOutsideOfRecognitionSite.ts +0 -16
  115. package/src/featureTypesAndColors.ts +0 -167
  116. package/src/filterSequenceString.ts +0 -153
  117. package/src/findApproxMatches.ts +0 -58
  118. package/src/findNearestRangeOfSequenceOverlapToPosition.ts +0 -43
  119. package/src/findOrfsInPlasmid.ts +0 -31
  120. package/src/findSequenceMatches.ts +0 -154
  121. package/src/generateAnnotations.ts +0 -39
  122. package/src/generateSequenceData.ts +0 -212
  123. package/src/getAllInsertionsInSeqReads.ts +0 -100
  124. package/src/getAminoAcidDataForEachBaseOfDna.ts +0 -305
  125. package/src/getAminoAcidFromSequenceTriplet.ts +0 -27
  126. package/src/getAminoAcidStringFromSequenceString.ts +0 -36
  127. package/src/getCodonRangeForAASliver.ts +0 -73
  128. package/src/getComplementAminoAcidStringFromSequenceString.ts +0 -10
  129. package/src/getComplementSequenceAndAnnotations.ts +0 -25
  130. package/src/getComplementSequenceString.ts +0 -23
  131. package/src/getCutsiteType.ts +0 -18
  132. package/src/getCutsitesFromSequence.ts +0 -22
  133. package/src/getDegenerateDnaStringFromAAString.ts +0 -15
  134. package/src/getDegenerateRnaStringFromAAString.ts +0 -15
  135. package/src/getDigestFragmentsForCutsites.ts +0 -126
  136. package/src/getDigestFragmentsForRestrictionEnzymes.ts +0 -50
  137. package/src/getInsertBetweenVals.ts +0 -31
  138. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.ts +0 -40
  139. package/src/getMassOfAaString.ts +0 -29
  140. package/src/getOrfsFromSequence.ts +0 -132
  141. package/src/getOverlapBetweenTwoSequences.ts +0 -30
  142. package/src/getPossiblePartsFromSequenceAndEnzymes.ts +0 -149
  143. package/src/getReverseAminoAcidStringFromSequenceString.ts +0 -22
  144. package/src/getReverseComplementAminoAcidStringFromSequenceString.ts +0 -10
  145. package/src/getReverseComplementAnnotation.ts +0 -33
  146. package/src/getReverseComplementSequenceAndAnnotations.ts +0 -46
  147. package/src/getReverseComplementSequenceString.ts +0 -18
  148. package/src/getReverseSequenceString.ts +0 -12
  149. package/src/getSequenceDataBetweenRange.ts +0 -154
  150. package/src/getVirtualDigest.ts +0 -139
  151. package/src/guessIfSequenceIsDnaAndNotProtein.ts +0 -39
  152. package/src/index.test.ts +0 -43
  153. package/src/index.ts +0 -111
  154. package/src/insertGapsIntoRefSeq.ts +0 -43
  155. package/src/insertSequenceDataAtPosition.ts +0 -2
  156. package/src/insertSequenceDataAtPositionOrRange.ts +0 -328
  157. package/src/isEnzymeType2S.ts +0 -5
  158. package/src/mapAnnotationsToRows.ts +0 -256
  159. package/src/prepareCircularViewData.ts +0 -24
  160. package/src/prepareRowData.ts +0 -61
  161. package/src/proteinAlphabet.ts +0 -271
  162. package/src/rotateBpsToPosition.ts +0 -12
  163. package/src/rotateSequenceDataToPosition.ts +0 -54
  164. package/src/shiftAnnotationsByLen.ts +0 -24
  165. package/src/threeLetterSequenceStringToAminoAcidMap.ts +0 -198
  166. package/src/tidyUpAnnotation.ts +0 -205
  167. package/src/tidyUpSequenceData.ts +0 -213
  168. package/src/types.ts +0 -109
  169. package/types.d.ts +0 -105
package/index.cjs CHANGED
@@ -2588,10 +2588,9 @@ function getOverlapOfNonCircularRanges(rangeA, rangeB) {
2588
2588
  }
2589
2589
  }
2590
2590
  }
2591
- return null;
2592
2591
  }
2593
2592
  __name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
2594
- function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
2593
+ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
2595
2594
  const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
2596
2595
  rangeA,
2597
2596
  maxRangeLength
@@ -2612,22 +2611,6 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
2612
2611
  }
2613
2612
  });
2614
2613
  });
2615
- if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
2616
- const joinedOverlap = {};
2617
- overlaps = flatMap(overlaps, (o) => {
2618
- if (o.start === 0) {
2619
- joinedOverlap.end = o.end;
2620
- return [];
2621
- } else if (o.end === maxRangeLength - 1) {
2622
- joinedOverlap.start = o.start;
2623
- return [];
2624
- }
2625
- return [o];
2626
- });
2627
- if (Object.keys(joinedOverlap).length > 0) {
2628
- overlaps.push(joinedOverlap);
2629
- }
2630
- }
2631
2614
  return overlaps;
2632
2615
  }
2633
2616
  __name(getOverlapsOfPotentiallyCircularRanges, "getOverlapsOfPotentiallyCircularRanges");
@@ -2699,7 +2682,10 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
2699
2682
  if (!overlaps.length) {
2700
2683
  return rangeToBeTrimmed;
2701
2684
  }
2702
- const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
2685
+ const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
2686
+ rangeToBeTrimmed,
2687
+ sequenceLength
2688
+ );
2703
2689
  splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
2704
2690
  overlaps.forEach(function(overlap) {
2705
2691
  if (nonCircularRangeToBeTrimmed) {
@@ -2742,7 +2728,6 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
2742
2728
  end: outputTrimmedRange.end
2743
2729
  });
2744
2730
  }
2745
- return void 0;
2746
2731
  }
2747
2732
  __name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
2748
2733
  function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
@@ -2889,36 +2874,28 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
2889
2874
  }
2890
2875
  }
2891
2876
  }
2892
- return overlaps;
2893
2877
  }
2894
2878
  __name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
2895
2879
  function provideInclusiveOptions(funToWrap) {
2896
- return function(...args) {
2880
+ return function() {
2881
+ const args = Array.prototype.slice.call(arguments);
2897
2882
  const options = args[args.length - 1];
2898
2883
  if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
2899
2884
  args.forEach(function(arg, index) {
2900
- const potentialRange = arg;
2901
- if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
2902
- args[index] = assign(potentialRange, {
2903
- start: potentialRange.start - 1
2904
- });
2885
+ if (arg && arg.start > -1 && options.inclusive1BasedStart) {
2886
+ args[index] = assign(arg, { start: arg.start - 1 });
2905
2887
  }
2906
- if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
2907
- args[index] = assign(potentialRange, {
2908
- end: potentialRange.end - 1
2909
- });
2888
+ if (arg && arg.end > -1 && options.inclusive1BasedEnd) {
2889
+ args[index] = assign(arg, { end: arg.end - 1 });
2910
2890
  }
2911
2891
  });
2912
2892
  }
2913
2893
  let returnVal = funToWrap.apply(this, args);
2914
- const potentialReturn = returnVal;
2915
- if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
2916
- returnVal = assign(potentialReturn, {
2917
- start: potentialReturn.start + 1
2918
- });
2894
+ if (returnVal && returnVal.start > -1 && options && options.inclusive1BasedStart) {
2895
+ returnVal = assign(returnVal, { start: returnVal.start + 1 });
2919
2896
  }
2920
- if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
2921
- returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
2897
+ if (returnVal && returnVal.end > -1 && options && options.inclusive1BasedEnd) {
2898
+ returnVal = assign(returnVal, { end: returnVal.end + 1 });
2922
2899
  }
2923
2900
  return returnVal;
2924
2901
  };
@@ -2964,7 +2941,7 @@ function isPositionWithinRange(position, range, sequenceLength, includeStartEdge
2964
2941
  return positionFits;
2965
2942
  }
2966
2943
  __name(isPositionWithinRange, "isPositionWithinRange");
2967
- function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
2944
+ function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
2968
2945
  let position = pPosition;
2969
2946
  if (position < 0) {
2970
2947
  position += sequenceLength;
@@ -3144,9 +3121,7 @@ function getSequenceWithinRange(range, sequence) {
3144
3121
  if (typeof subSequence === "string") {
3145
3122
  subSequence += sequence.slice(0, range.end + 1);
3146
3123
  } else {
3147
- subSequence = subSequence.concat(
3148
- sequence.slice(0, range.end + 1)
3149
- );
3124
+ subSequence = subSequence.concat(sequence.slice(0, range.end + 1));
3150
3125
  }
3151
3126
  return subSequence;
3152
3127
  } else {
@@ -3166,7 +3141,7 @@ function getShortestDistanceBetweenTwoPositions(position1, position2, sequenceLe
3166
3141
  }
3167
3142
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
3168
3143
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
3169
- let yOffset = 0;
3144
+ let yOffset = [];
3170
3145
  const openYOffsetFound = YOffsetLevelsWithRanges.some(
3171
3146
  function(rangesAlreadyAddedToYOffset, index) {
3172
3147
  const rangeBlocked = rangesAlreadyAddedToYOffset.some(
@@ -3179,7 +3154,6 @@ function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, a
3179
3154
  );
3180
3155
  if (!rangeBlocked) {
3181
3156
  yOffset = index;
3182
- if (assignYOffsetToRange) range.yOffset = index;
3183
3157
  rangesAlreadyAddedToYOffset.push(range);
3184
3158
  return true;
3185
3159
  }
@@ -3188,7 +3162,6 @@ function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, a
3188
3162
  );
3189
3163
  if (!openYOffsetFound) {
3190
3164
  yOffset = YOffsetLevelsWithRanges.length;
3191
- if (assignYOffsetToRange) range.yOffset = YOffsetLevelsWithRanges.length;
3192
3165
  }
3193
3166
  return yOffset;
3194
3167
  }
@@ -3200,8 +3173,7 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
3200
3173
  ranges.forEach(function(range) {
3201
3174
  const yOffset = getYOffsetForPotentiallyCircularRange(
3202
3175
  range,
3203
- yOffsetLevels,
3204
- assignYOffsetToRange
3176
+ yOffsetLevels
3205
3177
  );
3206
3178
  yOffsets.push(yOffset);
3207
3179
  if (yOffset > maxYOffset) {
@@ -3216,20 +3188,21 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
3216
3188
  __name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
3217
3189
  const invertRange = provideInclusiveOptions(invertRange$1);
3218
3190
  function invertRange$1(rangeOrCaret, rangeMax) {
3219
- if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
3191
+ if (rangeOrCaret.start > -1) {
3220
3192
  const start = rangeOrCaret.end + 1;
3221
3193
  const end = rangeOrCaret.start - 1;
3222
3194
  return {
3223
3195
  start: normalizePositionByRangeLength(start, rangeMax, false),
3224
3196
  end: normalizePositionByRangeLength(end, rangeMax, false)
3225
3197
  };
3226
- } else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
3227
- return {
3228
- start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
3229
- end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
3230
- };
3198
+ } else {
3199
+ if (rangeOrCaret > -1) {
3200
+ return {
3201
+ start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
3202
+ end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
3203
+ };
3204
+ }
3231
3205
  }
3232
- return void 0;
3233
3206
  }
3234
3207
  __name(invertRange$1, "invertRange$1");
3235
3208
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
@@ -3283,10 +3256,9 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
3283
3256
  "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
3284
3257
  );
3285
3258
  }
3286
- const newSubrange = {
3287
- start: subRange.start - containerRange.start,
3288
- end: subRange.end - containerRange.start
3289
- };
3259
+ const newSubrange = {};
3260
+ newSubrange.start = subRange.start - containerRange.start;
3261
+ newSubrange.end = subRange.end - containerRange.start;
3290
3262
  if (newSubrange.start < 0) {
3291
3263
  newSubrange.start += sequenceLength;
3292
3264
  }
@@ -3297,10 +3269,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
3297
3269
  }
3298
3270
  __name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
3299
3271
  function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
3300
- const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
3272
+ const mod = rangeLength ? modulo : identity;
3301
3273
  const newRange = assign({}, rangeToBeAdjusted, {
3302
- start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
3303
- end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
3274
+ start: mod(rangeToBeAdjusted.start - (rotateTo || 0), rangeLength),
3275
+ end: mod(rangeToBeAdjusted.end - (rotateTo || 0), rangeLength)
3304
3276
  });
3305
3277
  return newRange;
3306
3278
  }
@@ -3386,11 +3358,7 @@ function autoAnnotate({
3386
3358
  forEach(
3387
3359
  omitBy(seqsToAnnotateById, (s) => !s.sequence.length),
3388
3360
  ({ circular, sequence }, id) => {
3389
- function getMatches({
3390
- seqToMatchAgainst,
3391
- isReverse,
3392
- seqLen: seqLen2
3393
- }) {
3361
+ function getMatches({ seqToMatchAgainst, isReverse, seqLen: seqLen2 }) {
3394
3362
  let match;
3395
3363
  let lastMatch;
3396
3364
  try {
@@ -3410,13 +3378,13 @@ function autoAnnotate({
3410
3378
  };
3411
3379
  const range = {
3412
3380
  start: matchStart,
3413
- end: normalizePositionByRangeLength(matchEnd - 1, seqLen2, false)
3381
+ end: normalizePositionByRangeLength(matchEnd - 1, seqLen2)
3414
3382
  };
3415
3383
  if (!annotationsToAddBySeqId[id])
3416
3384
  annotationsToAddBySeqId[id] = [];
3417
3385
  annotationsToAddBySeqId[id].push(__spreadProps(__spreadValues({}, isReverse ? {
3418
- start: reversePositionInRange(range.end, seqLen2, false),
3419
- end: reversePositionInRange(range.start, seqLen2, false)
3386
+ start: reversePositionInRange(range.end, seqLen2),
3387
+ end: reversePositionInRange(range.start, seqLen2)
3420
3388
  } : range), {
3421
3389
  strand: isReverse ? -1 : 1,
3422
3390
  id: ann.id
@@ -3447,22 +3415,14 @@ function autoAnnotate({
3447
3415
  const origSeq = seqsToAnnotateById[id];
3448
3416
  const alreadyExistingAnnsByStartEnd = {};
3449
3417
  forEach(origSeq.annotations, (ann) => {
3450
- alreadyExistingAnnsByStartEnd[getStartEndStr(
3451
- __spreadProps(__spreadValues({}, ann), { strand: typeof ann.strand === "string" ? 1 : ann.strand }),
3452
- { compareName }
3453
- )] = ann;
3418
+ alreadyExistingAnnsByStartEnd[getStartEndStr(ann, { compareName })] = ann;
3454
3419
  });
3455
3420
  const warningCounter = {};
3456
3421
  const toAdd = anns.filter((ann) => {
3457
- const alreadyExistingAnn = alreadyExistingAnnsByStartEnd[getStartEndStr(
3458
- __spreadProps(__spreadValues({}, ann), {
3459
- strand: typeof ann.strand === "string" ? 1 : ann.strand
3460
- }),
3461
- { compareName }
3462
- )];
3422
+ const alreadyExistingAnn = alreadyExistingAnnsByStartEnd[getStartEndStr(ann, { compareName })];
3463
3423
  if (alreadyExistingAnn) return false;
3464
- if (warnIfMoreThan && ann.id !== void 0) {
3465
- warningCounter[String(ann.id)] = (warningCounter[String(ann.id)] || 0) + 1;
3424
+ if (warnIfMoreThan) {
3425
+ warningCounter[ann.id] = (warningCounter[ann.id] || 0) + 1;
3466
3426
  }
3467
3427
  return true;
3468
3428
  }).sort((a, b) => a.start - b.start);
@@ -3471,23 +3431,16 @@ function autoAnnotate({
3471
3431
  }
3472
3432
  warnIfMoreThan && forEach(warningCounter, (num, annId) => {
3473
3433
  if (num > warnIfMoreThan) {
3474
- const warnings = toReturn["__more_than_warnings"] || {};
3475
- warnings[id] = warnings[id] || [];
3476
- warnings[id].push(annId);
3477
- toReturn["__more_than_warnings"] = warnings;
3434
+ toReturn.__more_than_warnings = toReturn.__more_than_warnings || {};
3435
+ toReturn.__more_than_warnings[id] = toReturn.__more_than_warnings[id] || [];
3436
+ toReturn.__more_than_warnings[id].push(annId);
3478
3437
  }
3479
3438
  });
3480
3439
  });
3481
3440
  return toReturn;
3482
3441
  }
3483
3442
  __name(autoAnnotate, "autoAnnotate");
3484
- function getStartEndStr({
3485
- start,
3486
- end,
3487
- name,
3488
- strand,
3489
- forward
3490
- }, { compareName }) {
3443
+ function getStartEndStr({ start, end, name, strand, forward }, { compareName }) {
3491
3444
  const isReverse = strand === -1 || forward === false;
3492
3445
  return `${start}-${end}-${isReverse ? "rev" : "for"}-${compareName ? name : ""}`;
3493
3446
  }
@@ -3501,12 +3454,13 @@ function convertApELikeRegexToRegex(regString = "") {
3501
3454
  let hitLeftCaret;
3502
3455
  let hitRightCaret;
3503
3456
  for (const bp of regString.replace("(", "").replace(")", "")) {
3504
- let maybeHandleRightCaret = /* @__PURE__ */ __name(function(justAdded) {
3457
+ let maybeHandleRightCaret = function(justAdded) {
3505
3458
  if (hitRightCaret) {
3506
3459
  rightOfCaretHolder += justAdded;
3507
3460
  afterRightCaretHolder = `${rightOfCaretHolder}${afterRightCaretHolder.length ? "|" : ""}${afterRightCaretHolder}`;
3508
3461
  }
3509
- }, "maybeHandleRightCaret");
3462
+ };
3463
+ __name(maybeHandleRightCaret, "maybeHandleRightCaret");
3510
3464
  const ambigVal = ambiguous_dna_values[bp.toUpperCase()];
3511
3465
  if (ambigVal && ambigVal.length > 1) {
3512
3466
  let valToUse;
@@ -3691,17 +3645,16 @@ const getMergedFeatureMap = /* @__PURE__ */ __name(() => {
3691
3645
  })),
3692
3646
  "name"
3693
3647
  );
3694
- const featureOverrides = typeof window !== "undefined" && get$1(window, "tg_featureTypeOverrides") || typeof global !== "undefined" && get$1(global, "tg_featureTypeOverrides") || [];
3695
- const mappedOverrides = featureOverrides.map((fo) => {
3648
+ let featureOverrides = typeof window !== "undefined" && get$1(window, "tg_featureTypeOverrides") || typeof global !== "undefined" && get$1(global, "tg_featureTypeOverrides");
3649
+ featureOverrides = featureOverrides || [];
3650
+ featureOverrides = featureOverrides.map((fo) => {
3696
3651
  const originalGenbankFeat = keyedGBFeats[fo.name];
3697
3652
  return __spreadValues(__spreadValues(__spreadValues({}, originalGenbankFeat), fo), originalGenbankFeat ? { isOverridden: true } : { isCustomType: true });
3698
3653
  });
3699
- const keyedOverrides = keyBy(mappedOverrides, "name");
3700
- return __spreadValues(__spreadValues({}, keyedGBFeats), keyedOverrides);
3654
+ featureOverrides = keyBy(featureOverrides, "name");
3655
+ return __spreadValues(__spreadValues({}, keyedGBFeats), featureOverrides);
3701
3656
  }, "getMergedFeatureMap");
3702
- const getFeatureToColorMap = /* @__PURE__ */ __name(({
3703
- includeHidden
3704
- } = {}) => {
3657
+ const getFeatureToColorMap = /* @__PURE__ */ __name(({ includeHidden } = {}) => {
3705
3658
  const toRet = {};
3706
3659
  filter(
3707
3660
  getMergedFeatureMap(),
@@ -3711,9 +3664,7 @@ const getFeatureToColorMap = /* @__PURE__ */ __name(({
3711
3664
  });
3712
3665
  return toRet;
3713
3666
  }, "getFeatureToColorMap");
3714
- const getFeatureTypes = /* @__PURE__ */ __name(({
3715
- includeHidden
3716
- } = {}) => filter(getMergedFeatureMap(), (f) => includeHidden ? true : !f.isHidden).map(
3667
+ const getFeatureTypes = /* @__PURE__ */ __name(({ includeHidden } = {}) => filter(getMergedFeatureMap(), (f) => includeHidden ? true : !f.isHidden).map(
3717
3668
  (f) => f.name
3718
3669
  ), "getFeatureTypes");
3719
3670
  function getDefaultExportFromCjs(x) {
@@ -4018,15 +3969,10 @@ __name(requireShortid, "requireShortid");
4018
3969
  var shortidExports = requireShortid();
4019
3970
  const shortid = /* @__PURE__ */ getDefaultExportFromCjs(shortidExports);
4020
3971
  function cutSequenceByRestrictionEnzyme(pSequence, circular, restrictionEnzyme) {
4021
- if (!restrictionEnzyme.forwardRegex || // Add check for undefined
4022
- !restrictionEnzyme.reverseRegex || // Add check for undefined
4023
- restrictionEnzyme.forwardRegex.length === 0 || restrictionEnzyme.reverseRegex.length === 0) {
4024
- console.warn(
4025
- "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long."
4026
- );
4027
- const returnVal = [];
4028
- returnVal.error = "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long.";
4029
- return returnVal;
3972
+ if (restrictionEnzyme.forwardRegex.length === 0 || restrictionEnzyme.reverseRegex.length === 0) {
3973
+ const returnArray = [];
3974
+ returnArray.error = "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long.";
3975
+ return returnArray;
4030
3976
  }
4031
3977
  const forwardRegExpPattern = new RegExp(restrictionEnzyme.forwardRegex, "ig");
4032
3978
  const sequence = pSequence;
@@ -4051,54 +3997,54 @@ function cutSequenceByRestrictionEnzyme(pSequence, circular, restrictionEnzyme)
4051
3997
  }
4052
3998
  return cutsitesForward.concat(cutsitesReverse);
4053
3999
  function reverseAllPositionsOfCutsite(cutsite, rangeLength) {
4054
- cutsite = assign({}, cutsite);
4055
4000
  cutsite.start = reversePositionInRange(cutsite.start, rangeLength, false);
4056
4001
  cutsite.end = reversePositionInRange(cutsite.end, rangeLength, false);
4057
- cutsite.topSnipPosition = cutsite.topSnipPosition != null ? reversePositionInRange(cutsite.topSnipPosition, rangeLength, true) : null;
4058
- cutsite.bottomSnipPosition = cutsite.bottomSnipPosition != null ? reversePositionInRange(cutsite.bottomSnipPosition, rangeLength, true) : null;
4059
- if (cutsite.cutType === 1 && cutsite.cutsTwice) {
4060
- if (cutsite.upstreamTopSnip != null && cutsite.upstreamBottomSnip != null) {
4061
- cutsite.upstreamTopSnip = reversePositionInRange(
4062
- cutsite.upstreamTopSnip,
4063
- rangeLength,
4064
- true
4065
- );
4066
- cutsite.upstreamBottomSnip = reversePositionInRange(
4067
- cutsite.upstreamBottomSnip,
4068
- rangeLength,
4069
- true
4070
- );
4071
- }
4072
- }
4073
- if (cutsite.recognitionSiteRange) {
4074
- cutsite.recognitionSiteRange = __spreadValues({}, cutsite.recognitionSiteRange);
4075
- cutsite.recognitionSiteRange.start = reversePositionInRange(
4076
- cutsite.recognitionSiteRange.start,
4002
+ cutsite.topSnipPosition = reversePositionInRange(
4003
+ cutsite.topSnipPosition,
4004
+ rangeLength,
4005
+ true
4006
+ );
4007
+ cutsite.bottomSnipPosition = reversePositionInRange(
4008
+ cutsite.bottomSnipPosition,
4009
+ rangeLength,
4010
+ true
4011
+ );
4012
+ if (cutsite.cutsTwice) {
4013
+ cutsite.upstreamTopSnip = reversePositionInRange(
4014
+ cutsite.upstreamTopSnip,
4077
4015
  rangeLength,
4078
- false
4016
+ true
4079
4017
  );
4080
- cutsite.recognitionSiteRange.end = reversePositionInRange(
4081
- cutsite.recognitionSiteRange.end,
4018
+ cutsite.upstreamBottomSnip = reversePositionInRange(
4019
+ cutsite.upstreamBottomSnip,
4082
4020
  rangeLength,
4083
- false
4021
+ true
4084
4022
  );
4085
4023
  }
4086
- return __spreadProps(__spreadValues({}, cutsite), {
4024
+ cutsite.recognitionSiteRange.start = reversePositionInRange(
4025
+ cutsite.recognitionSiteRange.start,
4026
+ rangeLength,
4027
+ false
4028
+ );
4029
+ cutsite.recognitionSiteRange.end = reversePositionInRange(
4030
+ cutsite.recognitionSiteRange.end,
4031
+ rangeLength,
4032
+ false
4033
+ );
4034
+ return assign({}, cutsite, {
4087
4035
  start: cutsite.end,
4088
4036
  end: cutsite.start,
4089
- overhangBps: getReverseComplementSequenceString(
4090
- cutsite.overhangBps || ""
4091
- ),
4037
+ overhangBps: getReverseComplementSequenceString(cutsite.overhangBps),
4092
4038
  topSnipPosition: cutsite.bottomSnipPosition,
4093
4039
  bottomSnipPosition: cutsite.topSnipPosition,
4094
4040
  upstreamTopSnip: cutsite.upstreamBottomSnip,
4095
4041
  upstreamBottomSnip: cutsite.upstreamTopSnip,
4096
4042
  upstreamTopBeforeBottom: !!cutsite.upstreamTopBeforeBottom,
4097
4043
  topSnipBeforeBottom: !!cutsite.topSnipBeforeBottom,
4098
- recognitionSiteRange: cutsite.recognitionSiteRange ? {
4044
+ recognitionSiteRange: {
4099
4045
  start: cutsite.recognitionSiteRange.end,
4100
4046
  end: cutsite.recognitionSiteRange.start
4101
- } : void 0,
4047
+ },
4102
4048
  forward: false
4103
4049
  });
4104
4050
  }
@@ -4110,7 +4056,7 @@ function cutSequence(forwardRegExpPattern, restrictionEnzyme, sequence, circular
4110
4056
  let restrictionCutSite;
4111
4057
  const recognitionSiteLength = restrictionEnzyme.site.length;
4112
4058
  const originalSequence = sequence;
4113
- const originalSequenceLengthVal = sequence.length;
4059
+ const originalSequenceLength = sequence.length;
4114
4060
  if (circular) {
4115
4061
  sequence += sequence;
4116
4062
  }
@@ -4119,10 +4065,7 @@ function cutSequence(forwardRegExpPattern, restrictionEnzyme, sequence, circular
4119
4065
  let startIndex = 0;
4120
4066
  let subSequence = sequence;
4121
4067
  while (matchIndex !== -1) {
4122
- const recognitionSiteRange = {
4123
- start: 0,
4124
- end: 0
4125
- };
4068
+ const recognitionSiteRange = {};
4126
4069
  let start;
4127
4070
  let end;
4128
4071
  let upstreamTopSnip = null;
@@ -4137,39 +4080,37 @@ function cutSequence(forwardRegExpPattern, restrictionEnzyme, sequence, circular
4137
4080
  recognitionSiteRange.end = matchIndex + recognitionSiteLength - 1 + startIndex;
4138
4081
  end = recognitionSiteRange.end;
4139
4082
  if (restrictionEnzyme.cutType === 1) {
4140
- if (restrictionEnzyme.usForward != null && restrictionEnzyme.usReverse != null) {
4141
- upstreamTopSnip = recognitionSiteRange.end - restrictionEnzyme.usForward;
4142
- upstreamBottomSnip = recognitionSiteRange.end - restrictionEnzyme.usReverse;
4143
- if (upstreamTopSnip >= 0 && upstreamBottomSnip >= 0) {
4144
- fitsWithinSequence = true;
4145
- if (upstreamTopSnip < upstreamBottomSnip) {
4146
- if (start > upstreamTopSnip) {
4147
- start = upstreamTopSnip + 1;
4148
- }
4149
- upstreamTopBeforeBottom = true;
4150
- } else {
4151
- if (start > upstreamBottomSnip) {
4152
- start = upstreamBottomSnip + 1;
4153
- }
4083
+ upstreamTopSnip = recognitionSiteRange.end - restrictionEnzyme.usForward;
4084
+ upstreamBottomSnip = recognitionSiteRange.end - restrictionEnzyme.usReverse;
4085
+ if (upstreamTopSnip >= 0 && upstreamBottomSnip >= 0) {
4086
+ fitsWithinSequence = true;
4087
+ if (upstreamTopSnip < upstreamBottomSnip) {
4088
+ if (start > upstreamTopSnip) {
4089
+ start = upstreamTopSnip + 1;
4154
4090
  }
4155
- upstreamTopSnip = normalizePositionByRangeLength(
4156
- upstreamTopSnip,
4157
- originalSequenceLengthVal,
4158
- true
4159
- );
4160
- upstreamBottomSnip = normalizePositionByRangeLength(
4161
- upstreamBottomSnip,
4162
- originalSequenceLengthVal,
4163
- true
4164
- );
4091
+ upstreamTopBeforeBottom = true;
4165
4092
  } else {
4166
- upstreamTopSnip = null;
4167
- upstreamBottomSnip = null;
4093
+ if (start > upstreamBottomSnip) {
4094
+ start = upstreamBottomSnip + 1;
4095
+ }
4168
4096
  }
4097
+ upstreamTopSnip = normalizePositionByRangeLength(
4098
+ upstreamTopSnip,
4099
+ originalSequenceLength,
4100
+ true
4101
+ );
4102
+ upstreamBottomSnip = normalizePositionByRangeLength(
4103
+ upstreamBottomSnip,
4104
+ originalSequenceLength,
4105
+ true
4106
+ );
4107
+ } else {
4108
+ upstreamTopSnip = null;
4109
+ upstreamBottomSnip = null;
4169
4110
  }
4170
4111
  }
4171
- topSnipPosition = recognitionSiteRange.start + (restrictionEnzyme.topSnipOffset || 0);
4172
- bottomSnipPosition = recognitionSiteRange.start + (restrictionEnzyme.bottomSnipOffset || 0);
4112
+ topSnipPosition = recognitionSiteRange.start + restrictionEnzyme.topSnipOffset;
4113
+ bottomSnipPosition = recognitionSiteRange.start + restrictionEnzyme.bottomSnipOffset;
4173
4114
  if (bottomSnipPosition <= currentSequenceLength && topSnipPosition <= currentSequenceLength) {
4174
4115
  fitsWithinSequence = true;
4175
4116
  if (topSnipPosition > bottomSnipPosition) {
@@ -4184,70 +4125,61 @@ function cutSequence(forwardRegExpPattern, restrictionEnzyme, sequence, circular
4184
4125
  }
4185
4126
  topSnipPosition = normalizePositionByRangeLength(
4186
4127
  topSnipPosition,
4187
- originalSequenceLengthVal,
4128
+ originalSequenceLength,
4188
4129
  true
4189
4130
  );
4190
4131
  bottomSnipPosition = normalizePositionByRangeLength(
4191
4132
  bottomSnipPosition,
4192
- originalSequenceLengthVal,
4133
+ originalSequenceLength,
4193
4134
  true
4194
4135
  );
4195
4136
  } else {
4196
4137
  topSnipPosition = null;
4197
4138
  bottomSnipPosition = null;
4198
4139
  }
4199
- if (fitsWithinSequence && start >= 0 && end >= 0 && start < originalSequenceLengthVal && end < currentSequenceLength) {
4140
+ if (fitsWithinSequence && start >= 0 && end >= 0 && start < originalSequenceLength && end < currentSequenceLength) {
4200
4141
  start = normalizePositionByRangeLength(
4201
4142
  start,
4202
- originalSequenceLengthVal,
4203
- false
4204
- );
4205
- end = normalizePositionByRangeLength(
4206
- end,
4207
- originalSequenceLengthVal,
4143
+ originalSequenceLength,
4208
4144
  false
4209
4145
  );
4146
+ end = normalizePositionByRangeLength(end, originalSequenceLength, false);
4210
4147
  recognitionSiteRange.start = normalizePositionByRangeLength(
4211
4148
  recognitionSiteRange.start,
4212
- originalSequenceLengthVal,
4149
+ originalSequenceLength,
4213
4150
  false
4214
4151
  );
4215
4152
  recognitionSiteRange.end = normalizePositionByRangeLength(
4216
4153
  recognitionSiteRange.end,
4217
- originalSequenceLengthVal,
4154
+ originalSequenceLength,
4218
4155
  false
4219
4156
  );
4220
4157
  let cutRange = {
4221
4158
  start: -1,
4222
4159
  end: -1
4223
4160
  };
4224
- if (topSnipPosition !== null && bottomSnipPosition !== null && topSnipPosition !== bottomSnipPosition) {
4161
+ if (topSnipPosition !== bottomSnipPosition) {
4225
4162
  cutRange = topSnipBeforeBottom ? {
4226
4163
  start: topSnipPosition,
4227
4164
  end: normalizePositionByRangeLength(
4228
4165
  bottomSnipPosition - 1,
4229
- originalSequenceLengthVal
4166
+ originalSequenceLength
4230
4167
  )
4231
4168
  } : {
4232
4169
  start: bottomSnipPosition,
4233
4170
  end: normalizePositionByRangeLength(
4234
4171
  topSnipPosition - 1,
4235
- originalSequenceLengthVal
4172
+ originalSequenceLength
4236
4173
  )
4237
4174
  };
4238
4175
  }
4239
- const overhangBps = getSequenceWithinRange(
4240
- cutRange,
4241
- originalSequence
4242
- );
4176
+ const overhangBps = getSequenceWithinRange(cutRange, originalSequence);
4243
4177
  restrictionCutSite = {
4244
4178
  id: shortid(),
4245
4179
  start,
4246
4180
  end,
4247
4181
  topSnipPosition,
4248
- // Allow null
4249
4182
  bottomSnipPosition,
4250
- // Allow null
4251
4183
  topSnipBeforeBottom,
4252
4184
  overhangBps,
4253
4185
  overhangSize: overhangBps.length,
@@ -4269,19 +4201,16 @@ function cutSequence(forwardRegExpPattern, restrictionEnzyme, sequence, circular
4269
4201
  return restrictionCutSites;
4270
4202
  }
4271
4203
  __name(cutSequence, "cutSequence");
4272
- function getCutsitesFromSequence(sequence, circular, contextEnzymes) {
4273
- const cutsites = flatMap(contextEnzymes, (enzyme) => {
4274
- return cutSequenceByRestrictionEnzyme(sequence, circular, enzyme);
4275
- });
4276
- const cutsitesByNameMap = {};
4277
- cutsites.forEach((cutsite) => {
4278
- const name = cutsite.name || "";
4279
- if (!cutsitesByNameMap[name]) {
4280
- cutsitesByNameMap[name] = [];
4204
+ function getCutsitesFromSequence(sequence, circular, restrictionEnzymes) {
4205
+ const cutsitesByName = {};
4206
+ for (let i = 0; i < restrictionEnzymes.length; i++) {
4207
+ const re = restrictionEnzymes[i];
4208
+ const cutsites = cutSequenceByRestrictionEnzyme(sequence, circular, re);
4209
+ if (cutsites.length) {
4210
+ cutsitesByName[re.name] = cutsites;
4281
4211
  }
4282
- cutsitesByNameMap[name].push(cutsite);
4283
- });
4284
- return cutsitesByNameMap;
4212
+ }
4213
+ return cutsitesByName;
4285
4214
  }
4286
4215
  __name(getCutsitesFromSequence, "getCutsitesFromSequence");
4287
4216
  function computeDigestFragments({
@@ -4299,9 +4228,9 @@ function computeDigestFragments({
4299
4228
  const fragments = [];
4300
4229
  const overlappingEnzymes = [];
4301
4230
  const pairs = [];
4302
- const sortedCutsites = cutsites.filter(
4303
- (c) => c.topSnipPosition != null && c.bottomSnipPosition != null
4304
- );
4231
+ const sortedCutsites = cutsites.sort((a, b) => {
4232
+ return a.topSnipPosition - b.topSnipPosition;
4233
+ });
4305
4234
  if (!circular && cutsites.length) {
4306
4235
  sortedCutsites.push({
4307
4236
  id: "seqTerm_" + shortid(),
@@ -4310,8 +4239,6 @@ function computeDigestFragments({
4310
4239
  overhangBps: "",
4311
4240
  topSnipPosition: 0,
4312
4241
  bottomSnipPosition: 0,
4313
- overhangSize: 0,
4314
- // Added to satisfy CutSite
4315
4242
  upstreamTopSnip: 0,
4316
4243
  upstreamBottomSnip: 0,
4317
4244
  upstreamTopBeforeBottom: false,
@@ -4322,34 +4249,26 @@ function computeDigestFragments({
4322
4249
  },
4323
4250
  forward: true,
4324
4251
  name: "Sequence_Terminus",
4325
- type: "START_OR_END_OF_SEQ",
4326
4252
  restrictionEnzyme: {
4327
- name: "Sequence_Terminus",
4328
- site: "",
4329
- forwardRegex: "",
4330
- reverseRegex: ""
4253
+ name: "Sequence_Terminus"
4331
4254
  }
4332
4255
  });
4333
4256
  }
4334
- sortedCutsites.sort((a, b) => {
4335
- return a.topSnipPosition - b.topSnipPosition;
4336
- });
4337
4257
  sortedCutsites.forEach((cutsite1, index) => {
4338
- if (!computeDigestDisabled) {
4339
- pairs.push([
4340
- cutsite1,
4341
- sortedCutsites[index + 1] ? sortedCutsites[index + 1] : sortedCutsites[0]
4342
- ]);
4343
- }
4344
4258
  if (computePartialDigest && !computePartialDigestDisabled) {
4345
4259
  sortedCutsites.forEach((cs, index2) => {
4346
- const isAdjacent = index2 === index + 1 || index === sortedCutsites.length - 1 && index2 === 0;
4347
- if (isAdjacent) {
4260
+ if (index2 === index + 1 || index2 === 0) {
4348
4261
  return;
4349
4262
  }
4350
4263
  pairs.push([cutsite1, sortedCutsites[index2]]);
4351
4264
  });
4352
4265
  }
4266
+ if (!computeDigestDisabled) {
4267
+ pairs.push([
4268
+ cutsite1,
4269
+ sortedCutsites[index + 1] ? sortedCutsites[index + 1] : sortedCutsites[0]
4270
+ ]);
4271
+ }
4353
4272
  });
4354
4273
  pairs.forEach((r) => {
4355
4274
  let [cut1, cut2] = r;
@@ -4394,17 +4313,12 @@ function computeDigestFragments({
4394
4313
  cut2.name = "Linear_Sequence_End";
4395
4314
  cut2.restrictionEnzyme.name = "Linear_Sequence_End";
4396
4315
  }
4397
- cut1 = __spreadProps(__spreadValues({}, cut1), {
4398
- isOverhangIncludedInFragmentSize: cut1.name !== "Linear_Sequence_Start" && cut1.name !== "Sequence_Terminus" && (cut1.overhangSize || 0) > 0 && !!cut1.topSnipBeforeBottom
4399
- });
4400
- cut2 = __spreadProps(__spreadValues({}, cut2), {
4401
- isOverhangIncludedInFragmentSize: cut2.name !== "Linear_Sequence_End" && cut2.name !== "Sequence_Terminus" && (cut2.overhangSize || 0) > 0 && !cut2.topSnipBeforeBottom
4402
- });
4403
4316
  const id = start + "-" + end + "-" + size + "-";
4404
4317
  const name = `${cut1.restrictionEnzyme.name} -- ${cut2.restrictionEnzyme.name} ${size} bps`;
4318
+ getRangeLength({ start, end }, sequenceLength);
4405
4319
  fragments.push({
4406
4320
  isFormedFromLinearEnd,
4407
- madeFromOneCutsite: cut1.id === cut2.id,
4321
+ madeFromOneCutsite: cut1 === cut2,
4408
4322
  start,
4409
4323
  end,
4410
4324
  size,
@@ -4445,14 +4359,12 @@ function getDigestFragsForSeqAndEnzymes({
4445
4359
  includeOverAndUnderHangs
4446
4360
  }) {
4447
4361
  const cutsitesByName = getCutsitesFromSequence(sequence, circular, enzymes);
4448
- const digest = computeDigestFragments({
4362
+ return computeDigestFragments({
4449
4363
  includeOverAndUnderHangs,
4450
4364
  cutsites: flatMap(cutsitesByName),
4451
4365
  sequenceLength: sequence.length,
4452
4366
  circular
4453
4367
  });
4454
- digest.fragments.sort((a, b) => b.size - a.size);
4455
- return digest;
4456
4368
  }
4457
4369
  __name(getDigestFragsForSeqAndEnzymes, "getDigestFragsForSeqAndEnzymes");
4458
4370
  function cloneRegExp(re) {
@@ -6021,8 +5933,7 @@ function expandAndResolve(threeLetterCodon) {
6021
5933
  let allPossibleThreeLetterCodons = [""];
6022
5934
  for (const set of picks) {
6023
5935
  const next = [];
6024
- for (const prefix of allPossibleThreeLetterCodons)
6025
- for (const b of set) next.push(prefix + b);
5936
+ for (const prefix of allPossibleThreeLetterCodons) for (const b of set) next.push(prefix + b);
6026
5937
  allPossibleThreeLetterCodons = next;
6027
5938
  }
6028
5939
  let foundAminoAcid = null;
@@ -6068,13 +5979,10 @@ function getAminoAcidFromSequenceTriplet(sequenceString) {
6068
5979
  if (aa) {
6069
5980
  return aa;
6070
5981
  }
6071
- const letter = (
6072
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6073
- degenerateDnaToAminoAcidMap[
6074
- sequenceString.replace("x", "n")
6075
- //replace x's with n's as those are equivalent dna chars
6076
- ] || "x"
6077
- );
5982
+ const letter = degenerateDnaToAminoAcidMap[
5983
+ sequenceString.replace("x", "n")
5984
+ //replace x's with n's as those are equivalent dna chars
5985
+ ] || "x";
6078
5986
  return proteinAlphabet[letter.toUpperCase()];
6079
5987
  }
6080
5988
  __name(getAminoAcidFromSequenceTriplet, "getAminoAcidFromSequenceTriplet");
@@ -6471,25 +6379,25 @@ function coerceLocation({
6471
6379
  circular,
6472
6380
  name
6473
6381
  }) {
6474
- location.start = parseInt(String(location.start), 10);
6475
- location.end = parseInt(String(location.end), 10);
6382
+ location.start = parseInt(location.start, 10);
6383
+ location.end = parseInt(location.end, 10);
6476
6384
  if (convertAnnotationsFromAAIndices) {
6477
6385
  location.start = location.start * 3;
6478
6386
  location.end = location.end * 3 + 2;
6479
6387
  }
6480
- if (size !== void 0 && (location.start < 0 || location.start > size - 1)) {
6388
+ if (location.start < 0 || !(location.start <= size - 1) || location.start > size - 1) {
6481
6389
  messages.push(
6482
6390
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
6483
6391
  );
6484
6392
  location.start = Math.max(0, size - (isProtein ? 3 : 1));
6485
6393
  }
6486
- if (size !== void 0 && (location.end < 0 || location.end > size - 1)) {
6394
+ if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
6487
6395
  messages.push(
6488
6396
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
6489
6397
  );
6490
6398
  location.end = Math.max(0, size - 1);
6491
6399
  }
6492
- if (size !== void 0 && location.start > location.end && circular === false) {
6400
+ if (location.start > location.end && circular === false) {
6493
6401
  messages.push(
6494
6402
  "Invalid circular annotation detected for " + name + ". end set to 1"
6495
6403
  );
@@ -6498,30 +6406,21 @@ function coerceLocation({
6498
6406
  }
6499
6407
  __name(coerceLocation, "coerceLocation");
6500
6408
  function getDegenerateDnaStringFromAAString(aaString) {
6501
- return aaString.split("").map(
6502
- (char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn"
6503
- ).join("");
6409
+ return aaString.split("").map((char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn").join("");
6504
6410
  }
6505
6411
  __name(getDegenerateDnaStringFromAAString, "getDegenerateDnaStringFromAAString");
6506
- function getAminoAcidStringFromSequenceString(sequenceString, options = {}) {
6507
- const { doNotExcludeAsterisk } = options;
6412
+ function getAminoAcidStringFromSequenceString(sequenceString, { doNotExcludeAsterisk } = {}) {
6508
6413
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
6509
6414
  sequenceString,
6510
- true,
6511
- null,
6512
- false
6415
+ true
6513
6416
  );
6514
6417
  const aaArray = [];
6515
6418
  let aaString = "";
6516
6419
  aminoAcidsPerBase.forEach((aa, index) => {
6517
- var _a;
6518
6420
  if (!aa.fullCodon) {
6519
6421
  return;
6520
6422
  }
6521
- if (!doNotExcludeAsterisk && index >= aminoAcidsPerBase.length - 3 && ((_a = aa.aminoAcid) == null ? void 0 : _a.value) === "*") {
6522
- return;
6523
- }
6524
- if (aa.aminoAcidIndex === null || !aa.aminoAcid) {
6423
+ if (!doNotExcludeAsterisk && index >= aminoAcidsPerBase.length - 3 && aa.aminoAcid.value === "*") {
6525
6424
  return;
6526
6425
  }
6527
6426
  aaArray[aa.aminoAcidIndex] = aa.aminoAcid.value;
@@ -6548,7 +6447,7 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6548
6447
  messages: []
6549
6448
  };
6550
6449
  if (!seqData) {
6551
- seqData = { sequence: "" };
6450
+ seqData = {};
6552
6451
  }
6553
6452
  if (!seqData.sequence) {
6554
6453
  seqData.sequence = "";
@@ -6611,27 +6510,25 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6611
6510
  const featureTypes = getFeatureTypes();
6612
6511
  annotationTypes.forEach((annotationType) => {
6613
6512
  if (!Array.isArray(seqData[annotationType])) {
6614
- if (seqData[annotationType] && typeof seqData[annotationType] === "object") {
6615
- seqData[annotationType] = Object.keys(
6616
- seqData[annotationType]
6617
- ).map((key) => {
6618
- return seqData[annotationType][key];
6619
- });
6513
+ if (typeof seqData[annotationType] === "object") {
6514
+ seqData[annotationType] = Object.keys(seqData[annotationType]).map(
6515
+ (key) => {
6516
+ return seqData[annotationType][key];
6517
+ }
6518
+ );
6620
6519
  } else {
6621
6520
  seqData[annotationType] = [];
6622
6521
  }
6623
6522
  }
6624
- seqData[annotationType] = seqData[annotationType].filter(
6625
- (annotation) => {
6626
- return tidyUpAnnotation(annotation, __spreadProps(__spreadValues({}, options), {
6627
- featureTypes,
6628
- sequenceData: seqData,
6629
- convertAnnotationsFromAAIndices,
6630
- mutative: true,
6631
- annotationType
6632
- }));
6633
- }
6634
- );
6523
+ seqData[annotationType] = seqData[annotationType].filter((annotation) => {
6524
+ return tidyUpAnnotation(annotation, __spreadProps(__spreadValues({}, options), {
6525
+ featureTypes,
6526
+ sequenceData: seqData,
6527
+ convertAnnotationsFromAAIndices,
6528
+ mutative: true,
6529
+ annotationType
6530
+ }));
6531
+ });
6635
6532
  });
6636
6533
  if (!noTranslationData) {
6637
6534
  seqData.translations = flatMap(seqData.translations, (translation) => {
@@ -6639,7 +6536,7 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6639
6536
  if (noCdsTranslations && translation.translationType === "CDS Feature") {
6640
6537
  return [];
6641
6538
  }
6642
- const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a["codon_start"]) == null ? void 0 : _b[0]) - 1 || 0;
6539
+ const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a.codon_start) == null ? void 0 : _b[0]) - 1 || 0;
6643
6540
  const expandedRange = expandOrContractRangeByLength(
6644
6541
  translation,
6645
6542
  -codonStart,
@@ -6649,9 +6546,8 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6649
6546
  if (!expandedRange.aminoAcids && !seqData.noSequence) {
6650
6547
  expandedRange.aminoAcids = getAminoAcidDataForEachBaseOfDna(
6651
6548
  seqData.sequence,
6652
- expandedRange.forward || false,
6653
- expandedRange,
6654
- false
6549
+ expandedRange.forward,
6550
+ expandedRange
6655
6551
  );
6656
6552
  }
6657
6553
  return expandedRange;
@@ -6659,22 +6555,19 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6659
6555
  }
6660
6556
  if (annotationsAsObjects) {
6661
6557
  annotationTypes.forEach((name) => {
6662
- seqData[name] = seqData[name].reduce(
6663
- (acc, item) => {
6664
- let itemId;
6665
- if (item.id || item.id === 0) {
6666
- itemId = item.id;
6667
- } else {
6668
- itemId = shortid();
6669
- if (!doNotProvideIdsForAnnotations) {
6670
- item.id = itemId;
6671
- }
6558
+ seqData[name] = seqData[name].reduce((acc, item) => {
6559
+ let itemId;
6560
+ if (item.id || item.id === 0) {
6561
+ itemId = item.id;
6562
+ } else {
6563
+ itemId = shortid();
6564
+ if (!doNotProvideIdsForAnnotations) {
6565
+ item.id = itemId;
6672
6566
  }
6673
- acc[itemId] = item;
6674
- return acc;
6675
- },
6676
- {}
6677
- );
6567
+ }
6568
+ acc[itemId] = item;
6569
+ return acc;
6570
+ }, {});
6678
6571
  });
6679
6572
  }
6680
6573
  if (logMessages && response.messages.length > 0) {
@@ -6684,17 +6577,17 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6684
6577
  }
6685
6578
  __name(tidyUpSequenceData, "tidyUpSequenceData");
6686
6579
  const getDiffFromSeqs = /* @__PURE__ */ __name((oldData, newData, { ignoreKeys = [] } = {}) => {
6687
- const cleanedOldData = tidyUpSequenceData(oldData, {
6580
+ oldData = tidyUpSequenceData(oldData, {
6688
6581
  annotationsAsObjects: true,
6689
6582
  noTranslationData: true,
6690
6583
  doNotRemoveInvalidChars: true
6691
6584
  });
6692
- const cleanedNewData = tidyUpSequenceData(newData, {
6585
+ newData = tidyUpSequenceData(newData, {
6693
6586
  annotationsAsObjects: true,
6694
6587
  noTranslationData: true,
6695
6588
  doNotRemoveInvalidChars: true
6696
6589
  });
6697
- [cleanedOldData, cleanedNewData].forEach((d) => {
6590
+ [oldData, newData].forEach((d) => {
6698
6591
  [
6699
6592
  "cutsites",
6700
6593
  "orfs",
@@ -6717,26 +6610,27 @@ const getDiffFromSeqs = /* @__PURE__ */ __name((oldData, newData, { ignoreKeys =
6717
6610
  });
6718
6611
  }
6719
6612
  });
6720
- return diff(cleanedOldData, cleanedNewData);
6613
+ return diff(oldData, newData);
6721
6614
  }, "getDiffFromSeqs");
6722
- const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diffData, { ignoreKeys = [] } = {}) => {
6615
+ const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diff2, { ignoreKeys = [] } = {}) => {
6723
6616
  ignoreKeys.forEach((k) => {
6724
- delete diffData[k];
6725
- });
6726
- const tidyOld = tidyUpSequenceData(cloneDeep(oldData), {
6727
- annotationsAsObjects: true,
6728
- doNotRemoveInvalidChars: true
6617
+ delete diff2[k];
6729
6618
  });
6730
- return patch(tidyOld, diffData);
6619
+ return patch(
6620
+ tidyUpSequenceData(cloneDeep(oldData), {
6621
+ annotationsAsObjects: true,
6622
+ doNotRemoveInvalidChars: true
6623
+ }),
6624
+ diff2
6625
+ );
6731
6626
  }, "patchSeqWithDiff");
6732
- const reverseSeqDiff = /* @__PURE__ */ __name((diffData) => {
6733
- return reverse(diffData);
6627
+ const reverseSeqDiff = /* @__PURE__ */ __name((diff2) => {
6628
+ return reverse(diff2);
6734
6629
  }, "reverseSeqDiff");
6735
6630
  function getAllInsertionsInSeqReads(seqReads) {
6736
6631
  const allInsertionsInSeqReads = [];
6737
6632
  seqReads.forEach((seqRead) => {
6738
6633
  const splitSeqRead = seqRead.cigar.match(/([0-9]*[MDI])/g);
6739
- if (!splitSeqRead) return;
6740
6634
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
6741
6635
  if (splitSeqRead[componentI].slice(-1) === "I") {
6742
6636
  let bpPosOfInsertion = seqRead.pos;
@@ -6780,19 +6674,14 @@ function getAllInsertionsInSeqReads(seqReads) {
6780
6674
  return sortedInsertions;
6781
6675
  }
6782
6676
  __name(getAllInsertionsInSeqReads, "getAllInsertionsInSeqReads");
6783
- function annotateSingleSeq({
6784
- fullSeq,
6785
- searchSeq
6786
- }) {
6677
+ function annotateSingleSeq({ fullSeq, searchSeq }) {
6787
6678
  const fullSeqId = fullSeq.id || "fullSeqId";
6788
6679
  const searchSeqId = searchSeq.id || "searchSeqId";
6789
6680
  const results = autoAnnotate({
6790
6681
  seqsToAnnotateById: {
6791
- [fullSeqId]: {
6792
- sequence: fullSeq.sequence,
6793
- circular: fullSeq.circular,
6794
- annotations: fullSeq.features || []
6795
- }
6682
+ [fullSeqId]: __spreadProps(__spreadValues({}, fullSeq), {
6683
+ id: fullSeqId
6684
+ })
6796
6685
  },
6797
6686
  annotationsToCheckById: {
6798
6687
  [searchSeqId]: __spreadProps(__spreadValues({}, searchSeq), {
@@ -6842,9 +6731,7 @@ const aminoAcidToDegenerateRnaMap = {
6842
6731
  z: "sar"
6843
6732
  };
6844
6733
  function getDegenerateRnaStringFromAAString(aaString) {
6845
- return aaString.split("").map(
6846
- (char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn"
6847
- ).join("");
6734
+ return aaString.split("").map((char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn").join("");
6848
6735
  }
6849
6736
  __name(getDegenerateRnaStringFromAAString, "getDegenerateRnaStringFromAAString");
6850
6737
  function getVirtualDigest({
@@ -6859,7 +6746,7 @@ function getVirtualDigest({
6859
6746
  const overlappingEnzymes = [];
6860
6747
  const pairs = [];
6861
6748
  const sortedCutsites = cutsites.sort((a, b) => {
6862
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
6749
+ return a.topSnipPosition - b.topSnipPosition;
6863
6750
  });
6864
6751
  sortedCutsites.forEach((cutsite1, index) => {
6865
6752
  if (computePartialDigest && !computePartialDigestDisabled) {
@@ -6876,11 +6763,11 @@ function getVirtualDigest({
6876
6763
  });
6877
6764
  pairs.forEach(([cut1, cut2]) => {
6878
6765
  const start = normalizePositionByRangeLength(
6879
- cut1.topSnipPosition || 0,
6766
+ cut1.topSnipPosition,
6880
6767
  sequenceLength
6881
6768
  );
6882
6769
  const end = normalizePositionByRangeLength(
6883
- (cut2.topSnipPosition || 0) - 1,
6770
+ cut2.topSnipPosition - 1,
6884
6771
  sequenceLength
6885
6772
  );
6886
6773
  if (!isCircular && start > end) {
@@ -6894,7 +6781,6 @@ function getVirtualDigest({
6894
6781
  name: "End Of Seq"
6895
6782
  }
6896
6783
  }
6897
- // Cast to CutSite as it's a mock
6898
6784
  };
6899
6785
  const frag2 = {
6900
6786
  start: 0,
@@ -6905,7 +6791,6 @@ function getVirtualDigest({
6905
6791
  name: "Start Of Seq"
6906
6792
  }
6907
6793
  },
6908
- // Cast
6909
6794
  cut2
6910
6795
  };
6911
6796
  fragments.push(addSizeIdName(frag1, sequenceLength));
@@ -7008,18 +6893,27 @@ function findApproxMatches(searchSeq, targetSeq, maxMismatches, circular = false
7008
6893
  return matches;
7009
6894
  }
7010
6895
  __name(findApproxMatches, "findApproxMatches");
6896
+ var spliceString$1;
6897
+ var hasRequiredSpliceString;
6898
+ function requireSpliceString() {
6899
+ if (hasRequiredSpliceString) return spliceString$1;
6900
+ hasRequiredSpliceString = 1;
6901
+ spliceString$1 = /* @__PURE__ */ __name(function spliceSlice(str, index, count, add) {
6902
+ return str.slice(0, index) + (add || "") + str.slice(index + count);
6903
+ }, "spliceSlice");
6904
+ return spliceString$1;
6905
+ }
6906
+ __name(requireSpliceString, "requireSpliceString");
6907
+ var spliceStringExports = requireSpliceString();
6908
+ const spliceString = /* @__PURE__ */ getDefaultExportFromCjs(spliceStringExports);
7011
6909
  function adjustBpsToReplaceOrInsert(bpString, insertString = "", caretPositionOrRange) {
7012
6910
  let stringToReturn = bpString;
7013
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange && caretPositionOrRange.start > -1) {
6911
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7014
6912
  if (getRangeLength(caretPositionOrRange, bpString.length) === bpString.length) {
7015
6913
  return insertString;
7016
6914
  }
7017
6915
  const ranges = splitRangeIntoTwoPartsIfItIsCircular(
7018
- invertRange(
7019
- caretPositionOrRange,
7020
- bpString.length
7021
- ),
7022
- bpString.length
6916
+ invertRange(caretPositionOrRange, bpString.length)
7023
6917
  );
7024
6918
  stringToReturn = "";
7025
6919
  ranges.forEach((range, index) => {
@@ -7045,16 +6939,6 @@ function adjustBpsToReplaceOrInsert(bpString, insertString = "", caretPositionOr
7045
6939
  return stringToReturn;
7046
6940
  }
7047
6941
  __name(adjustBpsToReplaceOrInsert, "adjustBpsToReplaceOrInsert");
7048
- const spliceString = /* @__PURE__ */ __name((str, index, count, add) => {
7049
- let i = index;
7050
- if (i < 0) {
7051
- i = str.length + i;
7052
- if (i < 0) {
7053
- i = 0;
7054
- }
7055
- }
7056
- return str.slice(0, i) + (add || "") + str.slice(i + count);
7057
- }, "spliceString");
7058
6942
  function calculatePercentGC(bps) {
7059
6943
  return (bps.match(/[cg]/gi) || []).length / bps.length * 100 || 0;
7060
6944
  }
@@ -7080,17 +6964,11 @@ const calcTmMethods = {
7080
6964
  * monovalentCationConc - THe monovalent salt concentration. Defaults to 50e-3M.
7081
6965
  * return - Temperature for the given sequence, in Celsius.
7082
6966
  */
7083
- calculateTemperature: /* @__PURE__ */ __name(function(_sequence, {
7084
- type,
7085
- A,
7086
- R,
7087
- primerConc,
7088
- monovalentCationConc
7089
- } = {}) {
6967
+ calculateTemperature: /* @__PURE__ */ __name(function(_sequence, { type, A, R, primerConc, monovalentCationConc } = {}) {
7090
6968
  const sequence = (_sequence || "").toLowerCase();
7091
6969
  if (typeof type === "undefined") {
7092
6970
  type = this.TABLE_BRESLAUER;
7093
- } else if (type !== this.TABLE_BRESLAUER && type !== this.TABLE_UNIFIED && type !== this.TABLE_SUGIMOTO) {
6971
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
7094
6972
  throw new Error("Invalid table type!");
7095
6973
  }
7096
6974
  if (!A) {
@@ -7106,14 +6984,11 @@ const calcTmMethods = {
7106
6984
  monovalentCationConc = this.monovalentCationConc;
7107
6985
  }
7108
6986
  const sequenceLength = sequence.length;
7109
- if (sequenceLength === 0) {
6987
+ if (sequenceLength == 0) {
7110
6988
  return 0;
7111
6989
  }
7112
6990
  const deltaHTable = this.getDeltaHTable(type);
7113
6991
  const deltaSTable = this.getDeltaSTable(type);
7114
- if (!deltaHTable || !deltaSTable) {
7115
- return 0;
7116
- }
7117
6992
  const neighbors = [];
7118
6993
  neighbors.push(this.calculateReps(sequence, "aa"));
7119
6994
  neighbors.push(this.calculateNumberOfOccurrences(sequence, "at"));
@@ -7147,7 +7022,7 @@ const calcTmMethods = {
7147
7022
  * @return {Number[]} deltaH table for given algorithm.
7148
7023
  */
7149
7024
  getDeltaHTable: /* @__PURE__ */ __name(function(type) {
7150
- if (type === this.TABLE_BRESLAUER) {
7025
+ if (type == this.TABLE_BRESLAUER) {
7151
7026
  return [
7152
7027
  9.1,
7153
7028
  8.6,
@@ -7166,7 +7041,7 @@ const calcTmMethods = {
7166
7041
  6.5,
7167
7042
  11.1
7168
7043
  ];
7169
- } else if (type === this.TABLE_SUGIMOTO) {
7044
+ } else if (type == this.TABLE_SUGIMOTO) {
7170
7045
  return [
7171
7046
  8,
7172
7047
  5.6,
@@ -7185,7 +7060,7 @@ const calcTmMethods = {
7185
7060
  9.4,
7186
7061
  11.9
7187
7062
  ];
7188
- } else if (type === this.TABLE_UNIFIED) {
7063
+ } else if (type == this.TABLE_UNIFIED) {
7189
7064
  return [
7190
7065
  7.9,
7191
7066
  7.2,
@@ -7208,6 +7083,39 @@ const calcTmMethods = {
7208
7083
  return null;
7209
7084
  }
7210
7085
  }, "getDeltaHTable"),
7086
+ // "AA/TT": -7.9, 7.9
7087
+ // "AT/TA": -7.2, 7.2
7088
+ // "AC/TG": -8.4, 8.4
7089
+ // "AG/TC": -7.8, 7.8
7090
+ // "TT/AA": -7.9, 7.9
7091
+ // "TA/AT": -7.2, 7.2
7092
+ // "TG/AC": -8.5, 8.2
7093
+ // "TC/AG": -8.2, 8.5
7094
+ // "CC/GG": -8.0, 8.0
7095
+ // "CA/GT": -8.5, 8.5
7096
+ // "CT/GA": -7.8, 7.8
7097
+ // "CG/GC": -10.6, 10.6
7098
+ // "GG/CC": -8.0, 8.0
7099
+ // "GA/CT": -8.2, 8.2,
7100
+ // "GT/CA": -8.4, 8.4
7101
+ // "GC/CG": -9.8, 9.8
7102
+ // aa, at, ac, ag, tt, ta, tc, tg, cc, ca, ct, cg, gg, ga, gt, gc
7103
+ // "AA/TT": -22.2,22.2,
7104
+ // "AT/TA": -20.4,20.4,
7105
+ // "AC/TG": -22.4,22.4,
7106
+ // "AG/TC": -21.0,21.0,
7107
+ // "TT/AA": -22.2,22.2,
7108
+ // "TA/AT": -21.3,21.3,
7109
+ // "TC/AG": -22.2,22.2,
7110
+ // "TG/AC": -22.7,22.7,
7111
+ // "CC/GG": -19.9,19.9,
7112
+ // "CA/GT": -22.7,22.7,
7113
+ // "CT/GA": -21.0,21.0,
7114
+ // "CG/GC": -27.2,27.2,
7115
+ // "GG/CC": -19.9,19.9,
7116
+ // "GT/CA": -22.4,22.2,
7117
+ // "GA/CT": -22.2,22.4,
7118
+ // "GC/CG": -24.4,24.4
7211
7119
  /**
7212
7120
  * @private
7213
7121
  * Function to return deltaS table for given algorithm.
@@ -7215,7 +7123,7 @@ const calcTmMethods = {
7215
7123
  * @return {Number[]} deltaS table for given algorithm.
7216
7124
  */
7217
7125
  getDeltaSTable: /* @__PURE__ */ __name(function(type) {
7218
- if (type === this.TABLE_BRESLAUER) {
7126
+ if (type == this.TABLE_BRESLAUER) {
7219
7127
  return [
7220
7128
  24,
7221
7129
  23.9,
@@ -7234,7 +7142,7 @@ const calcTmMethods = {
7234
7142
  17.3,
7235
7143
  26.7
7236
7144
  ];
7237
- } else if (type === this.TABLE_SUGIMOTO) {
7145
+ } else if (type == this.TABLE_SUGIMOTO) {
7238
7146
  return [
7239
7147
  21.9,
7240
7148
  15.2,
@@ -7253,7 +7161,7 @@ const calcTmMethods = {
7253
7161
  25.5,
7254
7162
  29
7255
7163
  ];
7256
- } else if (type === this.TABLE_UNIFIED) {
7164
+ } else if (type == this.TABLE_UNIFIED) {
7257
7165
  return [
7258
7166
  22.2,
7259
7167
  20.4,
@@ -7287,14 +7195,14 @@ const calcTmMethods = {
7287
7195
  */
7288
7196
  calculateReps: /* @__PURE__ */ __name(function(sequence, target) {
7289
7197
  const sequenceLength = sequence.length;
7290
- if (sequenceLength === 0) {
7198
+ if (sequenceLength == 0) {
7291
7199
  return 0;
7292
7200
  }
7293
7201
  let numFound = 0;
7294
7202
  let seqOffset = 0;
7295
7203
  while (true) {
7296
7204
  const foundSeq = sequence.indexOf(target, seqOffset);
7297
- if (foundSeq === -1) {
7205
+ if (foundSeq == -1) {
7298
7206
  break;
7299
7207
  }
7300
7208
  seqOffset = foundSeq + 1;
@@ -7314,7 +7222,7 @@ const calcTmMethods = {
7314
7222
  */
7315
7223
  calculateNumberOfOccurrences: /* @__PURE__ */ __name(function(sequence, target) {
7316
7224
  const sequenceLength = sequence.length;
7317
- if (sequenceLength === 0) {
7225
+ if (sequenceLength == 0) {
7318
7226
  return 0;
7319
7227
  }
7320
7228
  const numberFound = sequence.split(target).length - 1;
@@ -7349,11 +7257,11 @@ function rotateBpsToPosition(bps, caretPosition) {
7349
7257
  __name(rotateBpsToPosition, "rotateBpsToPosition");
7350
7258
  function arrayRotate(arr, count) {
7351
7259
  count -= arr.length * Math.floor(count / arr.length);
7352
- arr.push(...arr.splice(0, count));
7260
+ arr.push.apply(arr, arr.splice(0, count));
7353
7261
  return arr;
7354
7262
  }
7355
7263
  __name(arrayRotate, "arrayRotate");
7356
- function rotateSequenceDataToPosition(sequenceData, caretPosition, options = {}) {
7264
+ function rotateSequenceDataToPosition(sequenceData, caretPosition, options) {
7357
7265
  const newSequenceData = tidyUpSequenceData(sequenceData, __spreadValues({
7358
7266
  doNotRemoveInvalidChars: true
7359
7267
  }, options));
@@ -7401,24 +7309,16 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7401
7309
  }, options));
7402
7310
  const newSequenceData = cloneDeep(existingSequenceData);
7403
7311
  const insertLength = sequenceDataToInsert.isProtein && sequenceDataToInsert.proteinSequence ? sequenceDataToInsert.proteinSequence.length * 3 : sequenceDataToInsert.sequence.length;
7404
- let caretPosition = typeof caretPositionOrRange === "number" ? caretPositionOrRange : caretPositionOrRange.start;
7405
- const isInsertSameLengthAsSelection = typeof caretPositionOrRange !== "number" && sequenceDataToInsert.sequence.length === getRangeLength(
7406
- caretPositionOrRange,
7407
- existingSequenceData.sequence.length
7408
- );
7409
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1 && getRangeLength(
7312
+ let caretPosition = caretPositionOrRange;
7313
+ const isInsertSameLengthAsSelection = sequenceDataToInsert.sequence.length === getRangeLength(caretPositionOrRange, existingSequenceData.sequence.length);
7314
+ if (caretPositionOrRange.start > -1 && getRangeLength(
7410
7315
  caretPositionOrRange,
7411
7316
  existingSequenceData.sequence.length
7412
7317
  ) === existingSequenceData.sequence.length) {
7413
- const emptyAnnotations = modifiableTypes.reduce(
7414
- (acc, type) => {
7415
- acc[type] = [];
7416
- return acc;
7417
- },
7418
- {}
7419
- );
7420
7318
  existingSequenceData = tidyUpSequenceData(
7421
- __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), emptyAnnotations), {
7319
+ __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), modifiableTypes.reduce((acc, type) => {
7320
+ return acc[type] = [];
7321
+ }, {})), {
7422
7322
  sequence: "",
7423
7323
  doNotRemoveInvalidChars: true,
7424
7324
  proteinSequence: "",
@@ -7428,7 +7328,7 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7428
7328
  );
7429
7329
  newSequenceData.chromatogramData = void 0;
7430
7330
  } else if (newSequenceData.chromatogramData && newSequenceData.chromatogramData.baseTraces) {
7431
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7331
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7432
7332
  if (caretPositionOrRange.start > caretPositionOrRange.end) {
7433
7333
  newSequenceData.chromatogramData = trimChromatogram({
7434
7334
  chromatogramData: newSequenceData.chromatogramData,
@@ -7438,16 +7338,14 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7438
7338
  },
7439
7339
  justBaseCalls: isInsertSameLengthAsSelection
7440
7340
  });
7441
- if (newSequenceData.chromatogramData) {
7442
- newSequenceData.chromatogramData = trimChromatogram({
7443
- chromatogramData: newSequenceData.chromatogramData,
7444
- range: {
7445
- start: 0,
7446
- end: caretPositionOrRange.end
7447
- },
7448
- justBaseCalls: isInsertSameLengthAsSelection
7449
- });
7450
- }
7341
+ newSequenceData.chromatogramData = trimChromatogram({
7342
+ chromatogramData: newSequenceData.chromatogramData,
7343
+ range: {
7344
+ start: 0,
7345
+ end: caretPositionOrRange.end
7346
+ },
7347
+ justBaseCalls: isInsertSameLengthAsSelection
7348
+ });
7451
7349
  } else {
7452
7350
  newSequenceData.chromatogramData = trimChromatogram({
7453
7351
  chromatogramData: newSequenceData.chromatogramData,
@@ -7459,10 +7357,10 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7459
7357
  });
7460
7358
  }
7461
7359
  }
7462
- if (sequenceDataToInsert.sequence && newSequenceData.chromatogramData) {
7360
+ if (sequenceDataToInsert.sequence) {
7463
7361
  insertIntoChromatogram({
7464
7362
  chromatogramData: newSequenceData.chromatogramData,
7465
- caretPosition: typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7363
+ caretPosition: caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7466
7364
  seqToInsert: sequenceDataToInsert.sequence,
7467
7365
  justBaseCalls: isInsertSameLengthAsSelection
7468
7366
  });
@@ -7475,15 +7373,14 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7475
7373
  );
7476
7374
  newSequenceData.size = newSequenceData.sequence.length;
7477
7375
  newSequenceData.proteinSequence = adjustBpsToReplaceOrInsert(
7478
- existingSequenceData.proteinSequence || "",
7479
- sequenceDataToInsert.proteinSequence || "",
7376
+ existingSequenceData.proteinSequence,
7377
+ sequenceDataToInsert.proteinSequence,
7480
7378
  convertDnaCaretPositionOrRangeToAA(caretPositionOrRange)
7481
7379
  );
7482
- newSequenceData.proteinSize = (newSequenceData.proteinSequence || "").length;
7380
+ newSequenceData.proteinSize = newSequenceData.proteinSequence.length;
7483
7381
  modifiableTypes.forEach((annotationType) => {
7484
7382
  let existingAnnotations = existingSequenceData[annotationType];
7485
- if (!existingAnnotations) return;
7486
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7383
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7487
7384
  const range = caretPositionOrRange;
7488
7385
  caretPosition = range.start > range.end ? 0 : range.start;
7489
7386
  existingAnnotations = adjustAnnotationsToDelete(
@@ -7493,23 +7390,22 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7493
7390
  );
7494
7391
  }
7495
7392
  newSequenceData[annotationType] = [];
7496
- const annotationsToInsert = sequenceDataToInsert[annotationType];
7497
- if (newSequenceData[annotationType]) {
7498
- newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7499
- adjustAnnotationsToInsert(
7500
- existingAnnotations,
7501
- caretPosition,
7502
- insertLength
7503
- )
7504
- );
7505
- if (annotationsToInsert) {
7506
- newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7507
- adjustAnnotationsToInsert(annotationsToInsert, 0, caretPosition)
7508
- );
7509
- }
7510
- }
7393
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7394
+ adjustAnnotationsToInsert(
7395
+ existingAnnotations,
7396
+ caretPosition,
7397
+ insertLength
7398
+ )
7399
+ );
7400
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7401
+ adjustAnnotationsToInsert(
7402
+ sequenceDataToInsert[annotationType],
7403
+ 0,
7404
+ caretPosition
7405
+ )
7406
+ );
7511
7407
  });
7512
- if (maintainOriginSplit && typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > caretPositionOrRange.end) {
7408
+ if (maintainOriginSplit && caretPositionOrRange && caretPositionOrRange.start > caretPositionOrRange.end) {
7513
7409
  const caretPosToRotateTo = existingSequenceData.sequence.length - caretPositionOrRange.start;
7514
7410
  return rotateSequenceDataToPosition(
7515
7411
  newSequenceData,
@@ -7527,7 +7423,6 @@ function adjustAnnotationsToDelete(annotationsToBeAdjusted, range, maxLength) {
7527
7423
  maxLength
7528
7424
  );
7529
7425
  const newLocations = annotation.locations && annotation.locations.map((loc) => adjustRangeToDeletionOfAnotherRange(loc, range, maxLength)).filter((range2) => !!range2);
7530
- if (!newRange) return null;
7531
7426
  if (newLocations && newLocations.length) {
7532
7427
  return __spreadValues(__spreadProps(__spreadValues({}, newRange), {
7533
7428
  start: newLocations[0].start,
@@ -7546,13 +7441,11 @@ function insertIntoChromatogram({
7546
7441
  justBaseCalls
7547
7442
  }) {
7548
7443
  if (!seqToInsert.length) return;
7549
- if (chromatogramData.baseCalls) {
7550
- chromatogramData.baseCalls.splice(
7551
- caretPosition,
7552
- 0,
7553
- ...seqToInsert.split("")
7554
- );
7555
- }
7444
+ chromatogramData.baseCalls && chromatogramData.baseCalls.splice(
7445
+ caretPosition,
7446
+ 0,
7447
+ ...seqToInsert.split("")
7448
+ );
7556
7449
  if (justBaseCalls) {
7557
7450
  return chromatogramData;
7558
7451
  }
@@ -7568,20 +7461,8 @@ function insertIntoChromatogram({
7568
7461
  tTrace: toPush
7569
7462
  });
7570
7463
  }
7571
- if (chromatogramData.baseTraces) {
7572
- chromatogramData.baseTraces.splice(
7573
- caretPosition,
7574
- 0,
7575
- ...baseTracesToInsert
7576
- );
7577
- }
7578
- if (chromatogramData.qualNums) {
7579
- chromatogramData.qualNums.splice(
7580
- caretPosition,
7581
- 0,
7582
- ...qualNumsToInsert
7583
- );
7584
- }
7464
+ chromatogramData.baseTraces && chromatogramData.baseTraces.splice(caretPosition, 0, ...baseTracesToInsert);
7465
+ chromatogramData.qualNums && chromatogramData.qualNums.splice(caretPosition, 0, ...qualNumsToInsert);
7585
7466
  return chromatogramData;
7586
7467
  }
7587
7468
  __name(insertIntoChromatogram, "insertIntoChromatogram");
@@ -7594,23 +7475,17 @@ function trimChromatogram({
7594
7475
  "baseCalls",
7595
7476
  ...justBaseCalls ? [] : ["qualNums", "baseTraces", "basePos"]
7596
7477
  ].forEach((type) => {
7597
- if (chromatogramData[type]) {
7598
- chromatogramData[type].splice(start, end - start + 1);
7599
- }
7478
+ chromatogramData[type] && chromatogramData[type].splice(start, end - start + 1);
7600
7479
  });
7601
7480
  return chromatogramData;
7602
7481
  }
7603
7482
  __name(trimChromatogram, "trimChromatogram");
7604
7483
  function deleteSequenceDataAtRange(sequenceData, range) {
7605
- return insertSequenceDataAtPositionOrRange(
7606
- { sequence: "" },
7607
- sequenceData,
7608
- range
7609
- );
7484
+ return insertSequenceDataAtPositionOrRange({}, sequenceData, range);
7610
7485
  }
7611
7486
  __name(deleteSequenceDataAtRange, "deleteSequenceDataAtRange");
7612
7487
  function doesEnzymeChopOutsideOfRecognitionSite(enzyme) {
7613
- if (enzyme.topSnipOffset && enzyme.bottomSnipOffset && (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length)) {
7488
+ if (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length) {
7614
7489
  return true;
7615
7490
  } else {
7616
7491
  return false;
@@ -15242,10 +15117,10 @@ defaultEnzymes.forEach((name) => {
15242
15117
  defaultEnzymesByName[name] = aliasedEnzymesByName[name];
15243
15118
  });
15244
15119
  function generateAnnotations(numberOfAnnotationsToGenerate, start, end, maxLength) {
15245
- const result = [];
15120
+ const result = {};
15246
15121
  for (let i = 0; i < numberOfAnnotationsToGenerate; i++) {
15247
15122
  const annotation = generateAnnotation(start, end, maxLength);
15248
- result.push(annotation);
15123
+ result[annotation.id] = annotation;
15249
15124
  }
15250
15125
  return result;
15251
15126
  }
@@ -15273,16 +15148,16 @@ function generateSequenceData({
15273
15148
  numPrimers,
15274
15149
  numTranslations
15275
15150
  } = {}) {
15276
- const proteinSequence = isProtein ? generateSequence(sequenceLength, true) : "";
15277
- const sequence = !isProtein ? generateSequence(sequenceLength) : "";
15151
+ const proteinSequence = isProtein && generateSequence(sequenceLength, true);
15152
+ const sequence = !isProtein && generateSequence(sequenceLength);
15278
15153
  return {
15279
15154
  circular: isProtein ? false : Math.random() > 0.5,
15280
- name: "p-" + Math.floor(Math.random() * 100),
15155
+ name: "p-" + Math.floor(Math.random * 100),
15281
15156
  description: "",
15282
- isProtein: !!isProtein,
15157
+ isProtein,
15283
15158
  sequence,
15284
15159
  proteinSequence,
15285
- translations: isProtein ? [] : generateAnnotations(
15160
+ translations: isProtein ? void 0 : generateAnnotations(
15286
15161
  numTranslations || 5,
15287
15162
  0,
15288
15163
  sequenceLength - 1,
@@ -15294,7 +15169,7 @@ function generateSequenceData({
15294
15169
  sequenceLength - 1,
15295
15170
  sequenceLength / 3
15296
15171
  ),
15297
- primers: isProtein ? [] : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15172
+ primers: isProtein ? void 0 : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15298
15173
  parts: generateAnnotations(
15299
15174
  numParts || 10,
15300
15175
  0,
@@ -15306,14 +15181,15 @@ function generateSequenceData({
15306
15181
  __name(generateSequenceData, "generateSequenceData");
15307
15182
  function generateSequence(m = 9, isProtein) {
15308
15183
  let s = "";
15309
- const r = isProtein ? "ACDEFGHIKLMNPQRSTVWY" : "gatc";
15184
+ const r = isProtein ? "" : "gatc";
15310
15185
  for (let i = 0; i < m; i++) {
15311
15186
  s += r.charAt(Math.floor(Math.random() * r.length));
15312
15187
  }
15313
15188
  return s;
15314
15189
  }
15315
15190
  __name(generateSequence, "generateSequence");
15316
- function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart = 0, isLinear) {
15191
+ function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart, isLinear) {
15192
+ if (!positionStart) positionStart = 0;
15317
15193
  if (sequenceToSearch.length < overlapSequence.length) {
15318
15194
  return null;
15319
15195
  }
@@ -15331,9 +15207,6 @@ function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSe
15331
15207
  index = result.index;
15332
15208
  distance = newDistance;
15333
15209
  }
15334
- if (index === void 0) {
15335
- return null;
15336
- }
15337
15210
  return normalizeRange(
15338
15211
  {
15339
15212
  start: index,
@@ -15378,11 +15251,9 @@ function getOrfsFromSequence(options) {
15378
15251
  internalStartCodonIndices: [],
15379
15252
  frame: start % 3,
15380
15253
  forward,
15381
- // annotationTypePlural: "orfs",
15254
+ annotationTypePlural: "orfs",
15382
15255
  isOrf: true,
15383
- id: shortid(),
15384
- type: "orf",
15385
- name: "ORF"
15256
+ id: shortid()
15386
15257
  });
15387
15258
  }
15388
15259
  }
@@ -15486,10 +15357,7 @@ function findSequenceMatchesTopStrand(sequence, searchString, options = {}) {
15486
15357
  true
15487
15358
  );
15488
15359
  } else {
15489
- searchStringToUse = convertAmbiguousStringToRegex(
15490
- searchStringToUse,
15491
- false
15492
- );
15360
+ searchStringToUse = convertAmbiguousStringToRegex(searchStringToUse);
15493
15361
  }
15494
15362
  }
15495
15363
  if (!searchStringToUse) return [];
@@ -15609,9 +15477,7 @@ function getCodonRangeForAASliver(aminoAcidPositionInSequence, aminoAcidSliver,
15609
15477
  }
15610
15478
  __name(getCodonRangeForAASliver, "getCodonRangeForAASliver");
15611
15479
  function getComplementAminoAcidStringFromSequenceString(sequenceString) {
15612
- const aaString = getAminoAcidStringFromSequenceString(sequenceString, {
15613
- doNotExcludeAsterisk: true
15614
- });
15480
+ const aaString = getAminoAcidStringFromSequenceString(sequenceString, true);
15615
15481
  return aaString.split("").reverse().join("");
15616
15482
  }
15617
15483
  __name(getComplementAminoAcidStringFromSequenceString, "getComplementAminoAcidStringFromSequenceString");
@@ -15649,30 +15515,26 @@ function getSequenceDataBetweenRange(seqData, range, options = {}) {
15649
15515
  sequence: getSequenceWithinRange(range, seqDataToUse.sequence),
15650
15516
  proteinSequence: getSequenceWithinRange(
15651
15517
  convertDnaCaretPositionOrRangeToAA(range),
15652
- seqDataToUse.proteinSequence || ""
15518
+ seqDataToUse.proteinSequence
15653
15519
  )
15654
15520
  },
15655
- annotationTypes.reduce(
15656
- (acc, type) => {
15657
- if (exclude[type]) {
15658
- acc[type] = [];
15659
- return acc;
15660
- }
15661
- acc[type] = getAnnotationsBetweenRange(
15662
- seqDataToUse[type],
15663
- range,
15664
- seqDataToUse.sequence.length,
15665
- excludePartial[type]
15666
- );
15521
+ annotationTypes.reduce((acc, type) => {
15522
+ if (exclude[type]) {
15523
+ acc[type] = [];
15667
15524
  return acc;
15668
- },
15669
- {}
15670
- )
15525
+ }
15526
+ acc[type] = getAnnotationsBetweenRange(
15527
+ seqDataToUse[type],
15528
+ range,
15529
+ seqDataToUse.sequence.length,
15530
+ excludePartial[type]
15531
+ );
15532
+ return acc;
15533
+ }, {})
15671
15534
  );
15672
15535
  if (range.overlapsSelf) {
15673
15536
  const extendedSeqData = insertSequenceDataAtPositionOrRange(
15674
15537
  { sequence: seqDataToReturn.sequence },
15675
- // Wrapping in object as per assumed signature
15676
15538
  seqDataToUse,
15677
15539
  range.start
15678
15540
  );
@@ -15713,6 +15575,15 @@ function getAnnotationsBetweenRange(annotationsToBeAdjusted, range, maxLength, s
15713
15575
  }
15714
15576
  const overlaps = getZeroedRangeOverlaps(annotation, range, maxLength).map(
15715
15577
  (overlap) => {
15578
+ const allLocations = annotation.locations;
15579
+ if (allLocations && allLocations.length) {
15580
+ const newLocations = allLocations.filter((loc) => {
15581
+ return isRangeWithinRange(loc, overlap, maxLength);
15582
+ });
15583
+ return assignIn({}, annotation, overlap, {
15584
+ locations: newLocations
15585
+ });
15586
+ }
15716
15587
  return assignIn({}, annotation, overlap);
15717
15588
  }
15718
15589
  );
@@ -15737,8 +15608,7 @@ function getAnnotationsBetweenRange(annotationsToBeAdjusted, range, maxLength, s
15737
15608
  __name(getAnnotationsBetweenRange, "getAnnotationsBetweenRange");
15738
15609
  function getComplementSequenceAndAnnotations(pSeqObj, options = {}) {
15739
15610
  const seqObj = tidyUpSequenceData(
15740
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15741
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15611
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15742
15612
  options
15743
15613
  );
15744
15614
  const newSeqObj = Object.assign({}, seqObj, {
@@ -15753,7 +15623,7 @@ function getCutsiteType(restrictionEnzyme) {
15753
15623
  const { topSnipOffset, bottomSnipOffset } = restrictionEnzyme;
15754
15624
  if (topSnipOffset === bottomSnipOffset) {
15755
15625
  return "blunt";
15756
- } else if (topSnipOffset !== void 0 && bottomSnipOffset !== void 0 && topSnipOffset < bottomSnipOffset) {
15626
+ } else if (topSnipOffset < bottomSnipOffset) {
15757
15627
  return "5' overhang";
15758
15628
  } else {
15759
15629
  return "3' overhang";
@@ -15787,7 +15657,7 @@ function getLeftAndRightOfSequenceInRangeGivenPosition(range, position, sequence
15787
15657
  leftHandSide: "",
15788
15658
  rightHandSide: ""
15789
15659
  };
15790
- if (isPositionWithinRange(position, range, sequence.length)) {
15660
+ if (isPositionWithinRange(position, range)) {
15791
15661
  result.leftHandSide = getSequenceWithinRange(
15792
15662
  {
15793
15663
  start: range.start,
@@ -15827,13 +15697,13 @@ function getOverlapBetweenTwoSequences(sequenceToFind, sequenceToSearchIn) {
15827
15697
  }
15828
15698
  }
15829
15699
  __name(getOverlapBetweenTwoSequences, "getOverlapBetweenTwoSequences");
15830
- function getPossiblePartsFromSequenceAndEnzymes(seqData, restrictionEnzymes) {
15831
- const enzymes = Array.isArray(restrictionEnzymes) ? restrictionEnzymes : [restrictionEnzymes];
15700
+ function getPossiblePartsFromSequenceAndEnzyme(seqData, restrictionEnzymes) {
15701
+ restrictionEnzymes = restrictionEnzymes.length ? restrictionEnzymes : [restrictionEnzymes];
15832
15702
  const bps = seqData.sequence;
15833
15703
  const seqLen = bps.length;
15834
- const circular = seqData.circular || false;
15704
+ const circular = seqData.circular;
15835
15705
  let cutsites = [];
15836
- enzymes.forEach((enzyme) => {
15706
+ restrictionEnzymes.forEach((enzyme) => {
15837
15707
  const newCutsites = cutSequenceByRestrictionEnzyme(bps, circular, enzyme);
15838
15708
  cutsites = cutsites.concat(newCutsites);
15839
15709
  });
@@ -15874,13 +15744,13 @@ function getPossiblePartsFromSequenceAndEnzymes(seqData, restrictionEnzymes) {
15874
15744
  return parts;
15875
15745
  }
15876
15746
  }
15877
- __name(getPossiblePartsFromSequenceAndEnzymes, "getPossiblePartsFromSequenceAndEnzymes");
15747
+ __name(getPossiblePartsFromSequenceAndEnzyme, "getPossiblePartsFromSequenceAndEnzyme");
15878
15748
  function getPartBetweenEnzymesWithInclusiveOverhangs(cut1, cut2, seqLen) {
15879
15749
  const firstCutOffset = getEnzymeRelativeOffset(cut1.restrictionEnzyme);
15880
15750
  const secondCutOffset = getEnzymeRelativeOffset(cut2.restrictionEnzyme);
15881
- const start = (cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition) || 0;
15751
+ const start = cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition;
15882
15752
  const end = normalizePositionByRangeLength(
15883
- (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition || 0 : cut2.topSnipPosition || 0) - 1,
15753
+ (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition : cut2.topSnipPosition) - 1,
15884
15754
  seqLen
15885
15755
  );
15886
15756
  return {
@@ -15891,20 +15761,20 @@ function getPartBetweenEnzymesWithInclusiveOverhangs(cut1, cut2, seqLen) {
15891
15761
  firstCut: cut1,
15892
15762
  //the offset is always counting with 0 being at the top snip position
15893
15763
  firstCutOffset,
15894
- firstCutOverhang: cut1.overhangBps || "",
15895
- firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps || "" : "",
15896
- firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps || "") : "",
15764
+ firstCutOverhang: cut1.overhangBps,
15765
+ firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps : "",
15766
+ firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps) : "",
15897
15767
  secondCut: cut2,
15898
15768
  //the offset is always counting with 0 being at the top snip position
15899
15769
  secondCutOffset,
15900
- secondCutOverhang: cut2.overhangBps || "",
15901
- secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps || "" : "",
15902
- secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps || "") : ""
15770
+ secondCutOverhang: cut2.overhangBps,
15771
+ secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps : "",
15772
+ secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps) : ""
15903
15773
  };
15904
15774
  }
15905
15775
  __name(getPartBetweenEnzymesWithInclusiveOverhangs, "getPartBetweenEnzymesWithInclusiveOverhangs");
15906
15776
  function getEnzymeRelativeOffset(enzyme) {
15907
- return (enzyme.bottomSnipOffset || 0) - (enzyme.topSnipOffset || 0);
15777
+ return enzyme.bottomSnipOffset - enzyme.topSnipOffset;
15908
15778
  }
15909
15779
  __name(getEnzymeRelativeOffset, "getEnzymeRelativeOffset");
15910
15780
  function pairwise(list) {
@@ -15920,8 +15790,6 @@ __name(pairwise, "pairwise");
15920
15790
  function getReverseAminoAcidStringFromSequenceString(sequenceString) {
15921
15791
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
15922
15792
  sequenceString,
15923
- false,
15924
- null,
15925
15793
  false
15926
15794
  );
15927
15795
  const aaArray = [];
@@ -15960,8 +15828,7 @@ function getReverseComplementAnnotation(annotation, sequenceLength) {
15960
15828
  __name(getReverseComplementAnnotation, "getReverseComplementAnnotation");
15961
15829
  function getReverseComplementSequenceAndAnnoations(pSeqObj, options = {}) {
15962
15830
  const seqObj = tidyUpSequenceData(
15963
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15964
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15831
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15965
15832
  __spreadValues({ doNotRemoveInvalidChars: true }, options)
15966
15833
  );
15967
15834
  const newSeqObj = Object.assign(
@@ -15970,20 +15837,17 @@ function getReverseComplementSequenceAndAnnoations(pSeqObj, options = {}) {
15970
15837
  {
15971
15838
  sequence: getReverseComplementSequenceString(seqObj.sequence)
15972
15839
  },
15973
- annotationTypes.reduce(
15974
- (acc, type) => {
15975
- if (seqObj[type]) {
15976
- acc[type] = map(seqObj[type], (annotation) => {
15977
- return getReverseComplementAnnotation(
15978
- annotation,
15979
- seqObj.sequence.length
15980
- );
15981
- });
15982
- }
15983
- return acc;
15984
- },
15985
- {}
15986
- )
15840
+ annotationTypes.reduce((acc, type) => {
15841
+ if (seqObj[type]) {
15842
+ acc[type] = map(seqObj[type], (annotation) => {
15843
+ return getReverseComplementAnnotation(
15844
+ annotation,
15845
+ seqObj.sequence.length
15846
+ );
15847
+ });
15848
+ }
15849
+ return acc;
15850
+ }, {})
15987
15851
  );
15988
15852
  return tidyUpSequenceData(newSeqObj, __spreadValues({
15989
15853
  doNotRemoveInvalidChars: true
@@ -16005,13 +15869,10 @@ __name(getReverseSequenceString, "getReverseSequenceString");
16005
15869
  function guessIfSequenceIsDnaAndNotProtein(seq, options = {}) {
16006
15870
  const { threshold = 0.9, loose } = options;
16007
15871
  const dnaLetters = options.dnaLetters || loose ? [...ambiguous_dna_letters.split(""), "U"] : ["G", "A", "T", "C", "U"];
16008
- const dnaLetterMap = dnaLetters.reduce(
16009
- (acc, letter) => {
16010
- acc[letter.toUpperCase()] = true;
16011
- return acc;
16012
- },
16013
- {}
16014
- );
15872
+ const dnaLetterMap = dnaLetters.reduce((acc, letter) => {
15873
+ acc[letter.toUpperCase()] = true;
15874
+ return acc;
15875
+ }, {});
16015
15876
  let count = 0;
16016
15877
  if (!seq || !seq.length) return true;
16017
15878
  for (let index = 0; index < seq.length; index++) {
@@ -16031,17 +15892,15 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16031
15892
  const yOffsetLevelMap = {};
16032
15893
  const wrappedAnnotations = {};
16033
15894
  forEach(annotations, (annotation) => {
16034
- var _a;
16035
15895
  const containsLocations = !!(annotation.locations && annotation.locations.length);
16036
15896
  if (annotation.overlapsSelf) {
16037
15897
  if (!wrappedAnnotations[annotation.id]) {
16038
15898
  mapAnnotationToRows({
16039
- annotation: __spreadProps(__spreadValues({}, annotation), {
15899
+ annotation: {
16040
15900
  start: 0,
16041
15901
  end: sequenceLength - 1,
16042
- id: `__tempAnnRemoveMe__${annotation.id}`,
16043
- overlapsSelf: false
16044
- }),
15902
+ id: `__tempAnnRemoveMe__${annotation.id}`
15903
+ },
16045
15904
  sequenceLength,
16046
15905
  bpsPerRow,
16047
15906
  annotationsToRowsMap,
@@ -16062,7 +15921,7 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16062
15921
  splitForwardReverse
16063
15922
  });
16064
15923
  if (containsLocations) {
16065
- (_a = annotation.locations) == null ? void 0 : _a.forEach((location) => {
15924
+ annotation.locations.forEach((location) => {
16066
15925
  mapAnnotationToRows({
16067
15926
  annotation,
16068
15927
  sequenceLength,
@@ -16078,7 +15937,7 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16078
15937
  forEach(annotationsToRowsMap, (annotationsForRow, i) => {
16079
15938
  annotationsToRowsMap[i] = filter(
16080
15939
  annotationsForRow,
16081
- (ann) => !startsWith(String(ann.id), "__tempAnnRemoveMe__")
15940
+ (ann) => !startsWith(ann.id, "__tempAnnRemoveMe__")
16082
15941
  );
16083
15942
  });
16084
15943
  return annotationsToRowsMap;
@@ -16120,13 +15979,6 @@ function mapAnnotationToRows({
16120
15979
  yOffset = ann.yOffset;
16121
15980
  }
16122
15981
  });
16123
- if (yOffset === void 0) {
16124
- annotationsForRow.forEach((ann) => {
16125
- if (ann.id === annotation.id) {
16126
- yOffset = ann.yOffset;
16127
- }
16128
- });
16129
- }
16130
15982
  } else {
16131
15983
  if (location) {
16132
15984
  annotationsForRow.forEach((ann) => {
@@ -16135,74 +15987,32 @@ function mapAnnotationToRows({
16135
15987
  }
16136
15988
  });
16137
15989
  } else {
16138
- if (index > 0 && annotationsForRow.length && annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
15990
+ if (index > 0 && //second half of an annotation range
15991
+ annotationsForRow.length && //there are already annotations within the row
15992
+ annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
16139
15993
  yOffset = annotationsForRow[annotationsForRow.length - 1].yOffset;
16140
15994
  } else {
16141
- const siblingRangesOnThisRow = ranges.slice(index + 1).filter((r) => {
16142
- const rStartRow = Math.floor(r.start / bpsPerRow);
16143
- const rEndRow = Math.floor(r.end / bpsPerRow);
16144
- return rowNumber >= rStartRow && rowNumber <= rEndRow;
16145
- });
16146
- if (siblingRangesOnThisRow.length > 0) {
16147
- let foundYOffset = -1;
16148
- yOffsetsForRow.some((rangesAlreadyAddedToYOffset, levelIndex) => {
16149
- const rangeBlocked = rangesAlreadyAddedToYOffset.some(
16150
- (comparisonRange) => {
16151
- return checkIfPotentiallyCircularRangesOverlap(
16152
- range,
16153
- comparisonRange
16154
- );
16155
- }
16156
- );
16157
- if (rangeBlocked) return false;
16158
- const siblingBlocked = siblingRangesOnThisRow.some(
16159
- (siblingRange) => {
16160
- return rangesAlreadyAddedToYOffset.some((comparisonRange) => {
16161
- return checkIfPotentiallyCircularRangesOverlap(
16162
- siblingRange,
16163
- comparisonRange
16164
- );
16165
- });
16166
- }
16167
- );
16168
- if (!siblingBlocked) {
16169
- foundYOffset = levelIndex;
16170
- return true;
16171
- }
16172
- return false;
16173
- });
16174
- if (foundYOffset > -1) {
16175
- yOffset = foundYOffset;
16176
- yOffsetsForRow[foundYOffset].push(range);
16177
- } else {
16178
- yOffset = yOffsetsForRow.length;
16179
- yOffsetsForRow.push([range]);
16180
- }
16181
- } else {
16182
- yOffset = getYOffsetForPotentiallyCircularRange(
16183
- range,
16184
- yOffsetsForRow,
16185
- false
16186
- );
16187
- }
16188
- }
16189
- if (yOffset !== void 0) {
16190
- if (!yOffsetsForRow[yOffset]) yOffsetsForRow[yOffset] = [];
16191
- yOffsetsForRow[yOffset].push({
16192
- start,
16193
- end
16194
- });
15995
+ yOffset = getYOffsetForPotentiallyCircularRange(
15996
+ annotation,
15997
+ yOffsetsForRow
15998
+ );
16195
15999
  }
16000
+ if (!yOffsetsForRow[yOffset]) yOffsetsForRow[yOffset] = [];
16001
+ yOffsetsForRow[yOffset].push({
16002
+ start,
16003
+ end
16004
+ });
16196
16005
  }
16197
16006
  }
16198
- annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, annotation), {
16007
+ annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues({
16199
16008
  id: annotation.id,
16200
16009
  annotation,
16201
16010
  start,
16202
16011
  end
16203
- }), containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16012
+ }, containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16204
16013
  yOffset,
16205
16014
  enclosingRangeType: range.type
16015
+ //either "beginning", "end" or "beginningAndEnd"
16206
16016
  }));
16207
16017
  }
16208
16018
  });
@@ -16212,14 +16022,10 @@ function prepareCircularViewData(sequenceData) {
16212
16022
  const clonedSeqData = cloneDeep(sequenceData);
16213
16023
  annotationTypes.forEach((annotationType) => {
16214
16024
  if (annotationType !== "cutsites") {
16215
- const annotations = clonedSeqData[annotationType];
16216
- if (annotations) {
16217
- const maxYOffset = getYOffsetsForPotentiallyCircularRanges(
16218
- annotations,
16219
- true
16220
- ).maxYOffset;
16221
- clonedSeqData[annotationType].maxYOffset = maxYOffset;
16222
- }
16025
+ const maxYOffset = getYOffsetsForPotentiallyCircularRanges(
16026
+ clonedSeqData[annotationType]
16027
+ ).maxYOffset;
16028
+ clonedSeqData[annotationType].maxYOffset = maxYOffset;
16223
16029
  }
16224
16030
  });
16225
16031
  return clonedSeqData;
@@ -16232,19 +16038,14 @@ function prepareRowData(sequenceData, bpsPerRow) {
16232
16038
  const rowMap = {};
16233
16039
  annotationTypes.forEach((type) => {
16234
16040
  rowMap[type] = mapAnnotationsToRows(
16235
- sequenceData[type] || [],
16041
+ sequenceData[type],
16236
16042
  sequenceLength,
16237
16043
  bpsPerRow,
16238
16044
  { splitForwardReverse: type === "primers" }
16239
16045
  );
16240
16046
  });
16241
16047
  for (let rowNumber = 0; rowNumber < totalRows; rowNumber++) {
16242
- const row = {
16243
- rowNumber,
16244
- start: 0,
16245
- end: 0,
16246
- sequence: ""
16247
- };
16048
+ const row = {};
16248
16049
  row.rowNumber = rowNumber;
16249
16050
  row.start = rowNumber * bpsPerRow;
16250
16051
  row.end = (rowNumber + 1) * bpsPerRow - 1 < sequenceLength ? (rowNumber + 1) * bpsPerRow - 1 : sequenceLength - 1;
@@ -16305,16 +16106,17 @@ function addGapsToSeqReads(refSeq, seqReads) {
16305
16106
  }
16306
16107
  }
16307
16108
  const refSeqWithGaps = insertGapsIntoRefSeq(refSeq.sequence, seqReads);
16308
- const seqReadsWithGaps = [{ name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }];
16109
+ const seqReadsWithGaps = [
16110
+ { name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }
16111
+ ];
16309
16112
  seqReads.forEach((seqRead) => {
16310
16113
  const allInsertionsInSeqReads = [];
16311
16114
  seqReads.forEach((seqRead2) => {
16312
16115
  const splitSeqRead = seqRead2.cigar.match(/([0-9]*[SMDI])/g);
16313
- if (!splitSeqRead) return;
16314
16116
  let adjustedSeqReadPos2 = cloneDeep(seqRead2.pos);
16315
16117
  if (splitSeqRead[0].slice(-1) === "S") {
16316
16118
  const numOfBeginningSoftClipped = splitSeqRead[0].slice(0, -1);
16317
- adjustedSeqReadPos2 = seqRead2.pos - Number(numOfBeginningSoftClipped);
16119
+ adjustedSeqReadPos2 = seqRead2.pos - numOfBeginningSoftClipped;
16318
16120
  }
16319
16121
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
16320
16122
  if (splitSeqRead[componentI].slice(-1) === "I") {
@@ -16340,11 +16142,10 @@ function addGapsToSeqReads(refSeq, seqReads) {
16340
16142
  }
16341
16143
  });
16342
16144
  const splitSeqReadChunk = seqRead.cigar.match(/([0-9]*[SMDI])/g);
16343
- if (!splitSeqReadChunk) return;
16344
16145
  let adjustedSeqReadPos = cloneDeep(seqRead.pos);
16345
16146
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16346
16147
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16347
- adjustedSeqReadPos = seqRead.pos - Number(numOfBeginningSoftClipped);
16148
+ adjustedSeqReadPos = seqRead.pos - numOfBeginningSoftClipped;
16348
16149
  }
16349
16150
  let eachSeqReadWithGaps = seqRead.seq.split("");
16350
16151
  if (adjustedSeqReadPos > 0) {
@@ -16532,11 +16333,10 @@ function addGapsToSeqReads(refSeq, seqReads) {
16532
16333
  const seqReadLengthsBeforeRefSeqStart = [];
16533
16334
  seqReads.forEach((seq) => {
16534
16335
  const splitSeqReadChunk = seq.cigar.match(/([0-9]*[SMDI])/g);
16535
- if (!splitSeqReadChunk) return;
16536
16336
  let adjustedSeqReadPos = cloneDeep(seq.pos);
16537
16337
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16538
16338
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16539
- adjustedSeqReadPos = seq.pos - Number(numOfBeginningSoftClipped);
16339
+ adjustedSeqReadPos = seq.pos - numOfBeginningSoftClipped;
16540
16340
  if (adjustedSeqReadPos < 0) {
16541
16341
  seqReadLengthsBeforeRefSeqStart.push(Math.abs(adjustedSeqReadPos));
16542
16342
  }
@@ -16546,14 +16346,13 @@ function addGapsToSeqReads(refSeq, seqReads) {
16546
16346
  for (let i = 1; i < seqReadsWithGaps.length; i++) {
16547
16347
  const eachSeqReadWithGaps = seqReadsWithGaps[i].sequence.split("");
16548
16348
  const splitSeqReadChunk = seqReads[i - 1].cigar.match(/([0-9]*[SMDI])/g);
16549
- if (!splitSeqReadChunk) continue;
16550
16349
  let adjustedSeqReadPos = cloneDeep(seqReads[i - 1].pos);
16551
16350
  if (seqReadLengthsBeforeRefSeqStart.length > 0) {
16552
16351
  longestSeqReadLength = Math.max(...seqReadLengthsBeforeRefSeqStart);
16553
16352
  }
16554
16353
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16555
16354
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16556
- adjustedSeqReadPos = seqReads[i - 1].pos - Number(numOfBeginningSoftClipped);
16355
+ adjustedSeqReadPos = seqReads[i - 1].pos - numOfBeginningSoftClipped;
16557
16356
  if (adjustedSeqReadPos > 0) {
16558
16357
  if (longestSeqReadLength > 0) {
16559
16358
  eachSeqReadWithGaps.unshift("-".repeat(longestSeqReadLength + 1));
@@ -16667,11 +16466,11 @@ function calculateNebTm(sequence, { monovalentCationConc = 0.05, primerConc = 5e
16667
16466
  for (let i = 0; i < seq.length; i++) {
16668
16467
  if (i === 0 || i === seq.length - 1) {
16669
16468
  if (seq[i] === "G" || seq[i] === "C") {
16670
- hi += sequenceToEnthalpyMap["initiationWithTerminalGC"];
16671
- si += sequenceToEntropyMap["initiationWithTerminalGC"];
16469
+ hi += sequenceToEnthalpyMap.initiationWithTerminalGC;
16470
+ si += sequenceToEntropyMap.initiationWithTerminalGC;
16672
16471
  } else if (seq[i] === "A" || seq[i] === "T") {
16673
- hi += sequenceToEnthalpyMap["initiationWithTerminalAT"];
16674
- si += sequenceToEntropyMap["initiationWithTerminalAT"];
16472
+ hi += sequenceToEnthalpyMap.initiationWithTerminalAT;
16473
+ si += sequenceToEntropyMap.initiationWithTerminalAT;
16675
16474
  }
16676
16475
  }
16677
16476
  if (i < seq.length - 1) {
@@ -16714,13 +16513,9 @@ function calculateNebTa(sequences, primerConc, { monovalentCationConc, polymeras
16714
16513
  `${sequences.length} sequences received when 2 primers were expected`
16715
16514
  );
16716
16515
  }
16717
- const meltingTemperatures = sequences.map((seq) => {
16718
- const tm = calculateNebTm(seq, { monovalentCationConc, primerConc });
16719
- if (typeof tm !== "number") {
16720
- throw new Error(`Invalid Tm calculated for ${seq}: ${tm}`);
16721
- }
16722
- return tm;
16723
- });
16516
+ const meltingTemperatures = sequences.map(
16517
+ (seq) => calculateNebTm(seq, primerConc, { monovalentCationConc })
16518
+ );
16724
16519
  meltingTemperatures.sort((a, b) => a - b);
16725
16520
  const lowerMeltingTemp = meltingTemperatures[0];
16726
16521
  let annealingTemp;
@@ -16797,17 +16592,17 @@ function isValidSequence(sequence) {
16797
16592
  __name(isValidSequence, "isValidSequence");
16798
16593
  function calculateSantaLuciaTm(sequence) {
16799
16594
  try {
16800
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16801
- if (!isValidSequence(seq)) {
16595
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16596
+ if (!isValidSequence(sequence)) {
16802
16597
  throw new Error("Invalid sequence: contains non-DNA characters");
16803
16598
  }
16804
- if (seq.length < 2) {
16599
+ if (sequence.length < 2) {
16805
16600
  throw new Error("Sequence too short: minimum length is 2 bases");
16806
16601
  }
16807
16602
  let deltaH = 0;
16808
16603
  let deltaS = 0;
16809
- for (let i = 0; i < seq.length - 1; i++) {
16810
- const dinucleotide = seq.substring(i, i + 2);
16604
+ for (let i = 0; i < sequence.length - 1; i++) {
16605
+ const dinucleotide = sequence.substring(i, i + 2);
16811
16606
  if (dinucleotide.includes("N")) {
16812
16607
  continue;
16813
16608
  }
@@ -16817,23 +16612,23 @@ function calculateSantaLuciaTm(sequence) {
16817
16612
  deltaS += params.dS;
16818
16613
  }
16819
16614
  }
16820
- const firstBase = seq[0];
16821
- const lastBase = seq[seq.length - 1];
16615
+ const firstBase = sequence[0];
16616
+ const lastBase = sequence[sequence.length - 1];
16822
16617
  if (firstBase === "G" || firstBase === "C") {
16823
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16824
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16618
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16619
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16825
16620
  } else {
16826
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16827
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16621
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16622
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16828
16623
  }
16829
16624
  if (lastBase === "G" || lastBase === "C") {
16830
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16831
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16625
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16626
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16832
16627
  } else {
16833
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16834
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16628
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16629
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16835
16630
  }
16836
- const nnPairs = seq.length - 1;
16631
+ const nnPairs = sequence.length - 1;
16837
16632
  deltaS = applySaltCorrection(deltaS, nnPairs);
16838
16633
  const C = PRIMER3_PARAMS.dnaConc * 1e-9;
16839
16634
  const Tm = deltaH * 1e3 / (deltaS + PRIMER3_PARAMS.R * Math.log(C / 4));
@@ -16845,16 +16640,16 @@ function calculateSantaLuciaTm(sequence) {
16845
16640
  __name(calculateSantaLuciaTm, "calculateSantaLuciaTm");
16846
16641
  function calculateEndStability(sequence) {
16847
16642
  try {
16848
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16849
- if (!isValidSequence(seq)) {
16643
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16644
+ if (!isValidSequence(sequence)) {
16850
16645
  throw new Error("Invalid sequence: contains non-DNA characters");
16851
16646
  }
16852
- if (seq.length < 5) {
16647
+ if (sequence.length < 5) {
16853
16648
  throw new Error(
16854
16649
  "Sequence too short: minimum length is 5 bases for end stability calculation"
16855
16650
  );
16856
16651
  }
16857
- const last5Bases = seq.substring(seq.length - 5);
16652
+ const last5Bases = sequence.substring(sequence.length - 5);
16858
16653
  let deltaH = 0;
16859
16654
  let deltaS = 0;
16860
16655
  for (let i = 0; i < 4; i++) {
@@ -16871,18 +16666,18 @@ function calculateEndStability(sequence) {
16871
16666
  const firstBase = last5Bases[0];
16872
16667
  const lastBase = last5Bases[last5Bases.length - 1];
16873
16668
  if (firstBase === "G" || firstBase === "C") {
16874
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16875
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16669
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16670
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16876
16671
  } else {
16877
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16878
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16672
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16673
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16879
16674
  }
16880
16675
  if (lastBase === "G" || lastBase === "C") {
16881
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16882
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16676
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16677
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16883
16678
  } else {
16884
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16885
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16679
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16680
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16886
16681
  }
16887
16682
  const T = 310.15;
16888
16683
  const deltaG = deltaH - T * deltaS / 1e3;
@@ -16897,40 +16692,24 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16897
16692
  const pairs = [];
16898
16693
  if (!cutsites.length) return [];
16899
16694
  let sortedCutsites = cutsites.sort((a, b) => {
16900
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
16695
+ return a.topSnipPosition - b.topSnipPosition;
16901
16696
  });
16902
16697
  if (!circular) {
16903
16698
  sortedCutsites = [
16904
16699
  {
16905
- start: 0,
16906
- end: 0,
16907
16700
  topSnipPosition: 0,
16908
16701
  bottomSnipPosition: 0,
16909
16702
  overhangSize: 0,
16910
16703
  type: "START_OR_END_OF_SEQ",
16911
- name: "START_OF_SEQ",
16912
- restrictionEnzyme: {
16913
- name: "START_OF_SEQ",
16914
- site: "",
16915
- forwardRegex: "",
16916
- reverseRegex: ""
16917
- }
16704
+ name: "START_OF_SEQ"
16918
16705
  },
16919
16706
  ...sortedCutsites,
16920
16707
  {
16921
- start: sequenceLength,
16922
- end: sequenceLength,
16923
16708
  topSnipPosition: sequenceLength,
16924
16709
  bottomSnipPosition: sequenceLength,
16925
16710
  overhangSize: 0,
16926
16711
  type: "START_OR_END_OF_SEQ",
16927
- name: "END_OF_SEQ",
16928
- restrictionEnzyme: {
16929
- name: "END_OF_SEQ",
16930
- site: "",
16931
- forwardRegex: "",
16932
- reverseRegex: ""
16933
- }
16712
+ name: "END_OF_SEQ"
16934
16713
  }
16935
16714
  ];
16936
16715
  }
@@ -16953,11 +16732,11 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16953
16732
  });
16954
16733
  pairs.forEach(([cut1, cut2]) => {
16955
16734
  const start = normalizePositionByRangeLength(
16956
- cut1.topSnipPosition || 0,
16735
+ cut1.topSnipPosition,
16957
16736
  sequenceLength
16958
16737
  );
16959
16738
  const end = normalizePositionByRangeLength(
16960
- (cut2.topSnipPosition || 0) - 1,
16739
+ cut2.topSnipPosition - 1,
16961
16740
  sequenceLength
16962
16741
  );
16963
16742
  const fragmentRange = { start, end };
@@ -16975,9 +16754,7 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16975
16754
  })
16976
16755
  }, fragmentRange), {
16977
16756
  size,
16978
- id,
16979
- name: `${cut1.restrictionEnzyme.name} -- ${cut2.restrictionEnzyme.name} ${size} bps`
16980
- // Add missing name property
16757
+ id
16981
16758
  }));
16982
16759
  });
16983
16760
  fragments.filter((fragment) => {
@@ -16989,33 +16766,21 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16989
16766
  return fragments;
16990
16767
  }
16991
16768
  __name(getDigestFragmentsForCutsites, "getDigestFragmentsForCutsites");
16992
- function getDigestFragmentsForRestrictionEnzymes(sequence, circular, contextEnzymes, options) {
16993
- const cutsitesByName = getCutsitesFromSequence(
16994
- sequence,
16995
- circular,
16996
- Array.isArray(contextEnzymes) ? contextEnzymes : [contextEnzymes]
16997
- );
16998
- const digest = computeDigestFragments(__spreadProps(__spreadValues({
16999
- cutsites: flatMap(cutsitesByName),
17000
- sequenceLength: sequence.length,
17001
- circular
17002
- }, options), {
17003
- computePartialDigest: (options == null ? void 0 : options.computePartialDigest) || (options == null ? void 0 : options.computePartialDigests)
17004
- }));
17005
- const fragments = uniqBy(digest.fragments, (fragment) => {
17006
- return `${fragment.start}-${fragment.end}-${fragment.size}`;
17007
- });
17008
- if (circular && ((options == null ? void 0 : options.computePartialDigest) || (options == null ? void 0 : options.computePartialDigests))) {
17009
- const fullLengthFragmentIndex = fragments.findIndex(
17010
- (f) => f.size === sequence.length
16769
+ function getDigestFragmentsForRestrictionEnzymes(sequence, circular, restrictionEnzymeOrEnzymes, opts) {
16770
+ const restrictionEnzymes = Array.isArray(restrictionEnzymeOrEnzymes) ? restrictionEnzymeOrEnzymes : [restrictionEnzymeOrEnzymes];
16771
+ const cutsites = flatMap(restrictionEnzymes, (restrictionEnzyme) => {
16772
+ return cutSequenceByRestrictionEnzyme(
16773
+ sequence,
16774
+ circular,
16775
+ restrictionEnzyme
17011
16776
  );
17012
- if (fullLengthFragmentIndex > -1) {
17013
- fragments.splice(fullLengthFragmentIndex, 1);
17014
- }
17015
- }
17016
- return fragments.sort((a, b) => {
17017
- return a.start - b.start || b.size - a.size;
17018
16777
  });
16778
+ return getDigestFragmentsForCutsites(
16779
+ sequence.length,
16780
+ circular,
16781
+ cutsites,
16782
+ opts
16783
+ );
17019
16784
  }
17020
16785
  __name(getDigestFragmentsForRestrictionEnzymes, "getDigestFragmentsForRestrictionEnzymes");
17021
16786
  function convertAACaretPositionOrRangeToDna(rangeOrCaret) {
@@ -17061,13 +16826,11 @@ function shiftAnnotationsByLen({
17061
16826
  }) {
17062
16827
  modifiableTypes.forEach((annotationType) => {
17063
16828
  const existingAnnotations = seqData[annotationType];
17064
- if (existingAnnotations) {
17065
- seqData[annotationType] = adjustAnnotationsToInsert(
17066
- existingAnnotations,
17067
- caretPosition,
17068
- insertLength
17069
- );
17070
- }
16829
+ seqData[annotationType] = adjustAnnotationsToInsert(
16830
+ existingAnnotations,
16831
+ caretPosition,
16832
+ insertLength
16833
+ );
17071
16834
  });
17072
16835
  }
17073
16836
  __name(shiftAnnotationsByLen, "shiftAnnotationsByLen");
@@ -17137,7 +16900,7 @@ exports.getMassOfAaString = getMassOfAaString;
17137
16900
  exports.getMergedFeatureMap = getMergedFeatureMap;
17138
16901
  exports.getOrfsFromSequence = getOrfsFromSequence;
17139
16902
  exports.getOverlapBetweenTwoSequences = getOverlapBetweenTwoSequences;
17140
- exports.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzymes;
16903
+ exports.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzyme;
17141
16904
  exports.getReverseAminoAcidStringFromSequenceString = getReverseAminoAcidStringFromSequenceString;
17142
16905
  exports.getReverseComplementAminoAcidStringFromSequenceString = getReverseComplementAminoAcidStringFromSequenceString;
17143
16906
  exports.getReverseComplementAnnotation = getReverseComplementAnnotation;