@teselagen/sequence-utils 0.3.38-beta.3 → 0.3.42

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 (172) hide show
  1. package/DNAComplementMap.d.ts +1 -1
  2. package/README.md +2 -8
  3. package/addGapsToSeqReads.d.ts +3 -16
  4. package/adjustAnnotationsToInsert.d.ts +1 -2
  5. package/adjustBpsToReplaceOrInsert.d.ts +1 -2
  6. package/aliasedEnzymesByName.d.ts +1 -37
  7. package/aminoAcidToDegenerateDnaMap.d.ts +31 -1
  8. package/aminoAcidToDegenerateRnaMap.d.ts +1 -1
  9. package/annotateSingleSeq.d.ts +4 -5
  10. package/annotationTypes.d.ts +2 -2
  11. package/autoAnnotate.d.ts +8 -17
  12. package/bioData.d.ts +58 -10
  13. package/calculateEndStability.d.ts +1 -1
  14. package/calculateNebTa.d.ts +1 -6
  15. package/calculateNebTm.d.ts +4 -6
  16. package/calculatePercentGC.d.ts +1 -1
  17. package/calculateSantaLuciaTm.d.ts +114 -28
  18. package/calculateTm.d.ts +1 -13
  19. package/computeDigestFragments.d.ts +24 -30
  20. package/condensePairwiseAlignmentDifferences.d.ts +1 -1
  21. package/convertAACaretPositionOrRangeToDna.d.ts +1 -2
  22. package/convertDnaCaretPositionOrRangeToAA.d.ts +1 -2
  23. package/cutSequenceByRestrictionEnzyme.d.ts +1 -2
  24. package/defaultEnzymesByName.d.ts +1 -2
  25. package/degenerateDnaToAminoAcidMap.d.ts +1 -1
  26. package/degenerateRnaToAminoAcidMap.d.ts +1 -1
  27. package/deleteSequenceDataAtRange.d.ts +1 -2
  28. package/diffUtils.d.ts +7 -9
  29. package/doesEnzymeChopOutsideOfRecognitionSite.d.ts +1 -2
  30. package/featureTypesAndColors.d.ts +6 -19
  31. package/filterSequenceString.d.ts +10 -14
  32. package/findApproxMatches.d.ts +1 -7
  33. package/findNearestRangeOfSequenceOverlapToPosition.d.ts +1 -2
  34. package/findOrfsInPlasmid.d.ts +11 -2
  35. package/findSequenceMatches.d.ts +1 -11
  36. package/generateAnnotations.d.ts +1 -2
  37. package/generateSequenceData.d.ts +13 -8
  38. package/getAllInsertionsInSeqReads.d.ts +1 -11
  39. package/getAminoAcidDataForEachBaseOfDna.d.ts +5 -6
  40. package/getAminoAcidFromSequenceTriplet.d.ts +1 -1
  41. package/getAminoAcidStringFromSequenceString.d.ts +1 -3
  42. package/getCodonRangeForAASliver.d.ts +4 -3
  43. package/getComplementAminoAcidStringFromSequenceString.d.ts +1 -1
  44. package/getComplementSequenceAndAnnotations.d.ts +1 -5
  45. package/getComplementSequenceString.d.ts +1 -1
  46. package/getCutsiteType.d.ts +1 -2
  47. package/getCutsitesFromSequence.d.ts +1 -2
  48. package/getDegenerateDnaStringFromAAString.d.ts +1 -1
  49. package/getDegenerateRnaStringFromAAString.d.ts +1 -1
  50. package/getDigestFragmentsForCutsites.d.ts +1 -4
  51. package/getDigestFragmentsForRestrictionEnzymes.d.ts +1 -8
  52. package/getInsertBetweenVals.d.ts +1 -2
  53. package/getLeftAndRightOfSequenceInRangeGivenPosition.d.ts +1 -2
  54. package/getOrfsFromSequence.d.ts +11 -17
  55. package/getOverlapBetweenTwoSequences.d.ts +1 -2
  56. package/getPossiblePartsFromSequenceAndEnzymes.d.ts +1 -18
  57. package/getReverseAminoAcidStringFromSequenceString.d.ts +1 -1
  58. package/getReverseComplementAminoAcidStringFromSequenceString.d.ts +1 -1
  59. package/getReverseComplementAnnotation.d.ts +1 -11
  60. package/getReverseComplementSequenceAndAnnotations.d.ts +1 -5
  61. package/getReverseComplementSequenceString.d.ts +1 -1
  62. package/getReverseSequenceString.d.ts +1 -1
  63. package/getSequenceDataBetweenRange.d.ts +1 -9
  64. package/getVirtualDigest.d.ts +10 -11
  65. package/guessIfSequenceIsDnaAndNotProtein.d.ts +1 -5
  66. package/index.cjs +503 -734
  67. package/index.d.ts +5 -8
  68. package/index.js +503 -734
  69. package/index.umd.cjs +503 -734
  70. package/insertGapsIntoRefSeq.d.ts +1 -2
  71. package/insertSequenceDataAtPositionOrRange.d.ts +1 -10
  72. package/isEnzymeType2S.d.ts +1 -2
  73. package/mapAnnotationsToRows.d.ts +1 -9
  74. package/package.json +9 -12
  75. package/prepareCircularViewData.d.ts +1 -2
  76. package/prepareRowData.d.ts +3 -7
  77. package/proteinAlphabet.d.ts +1 -1
  78. package/rotateBpsToPosition.d.ts +1 -1
  79. package/rotateSequenceDataToPosition.d.ts +1 -3
  80. package/shiftAnnotationsByLen.d.ts +3 -4
  81. package/src/autoAnnotate.test.js +1 -0
  82. package/src/filterSequenceString.js +7 -4
  83. package/src/getSequenceDataBetweenRange.js +11 -2
  84. package/src/getSequenceDataBetweenRange.test.js +42 -0
  85. package/src/prepareRowData_output1.json +0 -1
  86. package/src/tidyUpSequenceData.js +5 -2
  87. package/threeLetterSequenceStringToAminoAcidMap.d.ts +921 -11
  88. package/tidyUpAnnotation.d.ts +11 -13
  89. package/tidyUpSequenceData.d.ts +1 -15
  90. package/src/DNAComplementMap.ts +0 -32
  91. package/src/addGapsToSeqReads.ts +0 -436
  92. package/src/adjustAnnotationsToInsert.ts +0 -20
  93. package/src/adjustBpsToReplaceOrInsert.ts +0 -73
  94. package/src/aliasedEnzymesByName.ts +0 -7366
  95. package/src/aminoAcidToDegenerateDnaMap.ts +0 -32
  96. package/src/aminoAcidToDegenerateRnaMap.ts +0 -32
  97. package/src/annotateSingleSeq.ts +0 -37
  98. package/src/annotationTypes.ts +0 -23
  99. package/src/autoAnnotate.ts +0 -290
  100. package/src/bioData.ts +0 -65
  101. package/src/calculateEndStability.ts +0 -91
  102. package/src/calculateNebTa.ts +0 -46
  103. package/src/calculateNebTm.ts +0 -132
  104. package/src/calculatePercentGC.ts +0 -3
  105. package/src/calculateSantaLuciaTm.ts +0 -184
  106. package/src/calculateTm.ts +0 -242
  107. package/src/computeDigestFragments.ts +0 -238
  108. package/src/condensePairwiseAlignmentDifferences.ts +0 -85
  109. package/src/convertAACaretPositionOrRangeToDna.ts +0 -28
  110. package/src/convertDnaCaretPositionOrRangeToAA.ts +0 -28
  111. package/src/cutSequenceByRestrictionEnzyme.ts +0 -345
  112. package/src/defaultEnzymesByName.ts +0 -280
  113. package/src/degenerateDnaToAminoAcidMap.ts +0 -5
  114. package/src/degenerateRnaToAminoAcidMap.ts +0 -5
  115. package/src/deleteSequenceDataAtRange.ts +0 -13
  116. package/src/diffUtils.ts +0 -80
  117. package/src/doesEnzymeChopOutsideOfRecognitionSite.ts +0 -16
  118. package/src/featureTypesAndColors.ts +0 -167
  119. package/src/filterSequenceString.ts +0 -153
  120. package/src/findApproxMatches.ts +0 -58
  121. package/src/findNearestRangeOfSequenceOverlapToPosition.ts +0 -43
  122. package/src/findOrfsInPlasmid.ts +0 -31
  123. package/src/findSequenceMatches.ts +0 -154
  124. package/src/generateAnnotations.ts +0 -39
  125. package/src/generateSequenceData.ts +0 -212
  126. package/src/getAllInsertionsInSeqReads.ts +0 -100
  127. package/src/getAminoAcidDataForEachBaseOfDna.ts +0 -305
  128. package/src/getAminoAcidFromSequenceTriplet.ts +0 -27
  129. package/src/getAminoAcidStringFromSequenceString.ts +0 -36
  130. package/src/getCodonRangeForAASliver.ts +0 -73
  131. package/src/getComplementAminoAcidStringFromSequenceString.ts +0 -10
  132. package/src/getComplementSequenceAndAnnotations.ts +0 -25
  133. package/src/getComplementSequenceString.ts +0 -23
  134. package/src/getCutsiteType.ts +0 -18
  135. package/src/getCutsitesFromSequence.ts +0 -22
  136. package/src/getDegenerateDnaStringFromAAString.ts +0 -15
  137. package/src/getDegenerateRnaStringFromAAString.ts +0 -15
  138. package/src/getDigestFragmentsForCutsites.ts +0 -126
  139. package/src/getDigestFragmentsForRestrictionEnzymes.ts +0 -50
  140. package/src/getInsertBetweenVals.ts +0 -31
  141. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.ts +0 -40
  142. package/src/getMassOfAaString.ts +0 -29
  143. package/src/getOrfsFromSequence.ts +0 -132
  144. package/src/getOverlapBetweenTwoSequences.ts +0 -30
  145. package/src/getPossiblePartsFromSequenceAndEnzymes.ts +0 -149
  146. package/src/getReverseAminoAcidStringFromSequenceString.ts +0 -22
  147. package/src/getReverseComplementAminoAcidStringFromSequenceString.ts +0 -10
  148. package/src/getReverseComplementAnnotation.ts +0 -33
  149. package/src/getReverseComplementSequenceAndAnnotations.ts +0 -46
  150. package/src/getReverseComplementSequenceString.ts +0 -18
  151. package/src/getReverseSequenceString.ts +0 -12
  152. package/src/getSequenceDataBetweenRange.ts +0 -154
  153. package/src/getVirtualDigest.ts +0 -139
  154. package/src/guessIfSequenceIsDnaAndNotProtein.ts +0 -39
  155. package/src/index.test.ts +0 -43
  156. package/src/index.ts +0 -111
  157. package/src/insertGapsIntoRefSeq.ts +0 -43
  158. package/src/insertSequenceDataAtPosition.ts +0 -2
  159. package/src/insertSequenceDataAtPositionOrRange.ts +0 -328
  160. package/src/isEnzymeType2S.ts +0 -5
  161. package/src/mapAnnotationsToRows.ts +0 -256
  162. package/src/prepareCircularViewData.ts +0 -24
  163. package/src/prepareRowData.ts +0 -61
  164. package/src/proteinAlphabet.ts +0 -271
  165. package/src/rotateBpsToPosition.ts +0 -12
  166. package/src/rotateSequenceDataToPosition.ts +0 -54
  167. package/src/shiftAnnotationsByLen.ts +0 -24
  168. package/src/threeLetterSequenceStringToAminoAcidMap.ts +0 -198
  169. package/src/tidyUpAnnotation.ts +0 -205
  170. package/src/tidyUpSequenceData.ts +0 -213
  171. package/src/types.ts +0 -109
  172. 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");
@@ -6288,14 +6196,16 @@ function filterSequenceString(sequenceString = "", {
6288
6196
  name,
6289
6197
  isProtein,
6290
6198
  isRna,
6291
- isMixedRnaAndDna
6199
+ isMixedRnaAndDna,
6200
+ getAcceptedInsertChars
6292
6201
  } = {}) {
6293
- const acceptedChars = getAcceptedChars({
6202
+ const sequenceTypeInfo = {
6294
6203
  isOligo,
6295
6204
  isProtein,
6296
6205
  isRna,
6297
6206
  isMixedRnaAndDna
6298
- });
6207
+ };
6208
+ const acceptedChars = isFunction(getAcceptedInsertChars) ? getAcceptedInsertChars(sequenceTypeInfo) : getAcceptedChars(sequenceTypeInfo);
6299
6209
  const replaceChars = getReplaceChars({
6300
6210
  isOligo,
6301
6211
  isProtein,
@@ -6471,25 +6381,25 @@ function coerceLocation({
6471
6381
  circular,
6472
6382
  name
6473
6383
  }) {
6474
- location.start = parseInt(String(location.start), 10);
6475
- location.end = parseInt(String(location.end), 10);
6384
+ location.start = parseInt(location.start, 10);
6385
+ location.end = parseInt(location.end, 10);
6476
6386
  if (convertAnnotationsFromAAIndices) {
6477
6387
  location.start = location.start * 3;
6478
6388
  location.end = location.end * 3 + 2;
6479
6389
  }
6480
- if (size !== void 0 && (location.start < 0 || location.start > size - 1)) {
6390
+ if (location.start < 0 || !(location.start <= size - 1) || location.start > size - 1) {
6481
6391
  messages.push(
6482
6392
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
6483
6393
  );
6484
6394
  location.start = Math.max(0, size - (isProtein ? 3 : 1));
6485
6395
  }
6486
- if (size !== void 0 && (location.end < 0 || location.end > size - 1)) {
6396
+ if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
6487
6397
  messages.push(
6488
6398
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
6489
6399
  );
6490
6400
  location.end = Math.max(0, size - 1);
6491
6401
  }
6492
- if (size !== void 0 && location.start > location.end && circular === false) {
6402
+ if (location.start > location.end && circular === false) {
6493
6403
  messages.push(
6494
6404
  "Invalid circular annotation detected for " + name + ". end set to 1"
6495
6405
  );
@@ -6498,30 +6408,21 @@ function coerceLocation({
6498
6408
  }
6499
6409
  __name(coerceLocation, "coerceLocation");
6500
6410
  function getDegenerateDnaStringFromAAString(aaString) {
6501
- return aaString.split("").map(
6502
- (char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn"
6503
- ).join("");
6411
+ return aaString.split("").map((char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn").join("");
6504
6412
  }
6505
6413
  __name(getDegenerateDnaStringFromAAString, "getDegenerateDnaStringFromAAString");
6506
- function getAminoAcidStringFromSequenceString(sequenceString, options = {}) {
6507
- const { doNotExcludeAsterisk } = options;
6414
+ function getAminoAcidStringFromSequenceString(sequenceString, { doNotExcludeAsterisk } = {}) {
6508
6415
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
6509
6416
  sequenceString,
6510
- true,
6511
- null,
6512
- false
6417
+ true
6513
6418
  );
6514
6419
  const aaArray = [];
6515
6420
  let aaString = "";
6516
6421
  aminoAcidsPerBase.forEach((aa, index) => {
6517
- var _a;
6518
6422
  if (!aa.fullCodon) {
6519
6423
  return;
6520
6424
  }
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) {
6425
+ if (!doNotExcludeAsterisk && index >= aminoAcidsPerBase.length - 3 && aa.aminoAcid.value === "*") {
6525
6426
  return;
6526
6427
  }
6527
6428
  aaArray[aa.aminoAcidIndex] = aa.aminoAcid.value;
@@ -6541,6 +6442,7 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6541
6442
  doNotProvideIdsForAnnotations,
6542
6443
  noCdsTranslations,
6543
6444
  convertAnnotationsFromAAIndices,
6445
+ getAcceptedInsertChars,
6544
6446
  topLevelSeqData
6545
6447
  } = options;
6546
6448
  let seqData = cloneDeep(pSeqData);
@@ -6548,7 +6450,7 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6548
6450
  messages: []
6549
6451
  };
6550
6452
  if (!seqData) {
6551
- seqData = { sequence: "" };
6453
+ seqData = {};
6552
6454
  }
6553
6455
  if (!seqData.sequence) {
6554
6456
  seqData.sequence = "";
@@ -6572,13 +6474,16 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6572
6474
  if (!doNotRemoveInvalidChars) {
6573
6475
  if (seqData.isProtein) {
6574
6476
  const [newSeq] = filterSequenceString(seqData.proteinSequence, __spreadProps(__spreadValues({}, topLevelSeqData || seqData), {
6575
- isProtein: true
6477
+ isProtein: true,
6478
+ getAcceptedInsertChars
6576
6479
  }));
6577
6480
  seqData.proteinSequence = newSeq;
6578
6481
  } else {
6579
- const [newSeq] = filterSequenceString(seqData.sequence, __spreadValues({
6482
+ const [newSeq] = filterSequenceString(seqData.sequence, __spreadProps(__spreadValues({
6580
6483
  additionalValidChars
6581
- }, topLevelSeqData || seqData));
6484
+ }, topLevelSeqData || seqData), {
6485
+ getAcceptedInsertChars
6486
+ }));
6582
6487
  seqData.sequence = newSeq;
6583
6488
  }
6584
6489
  }
@@ -6611,27 +6516,25 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6611
6516
  const featureTypes = getFeatureTypes();
6612
6517
  annotationTypes.forEach((annotationType) => {
6613
6518
  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
- });
6519
+ if (typeof seqData[annotationType] === "object") {
6520
+ seqData[annotationType] = Object.keys(seqData[annotationType]).map(
6521
+ (key) => {
6522
+ return seqData[annotationType][key];
6523
+ }
6524
+ );
6620
6525
  } else {
6621
6526
  seqData[annotationType] = [];
6622
6527
  }
6623
6528
  }
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
- );
6529
+ seqData[annotationType] = seqData[annotationType].filter((annotation) => {
6530
+ return tidyUpAnnotation(annotation, __spreadProps(__spreadValues({}, options), {
6531
+ featureTypes,
6532
+ sequenceData: seqData,
6533
+ convertAnnotationsFromAAIndices,
6534
+ mutative: true,
6535
+ annotationType
6536
+ }));
6537
+ });
6635
6538
  });
6636
6539
  if (!noTranslationData) {
6637
6540
  seqData.translations = flatMap(seqData.translations, (translation) => {
@@ -6639,7 +6542,7 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6639
6542
  if (noCdsTranslations && translation.translationType === "CDS Feature") {
6640
6543
  return [];
6641
6544
  }
6642
- const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a["codon_start"]) == null ? void 0 : _b[0]) - 1 || 0;
6545
+ const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a.codon_start) == null ? void 0 : _b[0]) - 1 || 0;
6643
6546
  const expandedRange = expandOrContractRangeByLength(
6644
6547
  translation,
6645
6548
  -codonStart,
@@ -6649,9 +6552,8 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6649
6552
  if (!expandedRange.aminoAcids && !seqData.noSequence) {
6650
6553
  expandedRange.aminoAcids = getAminoAcidDataForEachBaseOfDna(
6651
6554
  seqData.sequence,
6652
- expandedRange.forward || false,
6653
- expandedRange,
6654
- false
6555
+ expandedRange.forward,
6556
+ expandedRange
6655
6557
  );
6656
6558
  }
6657
6559
  return expandedRange;
@@ -6659,22 +6561,19 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6659
6561
  }
6660
6562
  if (annotationsAsObjects) {
6661
6563
  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
- }
6564
+ seqData[name] = seqData[name].reduce((acc, item) => {
6565
+ let itemId;
6566
+ if (item.id || item.id === 0) {
6567
+ itemId = item.id;
6568
+ } else {
6569
+ itemId = shortid();
6570
+ if (!doNotProvideIdsForAnnotations) {
6571
+ item.id = itemId;
6672
6572
  }
6673
- acc[itemId] = item;
6674
- return acc;
6675
- },
6676
- {}
6677
- );
6573
+ }
6574
+ acc[itemId] = item;
6575
+ return acc;
6576
+ }, {});
6678
6577
  });
6679
6578
  }
6680
6579
  if (logMessages && response.messages.length > 0) {
@@ -6684,17 +6583,17 @@ function tidyUpSequenceData(pSeqData, options = {}) {
6684
6583
  }
6685
6584
  __name(tidyUpSequenceData, "tidyUpSequenceData");
6686
6585
  const getDiffFromSeqs = /* @__PURE__ */ __name((oldData, newData, { ignoreKeys = [] } = {}) => {
6687
- const cleanedOldData = tidyUpSequenceData(oldData, {
6586
+ oldData = tidyUpSequenceData(oldData, {
6688
6587
  annotationsAsObjects: true,
6689
6588
  noTranslationData: true,
6690
6589
  doNotRemoveInvalidChars: true
6691
6590
  });
6692
- const cleanedNewData = tidyUpSequenceData(newData, {
6591
+ newData = tidyUpSequenceData(newData, {
6693
6592
  annotationsAsObjects: true,
6694
6593
  noTranslationData: true,
6695
6594
  doNotRemoveInvalidChars: true
6696
6595
  });
6697
- [cleanedOldData, cleanedNewData].forEach((d) => {
6596
+ [oldData, newData].forEach((d) => {
6698
6597
  [
6699
6598
  "cutsites",
6700
6599
  "orfs",
@@ -6717,26 +6616,27 @@ const getDiffFromSeqs = /* @__PURE__ */ __name((oldData, newData, { ignoreKeys =
6717
6616
  });
6718
6617
  }
6719
6618
  });
6720
- return diff(cleanedOldData, cleanedNewData);
6619
+ return diff(oldData, newData);
6721
6620
  }, "getDiffFromSeqs");
6722
- const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diffData, { ignoreKeys = [] } = {}) => {
6621
+ const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diff2, { ignoreKeys = [] } = {}) => {
6723
6622
  ignoreKeys.forEach((k) => {
6724
- delete diffData[k];
6725
- });
6726
- const tidyOld = tidyUpSequenceData(cloneDeep(oldData), {
6727
- annotationsAsObjects: true,
6728
- doNotRemoveInvalidChars: true
6623
+ delete diff2[k];
6729
6624
  });
6730
- return patch(tidyOld, diffData);
6625
+ return patch(
6626
+ tidyUpSequenceData(cloneDeep(oldData), {
6627
+ annotationsAsObjects: true,
6628
+ doNotRemoveInvalidChars: true
6629
+ }),
6630
+ diff2
6631
+ );
6731
6632
  }, "patchSeqWithDiff");
6732
- const reverseSeqDiff = /* @__PURE__ */ __name((diffData) => {
6733
- return reverse(diffData);
6633
+ const reverseSeqDiff = /* @__PURE__ */ __name((diff2) => {
6634
+ return reverse(diff2);
6734
6635
  }, "reverseSeqDiff");
6735
6636
  function getAllInsertionsInSeqReads(seqReads) {
6736
6637
  const allInsertionsInSeqReads = [];
6737
6638
  seqReads.forEach((seqRead) => {
6738
6639
  const splitSeqRead = seqRead.cigar.match(/([0-9]*[MDI])/g);
6739
- if (!splitSeqRead) return;
6740
6640
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
6741
6641
  if (splitSeqRead[componentI].slice(-1) === "I") {
6742
6642
  let bpPosOfInsertion = seqRead.pos;
@@ -6780,19 +6680,14 @@ function getAllInsertionsInSeqReads(seqReads) {
6780
6680
  return sortedInsertions;
6781
6681
  }
6782
6682
  __name(getAllInsertionsInSeqReads, "getAllInsertionsInSeqReads");
6783
- function annotateSingleSeq({
6784
- fullSeq,
6785
- searchSeq
6786
- }) {
6683
+ function annotateSingleSeq({ fullSeq, searchSeq }) {
6787
6684
  const fullSeqId = fullSeq.id || "fullSeqId";
6788
6685
  const searchSeqId = searchSeq.id || "searchSeqId";
6789
6686
  const results = autoAnnotate({
6790
6687
  seqsToAnnotateById: {
6791
- [fullSeqId]: {
6792
- sequence: fullSeq.sequence,
6793
- circular: fullSeq.circular,
6794
- annotations: fullSeq.features || []
6795
- }
6688
+ [fullSeqId]: __spreadProps(__spreadValues({}, fullSeq), {
6689
+ id: fullSeqId
6690
+ })
6796
6691
  },
6797
6692
  annotationsToCheckById: {
6798
6693
  [searchSeqId]: __spreadProps(__spreadValues({}, searchSeq), {
@@ -6842,9 +6737,7 @@ const aminoAcidToDegenerateRnaMap = {
6842
6737
  z: "sar"
6843
6738
  };
6844
6739
  function getDegenerateRnaStringFromAAString(aaString) {
6845
- return aaString.split("").map(
6846
- (char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn"
6847
- ).join("");
6740
+ return aaString.split("").map((char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn").join("");
6848
6741
  }
6849
6742
  __name(getDegenerateRnaStringFromAAString, "getDegenerateRnaStringFromAAString");
6850
6743
  function getVirtualDigest({
@@ -6859,7 +6752,7 @@ function getVirtualDigest({
6859
6752
  const overlappingEnzymes = [];
6860
6753
  const pairs = [];
6861
6754
  const sortedCutsites = cutsites.sort((a, b) => {
6862
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
6755
+ return a.topSnipPosition - b.topSnipPosition;
6863
6756
  });
6864
6757
  sortedCutsites.forEach((cutsite1, index) => {
6865
6758
  if (computePartialDigest && !computePartialDigestDisabled) {
@@ -6876,11 +6769,11 @@ function getVirtualDigest({
6876
6769
  });
6877
6770
  pairs.forEach(([cut1, cut2]) => {
6878
6771
  const start = normalizePositionByRangeLength(
6879
- cut1.topSnipPosition || 0,
6772
+ cut1.topSnipPosition,
6880
6773
  sequenceLength
6881
6774
  );
6882
6775
  const end = normalizePositionByRangeLength(
6883
- (cut2.topSnipPosition || 0) - 1,
6776
+ cut2.topSnipPosition - 1,
6884
6777
  sequenceLength
6885
6778
  );
6886
6779
  if (!isCircular && start > end) {
@@ -6894,7 +6787,6 @@ function getVirtualDigest({
6894
6787
  name: "End Of Seq"
6895
6788
  }
6896
6789
  }
6897
- // Cast to CutSite as it's a mock
6898
6790
  };
6899
6791
  const frag2 = {
6900
6792
  start: 0,
@@ -6905,7 +6797,6 @@ function getVirtualDigest({
6905
6797
  name: "Start Of Seq"
6906
6798
  }
6907
6799
  },
6908
- // Cast
6909
6800
  cut2
6910
6801
  };
6911
6802
  fragments.push(addSizeIdName(frag1, sequenceLength));
@@ -7008,18 +6899,27 @@ function findApproxMatches(searchSeq, targetSeq, maxMismatches, circular = false
7008
6899
  return matches;
7009
6900
  }
7010
6901
  __name(findApproxMatches, "findApproxMatches");
6902
+ var spliceString$1;
6903
+ var hasRequiredSpliceString;
6904
+ function requireSpliceString() {
6905
+ if (hasRequiredSpliceString) return spliceString$1;
6906
+ hasRequiredSpliceString = 1;
6907
+ spliceString$1 = /* @__PURE__ */ __name(function spliceSlice(str, index, count, add) {
6908
+ return str.slice(0, index) + (add || "") + str.slice(index + count);
6909
+ }, "spliceSlice");
6910
+ return spliceString$1;
6911
+ }
6912
+ __name(requireSpliceString, "requireSpliceString");
6913
+ var spliceStringExports = requireSpliceString();
6914
+ const spliceString = /* @__PURE__ */ getDefaultExportFromCjs(spliceStringExports);
7011
6915
  function adjustBpsToReplaceOrInsert(bpString, insertString = "", caretPositionOrRange) {
7012
6916
  let stringToReturn = bpString;
7013
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange && caretPositionOrRange.start > -1) {
6917
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7014
6918
  if (getRangeLength(caretPositionOrRange, bpString.length) === bpString.length) {
7015
6919
  return insertString;
7016
6920
  }
7017
6921
  const ranges = splitRangeIntoTwoPartsIfItIsCircular(
7018
- invertRange(
7019
- caretPositionOrRange,
7020
- bpString.length
7021
- ),
7022
- bpString.length
6922
+ invertRange(caretPositionOrRange, bpString.length)
7023
6923
  );
7024
6924
  stringToReturn = "";
7025
6925
  ranges.forEach((range, index) => {
@@ -7045,16 +6945,6 @@ function adjustBpsToReplaceOrInsert(bpString, insertString = "", caretPositionOr
7045
6945
  return stringToReturn;
7046
6946
  }
7047
6947
  __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
6948
  function calculatePercentGC(bps) {
7059
6949
  return (bps.match(/[cg]/gi) || []).length / bps.length * 100 || 0;
7060
6950
  }
@@ -7080,17 +6970,11 @@ const calcTmMethods = {
7080
6970
  * monovalentCationConc - THe monovalent salt concentration. Defaults to 50e-3M.
7081
6971
  * return - Temperature for the given sequence, in Celsius.
7082
6972
  */
7083
- calculateTemperature: /* @__PURE__ */ __name(function(_sequence, {
7084
- type,
7085
- A,
7086
- R,
7087
- primerConc,
7088
- monovalentCationConc
7089
- } = {}) {
6973
+ calculateTemperature: /* @__PURE__ */ __name(function(_sequence, { type, A, R, primerConc, monovalentCationConc } = {}) {
7090
6974
  const sequence = (_sequence || "").toLowerCase();
7091
6975
  if (typeof type === "undefined") {
7092
6976
  type = this.TABLE_BRESLAUER;
7093
- } else if (type !== this.TABLE_BRESLAUER && type !== this.TABLE_UNIFIED && type !== this.TABLE_SUGIMOTO) {
6977
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
7094
6978
  throw new Error("Invalid table type!");
7095
6979
  }
7096
6980
  if (!A) {
@@ -7106,14 +6990,11 @@ const calcTmMethods = {
7106
6990
  monovalentCationConc = this.monovalentCationConc;
7107
6991
  }
7108
6992
  const sequenceLength = sequence.length;
7109
- if (sequenceLength === 0) {
6993
+ if (sequenceLength == 0) {
7110
6994
  return 0;
7111
6995
  }
7112
6996
  const deltaHTable = this.getDeltaHTable(type);
7113
6997
  const deltaSTable = this.getDeltaSTable(type);
7114
- if (!deltaHTable || !deltaSTable) {
7115
- return 0;
7116
- }
7117
6998
  const neighbors = [];
7118
6999
  neighbors.push(this.calculateReps(sequence, "aa"));
7119
7000
  neighbors.push(this.calculateNumberOfOccurrences(sequence, "at"));
@@ -7147,7 +7028,7 @@ const calcTmMethods = {
7147
7028
  * @return {Number[]} deltaH table for given algorithm.
7148
7029
  */
7149
7030
  getDeltaHTable: /* @__PURE__ */ __name(function(type) {
7150
- if (type === this.TABLE_BRESLAUER) {
7031
+ if (type == this.TABLE_BRESLAUER) {
7151
7032
  return [
7152
7033
  9.1,
7153
7034
  8.6,
@@ -7166,7 +7047,7 @@ const calcTmMethods = {
7166
7047
  6.5,
7167
7048
  11.1
7168
7049
  ];
7169
- } else if (type === this.TABLE_SUGIMOTO) {
7050
+ } else if (type == this.TABLE_SUGIMOTO) {
7170
7051
  return [
7171
7052
  8,
7172
7053
  5.6,
@@ -7185,7 +7066,7 @@ const calcTmMethods = {
7185
7066
  9.4,
7186
7067
  11.9
7187
7068
  ];
7188
- } else if (type === this.TABLE_UNIFIED) {
7069
+ } else if (type == this.TABLE_UNIFIED) {
7189
7070
  return [
7190
7071
  7.9,
7191
7072
  7.2,
@@ -7208,6 +7089,39 @@ const calcTmMethods = {
7208
7089
  return null;
7209
7090
  }
7210
7091
  }, "getDeltaHTable"),
7092
+ // "AA/TT": -7.9, 7.9
7093
+ // "AT/TA": -7.2, 7.2
7094
+ // "AC/TG": -8.4, 8.4
7095
+ // "AG/TC": -7.8, 7.8
7096
+ // "TT/AA": -7.9, 7.9
7097
+ // "TA/AT": -7.2, 7.2
7098
+ // "TG/AC": -8.5, 8.2
7099
+ // "TC/AG": -8.2, 8.5
7100
+ // "CC/GG": -8.0, 8.0
7101
+ // "CA/GT": -8.5, 8.5
7102
+ // "CT/GA": -7.8, 7.8
7103
+ // "CG/GC": -10.6, 10.6
7104
+ // "GG/CC": -8.0, 8.0
7105
+ // "GA/CT": -8.2, 8.2,
7106
+ // "GT/CA": -8.4, 8.4
7107
+ // "GC/CG": -9.8, 9.8
7108
+ // aa, at, ac, ag, tt, ta, tc, tg, cc, ca, ct, cg, gg, ga, gt, gc
7109
+ // "AA/TT": -22.2,22.2,
7110
+ // "AT/TA": -20.4,20.4,
7111
+ // "AC/TG": -22.4,22.4,
7112
+ // "AG/TC": -21.0,21.0,
7113
+ // "TT/AA": -22.2,22.2,
7114
+ // "TA/AT": -21.3,21.3,
7115
+ // "TC/AG": -22.2,22.2,
7116
+ // "TG/AC": -22.7,22.7,
7117
+ // "CC/GG": -19.9,19.9,
7118
+ // "CA/GT": -22.7,22.7,
7119
+ // "CT/GA": -21.0,21.0,
7120
+ // "CG/GC": -27.2,27.2,
7121
+ // "GG/CC": -19.9,19.9,
7122
+ // "GT/CA": -22.4,22.2,
7123
+ // "GA/CT": -22.2,22.4,
7124
+ // "GC/CG": -24.4,24.4
7211
7125
  /**
7212
7126
  * @private
7213
7127
  * Function to return deltaS table for given algorithm.
@@ -7215,7 +7129,7 @@ const calcTmMethods = {
7215
7129
  * @return {Number[]} deltaS table for given algorithm.
7216
7130
  */
7217
7131
  getDeltaSTable: /* @__PURE__ */ __name(function(type) {
7218
- if (type === this.TABLE_BRESLAUER) {
7132
+ if (type == this.TABLE_BRESLAUER) {
7219
7133
  return [
7220
7134
  24,
7221
7135
  23.9,
@@ -7234,7 +7148,7 @@ const calcTmMethods = {
7234
7148
  17.3,
7235
7149
  26.7
7236
7150
  ];
7237
- } else if (type === this.TABLE_SUGIMOTO) {
7151
+ } else if (type == this.TABLE_SUGIMOTO) {
7238
7152
  return [
7239
7153
  21.9,
7240
7154
  15.2,
@@ -7253,7 +7167,7 @@ const calcTmMethods = {
7253
7167
  25.5,
7254
7168
  29
7255
7169
  ];
7256
- } else if (type === this.TABLE_UNIFIED) {
7170
+ } else if (type == this.TABLE_UNIFIED) {
7257
7171
  return [
7258
7172
  22.2,
7259
7173
  20.4,
@@ -7287,14 +7201,14 @@ const calcTmMethods = {
7287
7201
  */
7288
7202
  calculateReps: /* @__PURE__ */ __name(function(sequence, target) {
7289
7203
  const sequenceLength = sequence.length;
7290
- if (sequenceLength === 0) {
7204
+ if (sequenceLength == 0) {
7291
7205
  return 0;
7292
7206
  }
7293
7207
  let numFound = 0;
7294
7208
  let seqOffset = 0;
7295
7209
  while (true) {
7296
7210
  const foundSeq = sequence.indexOf(target, seqOffset);
7297
- if (foundSeq === -1) {
7211
+ if (foundSeq == -1) {
7298
7212
  break;
7299
7213
  }
7300
7214
  seqOffset = foundSeq + 1;
@@ -7314,7 +7228,7 @@ const calcTmMethods = {
7314
7228
  */
7315
7229
  calculateNumberOfOccurrences: /* @__PURE__ */ __name(function(sequence, target) {
7316
7230
  const sequenceLength = sequence.length;
7317
- if (sequenceLength === 0) {
7231
+ if (sequenceLength == 0) {
7318
7232
  return 0;
7319
7233
  }
7320
7234
  const numberFound = sequence.split(target).length - 1;
@@ -7349,11 +7263,11 @@ function rotateBpsToPosition(bps, caretPosition) {
7349
7263
  __name(rotateBpsToPosition, "rotateBpsToPosition");
7350
7264
  function arrayRotate(arr, count) {
7351
7265
  count -= arr.length * Math.floor(count / arr.length);
7352
- arr.push(...arr.splice(0, count));
7266
+ arr.push.apply(arr, arr.splice(0, count));
7353
7267
  return arr;
7354
7268
  }
7355
7269
  __name(arrayRotate, "arrayRotate");
7356
- function rotateSequenceDataToPosition(sequenceData, caretPosition, options = {}) {
7270
+ function rotateSequenceDataToPosition(sequenceData, caretPosition, options) {
7357
7271
  const newSequenceData = tidyUpSequenceData(sequenceData, __spreadValues({
7358
7272
  doNotRemoveInvalidChars: true
7359
7273
  }, options));
@@ -7401,24 +7315,16 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7401
7315
  }, options));
7402
7316
  const newSequenceData = cloneDeep(existingSequenceData);
7403
7317
  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(
7318
+ let caretPosition = caretPositionOrRange;
7319
+ const isInsertSameLengthAsSelection = sequenceDataToInsert.sequence.length === getRangeLength(caretPositionOrRange, existingSequenceData.sequence.length);
7320
+ if (caretPositionOrRange.start > -1 && getRangeLength(
7410
7321
  caretPositionOrRange,
7411
7322
  existingSequenceData.sequence.length
7412
7323
  ) === existingSequenceData.sequence.length) {
7413
- const emptyAnnotations = modifiableTypes.reduce(
7414
- (acc, type) => {
7415
- acc[type] = [];
7416
- return acc;
7417
- },
7418
- {}
7419
- );
7420
7324
  existingSequenceData = tidyUpSequenceData(
7421
- __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), emptyAnnotations), {
7325
+ __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), modifiableTypes.reduce((acc, type) => {
7326
+ return acc[type] = [];
7327
+ }, {})), {
7422
7328
  sequence: "",
7423
7329
  doNotRemoveInvalidChars: true,
7424
7330
  proteinSequence: "",
@@ -7428,7 +7334,7 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7428
7334
  );
7429
7335
  newSequenceData.chromatogramData = void 0;
7430
7336
  } else if (newSequenceData.chromatogramData && newSequenceData.chromatogramData.baseTraces) {
7431
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7337
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7432
7338
  if (caretPositionOrRange.start > caretPositionOrRange.end) {
7433
7339
  newSequenceData.chromatogramData = trimChromatogram({
7434
7340
  chromatogramData: newSequenceData.chromatogramData,
@@ -7438,16 +7344,14 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7438
7344
  },
7439
7345
  justBaseCalls: isInsertSameLengthAsSelection
7440
7346
  });
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
- }
7347
+ newSequenceData.chromatogramData = trimChromatogram({
7348
+ chromatogramData: newSequenceData.chromatogramData,
7349
+ range: {
7350
+ start: 0,
7351
+ end: caretPositionOrRange.end
7352
+ },
7353
+ justBaseCalls: isInsertSameLengthAsSelection
7354
+ });
7451
7355
  } else {
7452
7356
  newSequenceData.chromatogramData = trimChromatogram({
7453
7357
  chromatogramData: newSequenceData.chromatogramData,
@@ -7459,10 +7363,10 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7459
7363
  });
7460
7364
  }
7461
7365
  }
7462
- if (sequenceDataToInsert.sequence && newSequenceData.chromatogramData) {
7366
+ if (sequenceDataToInsert.sequence) {
7463
7367
  insertIntoChromatogram({
7464
7368
  chromatogramData: newSequenceData.chromatogramData,
7465
- caretPosition: typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7369
+ caretPosition: caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7466
7370
  seqToInsert: sequenceDataToInsert.sequence,
7467
7371
  justBaseCalls: isInsertSameLengthAsSelection
7468
7372
  });
@@ -7475,15 +7379,14 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7475
7379
  );
7476
7380
  newSequenceData.size = newSequenceData.sequence.length;
7477
7381
  newSequenceData.proteinSequence = adjustBpsToReplaceOrInsert(
7478
- existingSequenceData.proteinSequence || "",
7479
- sequenceDataToInsert.proteinSequence || "",
7382
+ existingSequenceData.proteinSequence,
7383
+ sequenceDataToInsert.proteinSequence,
7480
7384
  convertDnaCaretPositionOrRangeToAA(caretPositionOrRange)
7481
7385
  );
7482
- newSequenceData.proteinSize = (newSequenceData.proteinSequence || "").length;
7386
+ newSequenceData.proteinSize = newSequenceData.proteinSequence.length;
7483
7387
  modifiableTypes.forEach((annotationType) => {
7484
7388
  let existingAnnotations = existingSequenceData[annotationType];
7485
- if (!existingAnnotations) return;
7486
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7389
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7487
7390
  const range = caretPositionOrRange;
7488
7391
  caretPosition = range.start > range.end ? 0 : range.start;
7489
7392
  existingAnnotations = adjustAnnotationsToDelete(
@@ -7493,23 +7396,22 @@ function insertSequenceDataAtPositionOrRange(_sequenceDataToInsert, _existingSeq
7493
7396
  );
7494
7397
  }
7495
7398
  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
- }
7399
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7400
+ adjustAnnotationsToInsert(
7401
+ existingAnnotations,
7402
+ caretPosition,
7403
+ insertLength
7404
+ )
7405
+ );
7406
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7407
+ adjustAnnotationsToInsert(
7408
+ sequenceDataToInsert[annotationType],
7409
+ 0,
7410
+ caretPosition
7411
+ )
7412
+ );
7511
7413
  });
7512
- if (maintainOriginSplit && typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > caretPositionOrRange.end) {
7414
+ if (maintainOriginSplit && caretPositionOrRange && caretPositionOrRange.start > caretPositionOrRange.end) {
7513
7415
  const caretPosToRotateTo = existingSequenceData.sequence.length - caretPositionOrRange.start;
7514
7416
  return rotateSequenceDataToPosition(
7515
7417
  newSequenceData,
@@ -7527,7 +7429,6 @@ function adjustAnnotationsToDelete(annotationsToBeAdjusted, range, maxLength) {
7527
7429
  maxLength
7528
7430
  );
7529
7431
  const newLocations = annotation.locations && annotation.locations.map((loc) => adjustRangeToDeletionOfAnotherRange(loc, range, maxLength)).filter((range2) => !!range2);
7530
- if (!newRange) return null;
7531
7432
  if (newLocations && newLocations.length) {
7532
7433
  return __spreadValues(__spreadProps(__spreadValues({}, newRange), {
7533
7434
  start: newLocations[0].start,
@@ -7546,13 +7447,11 @@ function insertIntoChromatogram({
7546
7447
  justBaseCalls
7547
7448
  }) {
7548
7449
  if (!seqToInsert.length) return;
7549
- if (chromatogramData.baseCalls) {
7550
- chromatogramData.baseCalls.splice(
7551
- caretPosition,
7552
- 0,
7553
- ...seqToInsert.split("")
7554
- );
7555
- }
7450
+ chromatogramData.baseCalls && chromatogramData.baseCalls.splice(
7451
+ caretPosition,
7452
+ 0,
7453
+ ...seqToInsert.split("")
7454
+ );
7556
7455
  if (justBaseCalls) {
7557
7456
  return chromatogramData;
7558
7457
  }
@@ -7568,20 +7467,8 @@ function insertIntoChromatogram({
7568
7467
  tTrace: toPush
7569
7468
  });
7570
7469
  }
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
- }
7470
+ chromatogramData.baseTraces && chromatogramData.baseTraces.splice(caretPosition, 0, ...baseTracesToInsert);
7471
+ chromatogramData.qualNums && chromatogramData.qualNums.splice(caretPosition, 0, ...qualNumsToInsert);
7585
7472
  return chromatogramData;
7586
7473
  }
7587
7474
  __name(insertIntoChromatogram, "insertIntoChromatogram");
@@ -7594,23 +7481,17 @@ function trimChromatogram({
7594
7481
  "baseCalls",
7595
7482
  ...justBaseCalls ? [] : ["qualNums", "baseTraces", "basePos"]
7596
7483
  ].forEach((type) => {
7597
- if (chromatogramData[type]) {
7598
- chromatogramData[type].splice(start, end - start + 1);
7599
- }
7484
+ chromatogramData[type] && chromatogramData[type].splice(start, end - start + 1);
7600
7485
  });
7601
7486
  return chromatogramData;
7602
7487
  }
7603
7488
  __name(trimChromatogram, "trimChromatogram");
7604
7489
  function deleteSequenceDataAtRange(sequenceData, range) {
7605
- return insertSequenceDataAtPositionOrRange(
7606
- { sequence: "" },
7607
- sequenceData,
7608
- range
7609
- );
7490
+ return insertSequenceDataAtPositionOrRange({}, sequenceData, range);
7610
7491
  }
7611
7492
  __name(deleteSequenceDataAtRange, "deleteSequenceDataAtRange");
7612
7493
  function doesEnzymeChopOutsideOfRecognitionSite(enzyme) {
7613
- if (enzyme.topSnipOffset && enzyme.bottomSnipOffset && (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length)) {
7494
+ if (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length) {
7614
7495
  return true;
7615
7496
  } else {
7616
7497
  return false;
@@ -15242,10 +15123,10 @@ defaultEnzymes.forEach((name) => {
15242
15123
  defaultEnzymesByName[name] = aliasedEnzymesByName[name];
15243
15124
  });
15244
15125
  function generateAnnotations(numberOfAnnotationsToGenerate, start, end, maxLength) {
15245
- const result = [];
15126
+ const result = {};
15246
15127
  for (let i = 0; i < numberOfAnnotationsToGenerate; i++) {
15247
15128
  const annotation = generateAnnotation(start, end, maxLength);
15248
- result.push(annotation);
15129
+ result[annotation.id] = annotation;
15249
15130
  }
15250
15131
  return result;
15251
15132
  }
@@ -15273,16 +15154,16 @@ function generateSequenceData({
15273
15154
  numPrimers,
15274
15155
  numTranslations
15275
15156
  } = {}) {
15276
- const proteinSequence = isProtein ? generateSequence(sequenceLength, true) : "";
15277
- const sequence = !isProtein ? generateSequence(sequenceLength) : "";
15157
+ const proteinSequence = isProtein && generateSequence(sequenceLength, true);
15158
+ const sequence = !isProtein && generateSequence(sequenceLength);
15278
15159
  return {
15279
15160
  circular: isProtein ? false : Math.random() > 0.5,
15280
- name: "p-" + Math.floor(Math.random() * 100),
15161
+ name: "p-" + Math.floor(Math.random * 100),
15281
15162
  description: "",
15282
- isProtein: !!isProtein,
15163
+ isProtein,
15283
15164
  sequence,
15284
15165
  proteinSequence,
15285
- translations: isProtein ? [] : generateAnnotations(
15166
+ translations: isProtein ? void 0 : generateAnnotations(
15286
15167
  numTranslations || 5,
15287
15168
  0,
15288
15169
  sequenceLength - 1,
@@ -15294,7 +15175,7 @@ function generateSequenceData({
15294
15175
  sequenceLength - 1,
15295
15176
  sequenceLength / 3
15296
15177
  ),
15297
- primers: isProtein ? [] : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15178
+ primers: isProtein ? void 0 : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15298
15179
  parts: generateAnnotations(
15299
15180
  numParts || 10,
15300
15181
  0,
@@ -15306,14 +15187,15 @@ function generateSequenceData({
15306
15187
  __name(generateSequenceData, "generateSequenceData");
15307
15188
  function generateSequence(m = 9, isProtein) {
15308
15189
  let s = "";
15309
- const r = isProtein ? "ACDEFGHIKLMNPQRSTVWY" : "gatc";
15190
+ const r = isProtein ? "" : "gatc";
15310
15191
  for (let i = 0; i < m; i++) {
15311
15192
  s += r.charAt(Math.floor(Math.random() * r.length));
15312
15193
  }
15313
15194
  return s;
15314
15195
  }
15315
15196
  __name(generateSequence, "generateSequence");
15316
- function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart = 0, isLinear) {
15197
+ function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart, isLinear) {
15198
+ if (!positionStart) positionStart = 0;
15317
15199
  if (sequenceToSearch.length < overlapSequence.length) {
15318
15200
  return null;
15319
15201
  }
@@ -15331,9 +15213,6 @@ function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSe
15331
15213
  index = result.index;
15332
15214
  distance = newDistance;
15333
15215
  }
15334
- if (index === void 0) {
15335
- return null;
15336
- }
15337
15216
  return normalizeRange(
15338
15217
  {
15339
15218
  start: index,
@@ -15378,11 +15257,9 @@ function getOrfsFromSequence(options) {
15378
15257
  internalStartCodonIndices: [],
15379
15258
  frame: start % 3,
15380
15259
  forward,
15381
- // annotationTypePlural: "orfs",
15260
+ annotationTypePlural: "orfs",
15382
15261
  isOrf: true,
15383
- id: shortid(),
15384
- type: "orf",
15385
- name: "ORF"
15262
+ id: shortid()
15386
15263
  });
15387
15264
  }
15388
15265
  }
@@ -15486,10 +15363,7 @@ function findSequenceMatchesTopStrand(sequence, searchString, options = {}) {
15486
15363
  true
15487
15364
  );
15488
15365
  } else {
15489
- searchStringToUse = convertAmbiguousStringToRegex(
15490
- searchStringToUse,
15491
- false
15492
- );
15366
+ searchStringToUse = convertAmbiguousStringToRegex(searchStringToUse);
15493
15367
  }
15494
15368
  }
15495
15369
  if (!searchStringToUse) return [];
@@ -15609,9 +15483,7 @@ function getCodonRangeForAASliver(aminoAcidPositionInSequence, aminoAcidSliver,
15609
15483
  }
15610
15484
  __name(getCodonRangeForAASliver, "getCodonRangeForAASliver");
15611
15485
  function getComplementAminoAcidStringFromSequenceString(sequenceString) {
15612
- const aaString = getAminoAcidStringFromSequenceString(sequenceString, {
15613
- doNotExcludeAsterisk: true
15614
- });
15486
+ const aaString = getAminoAcidStringFromSequenceString(sequenceString, true);
15615
15487
  return aaString.split("").reverse().join("");
15616
15488
  }
15617
15489
  __name(getComplementAminoAcidStringFromSequenceString, "getComplementAminoAcidStringFromSequenceString");
@@ -15649,30 +15521,26 @@ function getSequenceDataBetweenRange(seqData, range, options = {}) {
15649
15521
  sequence: getSequenceWithinRange(range, seqDataToUse.sequence),
15650
15522
  proteinSequence: getSequenceWithinRange(
15651
15523
  convertDnaCaretPositionOrRangeToAA(range),
15652
- seqDataToUse.proteinSequence || ""
15524
+ seqDataToUse.proteinSequence
15653
15525
  )
15654
15526
  },
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
- );
15527
+ annotationTypes.reduce((acc, type) => {
15528
+ if (exclude[type]) {
15529
+ acc[type] = [];
15667
15530
  return acc;
15668
- },
15669
- {}
15670
- )
15531
+ }
15532
+ acc[type] = getAnnotationsBetweenRange(
15533
+ seqDataToUse[type],
15534
+ range,
15535
+ seqDataToUse.sequence.length,
15536
+ excludePartial[type]
15537
+ );
15538
+ return acc;
15539
+ }, {})
15671
15540
  );
15672
15541
  if (range.overlapsSelf) {
15673
15542
  const extendedSeqData = insertSequenceDataAtPositionOrRange(
15674
15543
  { sequence: seqDataToReturn.sequence },
15675
- // Wrapping in object as per assumed signature
15676
15544
  seqDataToUse,
15677
15545
  range.start
15678
15546
  );
@@ -15713,6 +15581,15 @@ function getAnnotationsBetweenRange(annotationsToBeAdjusted, range, maxLength, s
15713
15581
  }
15714
15582
  const overlaps = getZeroedRangeOverlaps(annotation, range, maxLength).map(
15715
15583
  (overlap) => {
15584
+ const allLocations = annotation.locations;
15585
+ if (allLocations && allLocations.length) {
15586
+ const newLocations = allLocations.filter((loc) => {
15587
+ return isRangeWithinRange(loc, overlap, maxLength);
15588
+ });
15589
+ return assignIn({}, annotation, overlap, {
15590
+ locations: newLocations
15591
+ });
15592
+ }
15716
15593
  return assignIn({}, annotation, overlap);
15717
15594
  }
15718
15595
  );
@@ -15737,8 +15614,7 @@ function getAnnotationsBetweenRange(annotationsToBeAdjusted, range, maxLength, s
15737
15614
  __name(getAnnotationsBetweenRange, "getAnnotationsBetweenRange");
15738
15615
  function getComplementSequenceAndAnnotations(pSeqObj, options = {}) {
15739
15616
  const seqObj = tidyUpSequenceData(
15740
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15741
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15617
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15742
15618
  options
15743
15619
  );
15744
15620
  const newSeqObj = Object.assign({}, seqObj, {
@@ -15753,7 +15629,7 @@ function getCutsiteType(restrictionEnzyme) {
15753
15629
  const { topSnipOffset, bottomSnipOffset } = restrictionEnzyme;
15754
15630
  if (topSnipOffset === bottomSnipOffset) {
15755
15631
  return "blunt";
15756
- } else if (topSnipOffset !== void 0 && bottomSnipOffset !== void 0 && topSnipOffset < bottomSnipOffset) {
15632
+ } else if (topSnipOffset < bottomSnipOffset) {
15757
15633
  return "5' overhang";
15758
15634
  } else {
15759
15635
  return "3' overhang";
@@ -15787,7 +15663,7 @@ function getLeftAndRightOfSequenceInRangeGivenPosition(range, position, sequence
15787
15663
  leftHandSide: "",
15788
15664
  rightHandSide: ""
15789
15665
  };
15790
- if (isPositionWithinRange(position, range, sequence.length)) {
15666
+ if (isPositionWithinRange(position, range)) {
15791
15667
  result.leftHandSide = getSequenceWithinRange(
15792
15668
  {
15793
15669
  start: range.start,
@@ -15827,13 +15703,13 @@ function getOverlapBetweenTwoSequences(sequenceToFind, sequenceToSearchIn) {
15827
15703
  }
15828
15704
  }
15829
15705
  __name(getOverlapBetweenTwoSequences, "getOverlapBetweenTwoSequences");
15830
- function getPossiblePartsFromSequenceAndEnzymes(seqData, restrictionEnzymes) {
15831
- const enzymes = Array.isArray(restrictionEnzymes) ? restrictionEnzymes : [restrictionEnzymes];
15706
+ function getPossiblePartsFromSequenceAndEnzyme(seqData, restrictionEnzymes) {
15707
+ restrictionEnzymes = restrictionEnzymes.length ? restrictionEnzymes : [restrictionEnzymes];
15832
15708
  const bps = seqData.sequence;
15833
15709
  const seqLen = bps.length;
15834
- const circular = seqData.circular || false;
15710
+ const circular = seqData.circular;
15835
15711
  let cutsites = [];
15836
- enzymes.forEach((enzyme) => {
15712
+ restrictionEnzymes.forEach((enzyme) => {
15837
15713
  const newCutsites = cutSequenceByRestrictionEnzyme(bps, circular, enzyme);
15838
15714
  cutsites = cutsites.concat(newCutsites);
15839
15715
  });
@@ -15874,13 +15750,13 @@ function getPossiblePartsFromSequenceAndEnzymes(seqData, restrictionEnzymes) {
15874
15750
  return parts;
15875
15751
  }
15876
15752
  }
15877
- __name(getPossiblePartsFromSequenceAndEnzymes, "getPossiblePartsFromSequenceAndEnzymes");
15753
+ __name(getPossiblePartsFromSequenceAndEnzyme, "getPossiblePartsFromSequenceAndEnzyme");
15878
15754
  function getPartBetweenEnzymesWithInclusiveOverhangs(cut1, cut2, seqLen) {
15879
15755
  const firstCutOffset = getEnzymeRelativeOffset(cut1.restrictionEnzyme);
15880
15756
  const secondCutOffset = getEnzymeRelativeOffset(cut2.restrictionEnzyme);
15881
- const start = (cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition) || 0;
15757
+ const start = cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition;
15882
15758
  const end = normalizePositionByRangeLength(
15883
- (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition || 0 : cut2.topSnipPosition || 0) - 1,
15759
+ (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition : cut2.topSnipPosition) - 1,
15884
15760
  seqLen
15885
15761
  );
15886
15762
  return {
@@ -15891,20 +15767,20 @@ function getPartBetweenEnzymesWithInclusiveOverhangs(cut1, cut2, seqLen) {
15891
15767
  firstCut: cut1,
15892
15768
  //the offset is always counting with 0 being at the top snip position
15893
15769
  firstCutOffset,
15894
- firstCutOverhang: cut1.overhangBps || "",
15895
- firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps || "" : "",
15896
- firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps || "") : "",
15770
+ firstCutOverhang: cut1.overhangBps,
15771
+ firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps : "",
15772
+ firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps) : "",
15897
15773
  secondCut: cut2,
15898
15774
  //the offset is always counting with 0 being at the top snip position
15899
15775
  secondCutOffset,
15900
- secondCutOverhang: cut2.overhangBps || "",
15901
- secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps || "" : "",
15902
- secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps || "") : ""
15776
+ secondCutOverhang: cut2.overhangBps,
15777
+ secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps : "",
15778
+ secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps) : ""
15903
15779
  };
15904
15780
  }
15905
15781
  __name(getPartBetweenEnzymesWithInclusiveOverhangs, "getPartBetweenEnzymesWithInclusiveOverhangs");
15906
15782
  function getEnzymeRelativeOffset(enzyme) {
15907
- return (enzyme.bottomSnipOffset || 0) - (enzyme.topSnipOffset || 0);
15783
+ return enzyme.bottomSnipOffset - enzyme.topSnipOffset;
15908
15784
  }
15909
15785
  __name(getEnzymeRelativeOffset, "getEnzymeRelativeOffset");
15910
15786
  function pairwise(list) {
@@ -15920,8 +15796,6 @@ __name(pairwise, "pairwise");
15920
15796
  function getReverseAminoAcidStringFromSequenceString(sequenceString) {
15921
15797
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
15922
15798
  sequenceString,
15923
- false,
15924
- null,
15925
15799
  false
15926
15800
  );
15927
15801
  const aaArray = [];
@@ -15960,8 +15834,7 @@ function getReverseComplementAnnotation(annotation, sequenceLength) {
15960
15834
  __name(getReverseComplementAnnotation, "getReverseComplementAnnotation");
15961
15835
  function getReverseComplementSequenceAndAnnoations(pSeqObj, options = {}) {
15962
15836
  const seqObj = tidyUpSequenceData(
15963
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15964
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15837
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15965
15838
  __spreadValues({ doNotRemoveInvalidChars: true }, options)
15966
15839
  );
15967
15840
  const newSeqObj = Object.assign(
@@ -15970,20 +15843,17 @@ function getReverseComplementSequenceAndAnnoations(pSeqObj, options = {}) {
15970
15843
  {
15971
15844
  sequence: getReverseComplementSequenceString(seqObj.sequence)
15972
15845
  },
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
- )
15846
+ annotationTypes.reduce((acc, type) => {
15847
+ if (seqObj[type]) {
15848
+ acc[type] = map(seqObj[type], (annotation) => {
15849
+ return getReverseComplementAnnotation(
15850
+ annotation,
15851
+ seqObj.sequence.length
15852
+ );
15853
+ });
15854
+ }
15855
+ return acc;
15856
+ }, {})
15987
15857
  );
15988
15858
  return tidyUpSequenceData(newSeqObj, __spreadValues({
15989
15859
  doNotRemoveInvalidChars: true
@@ -16005,13 +15875,10 @@ __name(getReverseSequenceString, "getReverseSequenceString");
16005
15875
  function guessIfSequenceIsDnaAndNotProtein(seq, options = {}) {
16006
15876
  const { threshold = 0.9, loose } = options;
16007
15877
  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
- );
15878
+ const dnaLetterMap = dnaLetters.reduce((acc, letter) => {
15879
+ acc[letter.toUpperCase()] = true;
15880
+ return acc;
15881
+ }, {});
16015
15882
  let count = 0;
16016
15883
  if (!seq || !seq.length) return true;
16017
15884
  for (let index = 0; index < seq.length; index++) {
@@ -16031,17 +15898,15 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16031
15898
  const yOffsetLevelMap = {};
16032
15899
  const wrappedAnnotations = {};
16033
15900
  forEach(annotations, (annotation) => {
16034
- var _a;
16035
15901
  const containsLocations = !!(annotation.locations && annotation.locations.length);
16036
15902
  if (annotation.overlapsSelf) {
16037
15903
  if (!wrappedAnnotations[annotation.id]) {
16038
15904
  mapAnnotationToRows({
16039
- annotation: __spreadProps(__spreadValues({}, annotation), {
15905
+ annotation: {
16040
15906
  start: 0,
16041
15907
  end: sequenceLength - 1,
16042
- id: `__tempAnnRemoveMe__${annotation.id}`,
16043
- overlapsSelf: false
16044
- }),
15908
+ id: `__tempAnnRemoveMe__${annotation.id}`
15909
+ },
16045
15910
  sequenceLength,
16046
15911
  bpsPerRow,
16047
15912
  annotationsToRowsMap,
@@ -16062,7 +15927,7 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16062
15927
  splitForwardReverse
16063
15928
  });
16064
15929
  if (containsLocations) {
16065
- (_a = annotation.locations) == null ? void 0 : _a.forEach((location) => {
15930
+ annotation.locations.forEach((location) => {
16066
15931
  mapAnnotationToRows({
16067
15932
  annotation,
16068
15933
  sequenceLength,
@@ -16078,7 +15943,7 @@ function mapAnnotationsToRows(annotations, sequenceLength, bpsPerRow, { splitFor
16078
15943
  forEach(annotationsToRowsMap, (annotationsForRow, i) => {
16079
15944
  annotationsToRowsMap[i] = filter(
16080
15945
  annotationsForRow,
16081
- (ann) => !startsWith(String(ann.id), "__tempAnnRemoveMe__")
15946
+ (ann) => !startsWith(ann.id, "__tempAnnRemoveMe__")
16082
15947
  );
16083
15948
  });
16084
15949
  return annotationsToRowsMap;
@@ -16120,13 +15985,6 @@ function mapAnnotationToRows({
16120
15985
  yOffset = ann.yOffset;
16121
15986
  }
16122
15987
  });
16123
- if (yOffset === void 0) {
16124
- annotationsForRow.forEach((ann) => {
16125
- if (ann.id === annotation.id) {
16126
- yOffset = ann.yOffset;
16127
- }
16128
- });
16129
- }
16130
15988
  } else {
16131
15989
  if (location) {
16132
15990
  annotationsForRow.forEach((ann) => {
@@ -16135,74 +15993,32 @@ function mapAnnotationToRows({
16135
15993
  }
16136
15994
  });
16137
15995
  } else {
16138
- if (index > 0 && annotationsForRow.length && annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
15996
+ if (index > 0 && //second half of an annotation range
15997
+ annotationsForRow.length && //there are already annotations within the row
15998
+ annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
16139
15999
  yOffset = annotationsForRow[annotationsForRow.length - 1].yOffset;
16140
16000
  } 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
- });
16001
+ yOffset = getYOffsetForPotentiallyCircularRange(
16002
+ annotation,
16003
+ yOffsetsForRow
16004
+ );
16195
16005
  }
16006
+ if (!yOffsetsForRow[yOffset]) yOffsetsForRow[yOffset] = [];
16007
+ yOffsetsForRow[yOffset].push({
16008
+ start,
16009
+ end
16010
+ });
16196
16011
  }
16197
16012
  }
16198
- annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, annotation), {
16013
+ annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues({
16199
16014
  id: annotation.id,
16200
16015
  annotation,
16201
16016
  start,
16202
16017
  end
16203
- }), containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16018
+ }, containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16204
16019
  yOffset,
16205
16020
  enclosingRangeType: range.type
16021
+ //either "beginning", "end" or "beginningAndEnd"
16206
16022
  }));
16207
16023
  }
16208
16024
  });
@@ -16212,14 +16028,10 @@ function prepareCircularViewData(sequenceData) {
16212
16028
  const clonedSeqData = cloneDeep(sequenceData);
16213
16029
  annotationTypes.forEach((annotationType) => {
16214
16030
  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
- }
16031
+ const maxYOffset = getYOffsetsForPotentiallyCircularRanges(
16032
+ clonedSeqData[annotationType]
16033
+ ).maxYOffset;
16034
+ clonedSeqData[annotationType].maxYOffset = maxYOffset;
16223
16035
  }
16224
16036
  });
16225
16037
  return clonedSeqData;
@@ -16232,19 +16044,14 @@ function prepareRowData(sequenceData, bpsPerRow) {
16232
16044
  const rowMap = {};
16233
16045
  annotationTypes.forEach((type) => {
16234
16046
  rowMap[type] = mapAnnotationsToRows(
16235
- sequenceData[type] || [],
16047
+ sequenceData[type],
16236
16048
  sequenceLength,
16237
16049
  bpsPerRow,
16238
16050
  { splitForwardReverse: type === "primers" }
16239
16051
  );
16240
16052
  });
16241
16053
  for (let rowNumber = 0; rowNumber < totalRows; rowNumber++) {
16242
- const row = {
16243
- rowNumber,
16244
- start: 0,
16245
- end: 0,
16246
- sequence: ""
16247
- };
16054
+ const row = {};
16248
16055
  row.rowNumber = rowNumber;
16249
16056
  row.start = rowNumber * bpsPerRow;
16250
16057
  row.end = (rowNumber + 1) * bpsPerRow - 1 < sequenceLength ? (rowNumber + 1) * bpsPerRow - 1 : sequenceLength - 1;
@@ -16305,16 +16112,17 @@ function addGapsToSeqReads(refSeq, seqReads) {
16305
16112
  }
16306
16113
  }
16307
16114
  const refSeqWithGaps = insertGapsIntoRefSeq(refSeq.sequence, seqReads);
16308
- const seqReadsWithGaps = [{ name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }];
16115
+ const seqReadsWithGaps = [
16116
+ { name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }
16117
+ ];
16309
16118
  seqReads.forEach((seqRead) => {
16310
16119
  const allInsertionsInSeqReads = [];
16311
16120
  seqReads.forEach((seqRead2) => {
16312
16121
  const splitSeqRead = seqRead2.cigar.match(/([0-9]*[SMDI])/g);
16313
- if (!splitSeqRead) return;
16314
16122
  let adjustedSeqReadPos2 = cloneDeep(seqRead2.pos);
16315
16123
  if (splitSeqRead[0].slice(-1) === "S") {
16316
16124
  const numOfBeginningSoftClipped = splitSeqRead[0].slice(0, -1);
16317
- adjustedSeqReadPos2 = seqRead2.pos - Number(numOfBeginningSoftClipped);
16125
+ adjustedSeqReadPos2 = seqRead2.pos - numOfBeginningSoftClipped;
16318
16126
  }
16319
16127
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
16320
16128
  if (splitSeqRead[componentI].slice(-1) === "I") {
@@ -16340,11 +16148,10 @@ function addGapsToSeqReads(refSeq, seqReads) {
16340
16148
  }
16341
16149
  });
16342
16150
  const splitSeqReadChunk = seqRead.cigar.match(/([0-9]*[SMDI])/g);
16343
- if (!splitSeqReadChunk) return;
16344
16151
  let adjustedSeqReadPos = cloneDeep(seqRead.pos);
16345
16152
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16346
16153
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16347
- adjustedSeqReadPos = seqRead.pos - Number(numOfBeginningSoftClipped);
16154
+ adjustedSeqReadPos = seqRead.pos - numOfBeginningSoftClipped;
16348
16155
  }
16349
16156
  let eachSeqReadWithGaps = seqRead.seq.split("");
16350
16157
  if (adjustedSeqReadPos > 0) {
@@ -16532,11 +16339,10 @@ function addGapsToSeqReads(refSeq, seqReads) {
16532
16339
  const seqReadLengthsBeforeRefSeqStart = [];
16533
16340
  seqReads.forEach((seq) => {
16534
16341
  const splitSeqReadChunk = seq.cigar.match(/([0-9]*[SMDI])/g);
16535
- if (!splitSeqReadChunk) return;
16536
16342
  let adjustedSeqReadPos = cloneDeep(seq.pos);
16537
16343
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16538
16344
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16539
- adjustedSeqReadPos = seq.pos - Number(numOfBeginningSoftClipped);
16345
+ adjustedSeqReadPos = seq.pos - numOfBeginningSoftClipped;
16540
16346
  if (adjustedSeqReadPos < 0) {
16541
16347
  seqReadLengthsBeforeRefSeqStart.push(Math.abs(adjustedSeqReadPos));
16542
16348
  }
@@ -16546,14 +16352,13 @@ function addGapsToSeqReads(refSeq, seqReads) {
16546
16352
  for (let i = 1; i < seqReadsWithGaps.length; i++) {
16547
16353
  const eachSeqReadWithGaps = seqReadsWithGaps[i].sequence.split("");
16548
16354
  const splitSeqReadChunk = seqReads[i - 1].cigar.match(/([0-9]*[SMDI])/g);
16549
- if (!splitSeqReadChunk) continue;
16550
16355
  let adjustedSeqReadPos = cloneDeep(seqReads[i - 1].pos);
16551
16356
  if (seqReadLengthsBeforeRefSeqStart.length > 0) {
16552
16357
  longestSeqReadLength = Math.max(...seqReadLengthsBeforeRefSeqStart);
16553
16358
  }
16554
16359
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16555
16360
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16556
- adjustedSeqReadPos = seqReads[i - 1].pos - Number(numOfBeginningSoftClipped);
16361
+ adjustedSeqReadPos = seqReads[i - 1].pos - numOfBeginningSoftClipped;
16557
16362
  if (adjustedSeqReadPos > 0) {
16558
16363
  if (longestSeqReadLength > 0) {
16559
16364
  eachSeqReadWithGaps.unshift("-".repeat(longestSeqReadLength + 1));
@@ -16667,11 +16472,11 @@ function calculateNebTm(sequence, { monovalentCationConc = 0.05, primerConc = 5e
16667
16472
  for (let i = 0; i < seq.length; i++) {
16668
16473
  if (i === 0 || i === seq.length - 1) {
16669
16474
  if (seq[i] === "G" || seq[i] === "C") {
16670
- hi += sequenceToEnthalpyMap["initiationWithTerminalGC"];
16671
- si += sequenceToEntropyMap["initiationWithTerminalGC"];
16475
+ hi += sequenceToEnthalpyMap.initiationWithTerminalGC;
16476
+ si += sequenceToEntropyMap.initiationWithTerminalGC;
16672
16477
  } else if (seq[i] === "A" || seq[i] === "T") {
16673
- hi += sequenceToEnthalpyMap["initiationWithTerminalAT"];
16674
- si += sequenceToEntropyMap["initiationWithTerminalAT"];
16478
+ hi += sequenceToEnthalpyMap.initiationWithTerminalAT;
16479
+ si += sequenceToEntropyMap.initiationWithTerminalAT;
16675
16480
  }
16676
16481
  }
16677
16482
  if (i < seq.length - 1) {
@@ -16714,13 +16519,9 @@ function calculateNebTa(sequences, primerConc, { monovalentCationConc, polymeras
16714
16519
  `${sequences.length} sequences received when 2 primers were expected`
16715
16520
  );
16716
16521
  }
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
- });
16522
+ const meltingTemperatures = sequences.map(
16523
+ (seq) => calculateNebTm(seq, primerConc, { monovalentCationConc })
16524
+ );
16724
16525
  meltingTemperatures.sort((a, b) => a - b);
16725
16526
  const lowerMeltingTemp = meltingTemperatures[0];
16726
16527
  let annealingTemp;
@@ -16797,17 +16598,17 @@ function isValidSequence(sequence) {
16797
16598
  __name(isValidSequence, "isValidSequence");
16798
16599
  function calculateSantaLuciaTm(sequence) {
16799
16600
  try {
16800
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16801
- if (!isValidSequence(seq)) {
16601
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16602
+ if (!isValidSequence(sequence)) {
16802
16603
  throw new Error("Invalid sequence: contains non-DNA characters");
16803
16604
  }
16804
- if (seq.length < 2) {
16605
+ if (sequence.length < 2) {
16805
16606
  throw new Error("Sequence too short: minimum length is 2 bases");
16806
16607
  }
16807
16608
  let deltaH = 0;
16808
16609
  let deltaS = 0;
16809
- for (let i = 0; i < seq.length - 1; i++) {
16810
- const dinucleotide = seq.substring(i, i + 2);
16610
+ for (let i = 0; i < sequence.length - 1; i++) {
16611
+ const dinucleotide = sequence.substring(i, i + 2);
16811
16612
  if (dinucleotide.includes("N")) {
16812
16613
  continue;
16813
16614
  }
@@ -16817,23 +16618,23 @@ function calculateSantaLuciaTm(sequence) {
16817
16618
  deltaS += params.dS;
16818
16619
  }
16819
16620
  }
16820
- const firstBase = seq[0];
16821
- const lastBase = seq[seq.length - 1];
16621
+ const firstBase = sequence[0];
16622
+ const lastBase = sequence[sequence.length - 1];
16822
16623
  if (firstBase === "G" || firstBase === "C") {
16823
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16824
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16624
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16625
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16825
16626
  } else {
16826
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16827
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16627
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16628
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16828
16629
  }
16829
16630
  if (lastBase === "G" || lastBase === "C") {
16830
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16831
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16631
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16632
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16832
16633
  } else {
16833
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16834
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16634
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16635
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16835
16636
  }
16836
- const nnPairs = seq.length - 1;
16637
+ const nnPairs = sequence.length - 1;
16837
16638
  deltaS = applySaltCorrection(deltaS, nnPairs);
16838
16639
  const C = PRIMER3_PARAMS.dnaConc * 1e-9;
16839
16640
  const Tm = deltaH * 1e3 / (deltaS + PRIMER3_PARAMS.R * Math.log(C / 4));
@@ -16845,16 +16646,16 @@ function calculateSantaLuciaTm(sequence) {
16845
16646
  __name(calculateSantaLuciaTm, "calculateSantaLuciaTm");
16846
16647
  function calculateEndStability(sequence) {
16847
16648
  try {
16848
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16849
- if (!isValidSequence(seq)) {
16649
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16650
+ if (!isValidSequence(sequence)) {
16850
16651
  throw new Error("Invalid sequence: contains non-DNA characters");
16851
16652
  }
16852
- if (seq.length < 5) {
16653
+ if (sequence.length < 5) {
16853
16654
  throw new Error(
16854
16655
  "Sequence too short: minimum length is 5 bases for end stability calculation"
16855
16656
  );
16856
16657
  }
16857
- const last5Bases = seq.substring(seq.length - 5);
16658
+ const last5Bases = sequence.substring(sequence.length - 5);
16858
16659
  let deltaH = 0;
16859
16660
  let deltaS = 0;
16860
16661
  for (let i = 0; i < 4; i++) {
@@ -16871,18 +16672,18 @@ function calculateEndStability(sequence) {
16871
16672
  const firstBase = last5Bases[0];
16872
16673
  const lastBase = last5Bases[last5Bases.length - 1];
16873
16674
  if (firstBase === "G" || firstBase === "C") {
16874
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16875
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16675
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16676
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16876
16677
  } else {
16877
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16878
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16678
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16679
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16879
16680
  }
16880
16681
  if (lastBase === "G" || lastBase === "C") {
16881
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16882
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16682
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16683
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16883
16684
  } else {
16884
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16885
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16685
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16686
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16886
16687
  }
16887
16688
  const T = 310.15;
16888
16689
  const deltaG = deltaH - T * deltaS / 1e3;
@@ -16897,40 +16698,24 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16897
16698
  const pairs = [];
16898
16699
  if (!cutsites.length) return [];
16899
16700
  let sortedCutsites = cutsites.sort((a, b) => {
16900
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
16701
+ return a.topSnipPosition - b.topSnipPosition;
16901
16702
  });
16902
16703
  if (!circular) {
16903
16704
  sortedCutsites = [
16904
16705
  {
16905
- start: 0,
16906
- end: 0,
16907
16706
  topSnipPosition: 0,
16908
16707
  bottomSnipPosition: 0,
16909
16708
  overhangSize: 0,
16910
16709
  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
- }
16710
+ name: "START_OF_SEQ"
16918
16711
  },
16919
16712
  ...sortedCutsites,
16920
16713
  {
16921
- start: sequenceLength,
16922
- end: sequenceLength,
16923
16714
  topSnipPosition: sequenceLength,
16924
16715
  bottomSnipPosition: sequenceLength,
16925
16716
  overhangSize: 0,
16926
16717
  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
- }
16718
+ name: "END_OF_SEQ"
16934
16719
  }
16935
16720
  ];
16936
16721
  }
@@ -16953,11 +16738,11 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16953
16738
  });
16954
16739
  pairs.forEach(([cut1, cut2]) => {
16955
16740
  const start = normalizePositionByRangeLength(
16956
- cut1.topSnipPosition || 0,
16741
+ cut1.topSnipPosition,
16957
16742
  sequenceLength
16958
16743
  );
16959
16744
  const end = normalizePositionByRangeLength(
16960
- (cut2.topSnipPosition || 0) - 1,
16745
+ cut2.topSnipPosition - 1,
16961
16746
  sequenceLength
16962
16747
  );
16963
16748
  const fragmentRange = { start, end };
@@ -16975,9 +16760,7 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16975
16760
  })
16976
16761
  }, fragmentRange), {
16977
16762
  size,
16978
- id,
16979
- name: `${cut1.restrictionEnzyme.name} -- ${cut2.restrictionEnzyme.name} ${size} bps`
16980
- // Add missing name property
16763
+ id
16981
16764
  }));
16982
16765
  });
16983
16766
  fragments.filter((fragment) => {
@@ -16989,33 +16772,21 @@ function getDigestFragmentsForCutsites(sequenceLength, circular, cutsites, opts
16989
16772
  return fragments;
16990
16773
  }
16991
16774
  __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
16775
+ function getDigestFragmentsForRestrictionEnzymes(sequence, circular, restrictionEnzymeOrEnzymes, opts) {
16776
+ const restrictionEnzymes = Array.isArray(restrictionEnzymeOrEnzymes) ? restrictionEnzymeOrEnzymes : [restrictionEnzymeOrEnzymes];
16777
+ const cutsites = flatMap(restrictionEnzymes, (restrictionEnzyme) => {
16778
+ return cutSequenceByRestrictionEnzyme(
16779
+ sequence,
16780
+ circular,
16781
+ restrictionEnzyme
17011
16782
  );
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
16783
  });
16784
+ return getDigestFragmentsForCutsites(
16785
+ sequence.length,
16786
+ circular,
16787
+ cutsites,
16788
+ opts
16789
+ );
17019
16790
  }
17020
16791
  __name(getDigestFragmentsForRestrictionEnzymes, "getDigestFragmentsForRestrictionEnzymes");
17021
16792
  function convertAACaretPositionOrRangeToDna(rangeOrCaret) {
@@ -17061,13 +16832,11 @@ function shiftAnnotationsByLen({
17061
16832
  }) {
17062
16833
  modifiableTypes.forEach((annotationType) => {
17063
16834
  const existingAnnotations = seqData[annotationType];
17064
- if (existingAnnotations) {
17065
- seqData[annotationType] = adjustAnnotationsToInsert(
17066
- existingAnnotations,
17067
- caretPosition,
17068
- insertLength
17069
- );
17070
- }
16835
+ seqData[annotationType] = adjustAnnotationsToInsert(
16836
+ existingAnnotations,
16837
+ caretPosition,
16838
+ insertLength
16839
+ );
17071
16840
  });
17072
16841
  }
17073
16842
  __name(shiftAnnotationsByLen, "shiftAnnotationsByLen");
@@ -17137,7 +16906,7 @@ exports.getMassOfAaString = getMassOfAaString;
17137
16906
  exports.getMergedFeatureMap = getMergedFeatureMap;
17138
16907
  exports.getOrfsFromSequence = getOrfsFromSequence;
17139
16908
  exports.getOverlapBetweenTwoSequences = getOverlapBetweenTwoSequences;
17140
- exports.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzymes;
16909
+ exports.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzyme;
17141
16910
  exports.getReverseAminoAcidStringFromSequenceString = getReverseAminoAcidStringFromSequenceString;
17142
16911
  exports.getReverseComplementAminoAcidStringFromSequenceString = getReverseComplementAminoAcidStringFromSequenceString;
17143
16912
  exports.getReverseComplementAnnotation = getReverseComplementAnnotation;