@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.umd.cjs CHANGED
@@ -2590,10 +2590,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2590
2590
  }
2591
2591
  }
2592
2592
  }
2593
- return null;
2594
2593
  }
2595
2594
  __name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
2596
- function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
2595
+ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
2597
2596
  const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
2598
2597
  rangeA,
2599
2598
  maxRangeLength
@@ -2614,22 +2613,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2614
2613
  }
2615
2614
  });
2616
2615
  });
2617
- if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
2618
- const joinedOverlap = {};
2619
- overlaps = flatMap(overlaps, (o) => {
2620
- if (o.start === 0) {
2621
- joinedOverlap.end = o.end;
2622
- return [];
2623
- } else if (o.end === maxRangeLength - 1) {
2624
- joinedOverlap.start = o.start;
2625
- return [];
2626
- }
2627
- return [o];
2628
- });
2629
- if (Object.keys(joinedOverlap).length > 0) {
2630
- overlaps.push(joinedOverlap);
2631
- }
2632
- }
2633
2616
  return overlaps;
2634
2617
  }
2635
2618
  __name(getOverlapsOfPotentiallyCircularRanges, "getOverlapsOfPotentiallyCircularRanges");
@@ -2701,7 +2684,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2701
2684
  if (!overlaps.length) {
2702
2685
  return rangeToBeTrimmed;
2703
2686
  }
2704
- const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
2687
+ const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
2688
+ rangeToBeTrimmed,
2689
+ sequenceLength
2690
+ );
2705
2691
  splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
2706
2692
  overlaps.forEach(function(overlap) {
2707
2693
  if (nonCircularRangeToBeTrimmed) {
@@ -2744,7 +2730,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2744
2730
  end: outputTrimmedRange.end
2745
2731
  });
2746
2732
  }
2747
- return void 0;
2748
2733
  }
2749
2734
  __name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
2750
2735
  function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
@@ -2891,36 +2876,28 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2891
2876
  }
2892
2877
  }
2893
2878
  }
2894
- return overlaps;
2895
2879
  }
2896
2880
  __name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
2897
2881
  function provideInclusiveOptions(funToWrap) {
2898
- return function(...args) {
2882
+ return function() {
2883
+ const args = Array.prototype.slice.call(arguments);
2899
2884
  const options = args[args.length - 1];
2900
2885
  if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
2901
2886
  args.forEach(function(arg, index) {
2902
- const potentialRange = arg;
2903
- if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
2904
- args[index] = assign(potentialRange, {
2905
- start: potentialRange.start - 1
2906
- });
2887
+ if (arg && arg.start > -1 && options.inclusive1BasedStart) {
2888
+ args[index] = assign(arg, { start: arg.start - 1 });
2907
2889
  }
2908
- if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
2909
- args[index] = assign(potentialRange, {
2910
- end: potentialRange.end - 1
2911
- });
2890
+ if (arg && arg.end > -1 && options.inclusive1BasedEnd) {
2891
+ args[index] = assign(arg, { end: arg.end - 1 });
2912
2892
  }
2913
2893
  });
2914
2894
  }
2915
2895
  let returnVal = funToWrap.apply(this, args);
2916
- const potentialReturn = returnVal;
2917
- if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
2918
- returnVal = assign(potentialReturn, {
2919
- start: potentialReturn.start + 1
2920
- });
2896
+ if (returnVal && returnVal.start > -1 && options && options.inclusive1BasedStart) {
2897
+ returnVal = assign(returnVal, { start: returnVal.start + 1 });
2921
2898
  }
2922
- if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
2923
- returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
2899
+ if (returnVal && returnVal.end > -1 && options && options.inclusive1BasedEnd) {
2900
+ returnVal = assign(returnVal, { end: returnVal.end + 1 });
2924
2901
  }
2925
2902
  return returnVal;
2926
2903
  };
@@ -2966,7 +2943,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2966
2943
  return positionFits;
2967
2944
  }
2968
2945
  __name(isPositionWithinRange, "isPositionWithinRange");
2969
- function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
2946
+ function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
2970
2947
  let position = pPosition;
2971
2948
  if (position < 0) {
2972
2949
  position += sequenceLength;
@@ -3146,9 +3123,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3146
3123
  if (typeof subSequence === "string") {
3147
3124
  subSequence += sequence.slice(0, range.end + 1);
3148
3125
  } else {
3149
- subSequence = subSequence.concat(
3150
- sequence.slice(0, range.end + 1)
3151
- );
3126
+ subSequence = subSequence.concat(sequence.slice(0, range.end + 1));
3152
3127
  }
3153
3128
  return subSequence;
3154
3129
  } else {
@@ -3168,7 +3143,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3168
3143
  }
3169
3144
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
3170
3145
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
3171
- let yOffset = 0;
3146
+ let yOffset = [];
3172
3147
  const openYOffsetFound = YOffsetLevelsWithRanges.some(
3173
3148
  function(rangesAlreadyAddedToYOffset, index) {
3174
3149
  const rangeBlocked = rangesAlreadyAddedToYOffset.some(
@@ -3181,7 +3156,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3181
3156
  );
3182
3157
  if (!rangeBlocked) {
3183
3158
  yOffset = index;
3184
- if (assignYOffsetToRange) range.yOffset = index;
3185
3159
  rangesAlreadyAddedToYOffset.push(range);
3186
3160
  return true;
3187
3161
  }
@@ -3190,7 +3164,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3190
3164
  );
3191
3165
  if (!openYOffsetFound) {
3192
3166
  yOffset = YOffsetLevelsWithRanges.length;
3193
- if (assignYOffsetToRange) range.yOffset = YOffsetLevelsWithRanges.length;
3194
3167
  }
3195
3168
  return yOffset;
3196
3169
  }
@@ -3202,8 +3175,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3202
3175
  ranges.forEach(function(range) {
3203
3176
  const yOffset = getYOffsetForPotentiallyCircularRange(
3204
3177
  range,
3205
- yOffsetLevels,
3206
- assignYOffsetToRange
3178
+ yOffsetLevels
3207
3179
  );
3208
3180
  yOffsets.push(yOffset);
3209
3181
  if (yOffset > maxYOffset) {
@@ -3218,20 +3190,21 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3218
3190
  __name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
3219
3191
  const invertRange = provideInclusiveOptions(invertRange$1);
3220
3192
  function invertRange$1(rangeOrCaret, rangeMax) {
3221
- if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
3193
+ if (rangeOrCaret.start > -1) {
3222
3194
  const start = rangeOrCaret.end + 1;
3223
3195
  const end = rangeOrCaret.start - 1;
3224
3196
  return {
3225
3197
  start: normalizePositionByRangeLength(start, rangeMax, false),
3226
3198
  end: normalizePositionByRangeLength(end, rangeMax, false)
3227
3199
  };
3228
- } else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
3229
- return {
3230
- start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
3231
- end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
3232
- };
3200
+ } else {
3201
+ if (rangeOrCaret > -1) {
3202
+ return {
3203
+ start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
3204
+ end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
3205
+ };
3206
+ }
3233
3207
  }
3234
- return void 0;
3235
3208
  }
3236
3209
  __name(invertRange$1, "invertRange$1");
3237
3210
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
@@ -3285,10 +3258,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3285
3258
  "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
3286
3259
  );
3287
3260
  }
3288
- const newSubrange = {
3289
- start: subRange.start - containerRange.start,
3290
- end: subRange.end - containerRange.start
3291
- };
3261
+ const newSubrange = {};
3262
+ newSubrange.start = subRange.start - containerRange.start;
3263
+ newSubrange.end = subRange.end - containerRange.start;
3292
3264
  if (newSubrange.start < 0) {
3293
3265
  newSubrange.start += sequenceLength;
3294
3266
  }
@@ -3299,10 +3271,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3299
3271
  }
3300
3272
  __name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
3301
3273
  function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
3302
- const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
3274
+ const mod = rangeLength ? modulo : identity;
3303
3275
  const newRange = assign({}, rangeToBeAdjusted, {
3304
- start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
3305
- end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
3276
+ start: mod(rangeToBeAdjusted.start - (rotateTo || 0), rangeLength),
3277
+ end: mod(rangeToBeAdjusted.end - (rotateTo || 0), rangeLength)
3306
3278
  });
3307
3279
  return newRange;
3308
3280
  }
@@ -3388,11 +3360,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3388
3360
  forEach(
3389
3361
  omitBy(seqsToAnnotateById, (s) => !s.sequence.length),
3390
3362
  ({ circular, sequence }, id) => {
3391
- function getMatches({
3392
- seqToMatchAgainst,
3393
- isReverse,
3394
- seqLen: seqLen2
3395
- }) {
3363
+ function getMatches({ seqToMatchAgainst, isReverse, seqLen: seqLen2 }) {
3396
3364
  let match;
3397
3365
  let lastMatch;
3398
3366
  try {
@@ -3412,13 +3380,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3412
3380
  };
3413
3381
  const range = {
3414
3382
  start: matchStart,
3415
- end: normalizePositionByRangeLength(matchEnd - 1, seqLen2, false)
3383
+ end: normalizePositionByRangeLength(matchEnd - 1, seqLen2)
3416
3384
  };
3417
3385
  if (!annotationsToAddBySeqId[id])
3418
3386
  annotationsToAddBySeqId[id] = [];
3419
3387
  annotationsToAddBySeqId[id].push(__spreadProps(__spreadValues({}, isReverse ? {
3420
- start: reversePositionInRange(range.end, seqLen2, false),
3421
- end: reversePositionInRange(range.start, seqLen2, false)
3388
+ start: reversePositionInRange(range.end, seqLen2),
3389
+ end: reversePositionInRange(range.start, seqLen2)
3422
3390
  } : range), {
3423
3391
  strand: isReverse ? -1 : 1,
3424
3392
  id: ann.id
@@ -3449,22 +3417,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3449
3417
  const origSeq = seqsToAnnotateById[id];
3450
3418
  const alreadyExistingAnnsByStartEnd = {};
3451
3419
  forEach(origSeq.annotations, (ann) => {
3452
- alreadyExistingAnnsByStartEnd[getStartEndStr(
3453
- __spreadProps(__spreadValues({}, ann), { strand: typeof ann.strand === "string" ? 1 : ann.strand }),
3454
- { compareName }
3455
- )] = ann;
3420
+ alreadyExistingAnnsByStartEnd[getStartEndStr(ann, { compareName })] = ann;
3456
3421
  });
3457
3422
  const warningCounter = {};
3458
3423
  const toAdd = anns.filter((ann) => {
3459
- const alreadyExistingAnn = alreadyExistingAnnsByStartEnd[getStartEndStr(
3460
- __spreadProps(__spreadValues({}, ann), {
3461
- strand: typeof ann.strand === "string" ? 1 : ann.strand
3462
- }),
3463
- { compareName }
3464
- )];
3424
+ const alreadyExistingAnn = alreadyExistingAnnsByStartEnd[getStartEndStr(ann, { compareName })];
3465
3425
  if (alreadyExistingAnn) return false;
3466
- if (warnIfMoreThan && ann.id !== void 0) {
3467
- warningCounter[String(ann.id)] = (warningCounter[String(ann.id)] || 0) + 1;
3426
+ if (warnIfMoreThan) {
3427
+ warningCounter[ann.id] = (warningCounter[ann.id] || 0) + 1;
3468
3428
  }
3469
3429
  return true;
3470
3430
  }).sort((a, b) => a.start - b.start);
@@ -3473,23 +3433,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3473
3433
  }
3474
3434
  warnIfMoreThan && forEach(warningCounter, (num, annId) => {
3475
3435
  if (num > warnIfMoreThan) {
3476
- const warnings = toReturn["__more_than_warnings"] || {};
3477
- warnings[id] = warnings[id] || [];
3478
- warnings[id].push(annId);
3479
- toReturn["__more_than_warnings"] = warnings;
3436
+ toReturn.__more_than_warnings = toReturn.__more_than_warnings || {};
3437
+ toReturn.__more_than_warnings[id] = toReturn.__more_than_warnings[id] || [];
3438
+ toReturn.__more_than_warnings[id].push(annId);
3480
3439
  }
3481
3440
  });
3482
3441
  });
3483
3442
  return toReturn;
3484
3443
  }
3485
3444
  __name(autoAnnotate, "autoAnnotate");
3486
- function getStartEndStr({
3487
- start,
3488
- end,
3489
- name,
3490
- strand,
3491
- forward
3492
- }, { compareName }) {
3445
+ function getStartEndStr({ start, end, name, strand, forward }, { compareName }) {
3493
3446
  const isReverse = strand === -1 || forward === false;
3494
3447
  return `${start}-${end}-${isReverse ? "rev" : "for"}-${compareName ? name : ""}`;
3495
3448
  }
@@ -3503,12 +3456,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3503
3456
  let hitLeftCaret;
3504
3457
  let hitRightCaret;
3505
3458
  for (const bp of regString.replace("(", "").replace(")", "")) {
3506
- let maybeHandleRightCaret = /* @__PURE__ */ __name(function(justAdded) {
3459
+ let maybeHandleRightCaret = function(justAdded) {
3507
3460
  if (hitRightCaret) {
3508
3461
  rightOfCaretHolder += justAdded;
3509
3462
  afterRightCaretHolder = `${rightOfCaretHolder}${afterRightCaretHolder.length ? "|" : ""}${afterRightCaretHolder}`;
3510
3463
  }
3511
- }, "maybeHandleRightCaret");
3464
+ };
3465
+ __name(maybeHandleRightCaret, "maybeHandleRightCaret");
3512
3466
  const ambigVal = ambiguous_dna_values[bp.toUpperCase()];
3513
3467
  if (ambigVal && ambigVal.length > 1) {
3514
3468
  let valToUse;
@@ -3693,17 +3647,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3693
3647
  })),
3694
3648
  "name"
3695
3649
  );
3696
- const featureOverrides = typeof window !== "undefined" && get$1(window, "tg_featureTypeOverrides") || typeof global !== "undefined" && get$1(global, "tg_featureTypeOverrides") || [];
3697
- const mappedOverrides = featureOverrides.map((fo) => {
3650
+ let featureOverrides = typeof window !== "undefined" && get$1(window, "tg_featureTypeOverrides") || typeof global !== "undefined" && get$1(global, "tg_featureTypeOverrides");
3651
+ featureOverrides = featureOverrides || [];
3652
+ featureOverrides = featureOverrides.map((fo) => {
3698
3653
  const originalGenbankFeat = keyedGBFeats[fo.name];
3699
3654
  return __spreadValues(__spreadValues(__spreadValues({}, originalGenbankFeat), fo), originalGenbankFeat ? { isOverridden: true } : { isCustomType: true });
3700
3655
  });
3701
- const keyedOverrides = keyBy(mappedOverrides, "name");
3702
- return __spreadValues(__spreadValues({}, keyedGBFeats), keyedOverrides);
3656
+ featureOverrides = keyBy(featureOverrides, "name");
3657
+ return __spreadValues(__spreadValues({}, keyedGBFeats), featureOverrides);
3703
3658
  }, "getMergedFeatureMap");
3704
- const getFeatureToColorMap = /* @__PURE__ */ __name(({
3705
- includeHidden
3706
- } = {}) => {
3659
+ const getFeatureToColorMap = /* @__PURE__ */ __name(({ includeHidden } = {}) => {
3707
3660
  const toRet = {};
3708
3661
  filter(
3709
3662
  getMergedFeatureMap(),
@@ -3713,9 +3666,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
3713
3666
  });
3714
3667
  return toRet;
3715
3668
  }, "getFeatureToColorMap");
3716
- const getFeatureTypes = /* @__PURE__ */ __name(({
3717
- includeHidden
3718
- } = {}) => filter(getMergedFeatureMap(), (f) => includeHidden ? true : !f.isHidden).map(
3669
+ const getFeatureTypes = /* @__PURE__ */ __name(({ includeHidden } = {}) => filter(getMergedFeatureMap(), (f) => includeHidden ? true : !f.isHidden).map(
3719
3670
  (f) => f.name
3720
3671
  ), "getFeatureTypes");
3721
3672
  function getDefaultExportFromCjs(x) {
@@ -4020,15 +3971,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4020
3971
  var shortidExports = requireShortid();
4021
3972
  const shortid = /* @__PURE__ */ getDefaultExportFromCjs(shortidExports);
4022
3973
  function cutSequenceByRestrictionEnzyme(pSequence, circular, restrictionEnzyme) {
4023
- if (!restrictionEnzyme.forwardRegex || // Add check for undefined
4024
- !restrictionEnzyme.reverseRegex || // Add check for undefined
4025
- restrictionEnzyme.forwardRegex.length === 0 || restrictionEnzyme.reverseRegex.length === 0) {
4026
- console.warn(
4027
- "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long."
4028
- );
4029
- const returnVal = [];
4030
- returnVal.error = "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long.";
4031
- return returnVal;
3974
+ if (restrictionEnzyme.forwardRegex.length === 0 || restrictionEnzyme.reverseRegex.length === 0) {
3975
+ const returnArray = [];
3976
+ returnArray.error = "Cannot cut sequence. Enzyme restriction site must be at least 1 bp long.";
3977
+ return returnArray;
4032
3978
  }
4033
3979
  const forwardRegExpPattern = new RegExp(restrictionEnzyme.forwardRegex, "ig");
4034
3980
  const sequence = pSequence;
@@ -4053,54 +3999,54 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4053
3999
  }
4054
4000
  return cutsitesForward.concat(cutsitesReverse);
4055
4001
  function reverseAllPositionsOfCutsite(cutsite, rangeLength) {
4056
- cutsite = assign({}, cutsite);
4057
4002
  cutsite.start = reversePositionInRange(cutsite.start, rangeLength, false);
4058
4003
  cutsite.end = reversePositionInRange(cutsite.end, rangeLength, false);
4059
- cutsite.topSnipPosition = cutsite.topSnipPosition != null ? reversePositionInRange(cutsite.topSnipPosition, rangeLength, true) : null;
4060
- cutsite.bottomSnipPosition = cutsite.bottomSnipPosition != null ? reversePositionInRange(cutsite.bottomSnipPosition, rangeLength, true) : null;
4061
- if (cutsite.cutType === 1 && cutsite.cutsTwice) {
4062
- if (cutsite.upstreamTopSnip != null && cutsite.upstreamBottomSnip != null) {
4063
- cutsite.upstreamTopSnip = reversePositionInRange(
4064
- cutsite.upstreamTopSnip,
4065
- rangeLength,
4066
- true
4067
- );
4068
- cutsite.upstreamBottomSnip = reversePositionInRange(
4069
- cutsite.upstreamBottomSnip,
4070
- rangeLength,
4071
- true
4072
- );
4073
- }
4074
- }
4075
- if (cutsite.recognitionSiteRange) {
4076
- cutsite.recognitionSiteRange = __spreadValues({}, cutsite.recognitionSiteRange);
4077
- cutsite.recognitionSiteRange.start = reversePositionInRange(
4078
- cutsite.recognitionSiteRange.start,
4004
+ cutsite.topSnipPosition = reversePositionInRange(
4005
+ cutsite.topSnipPosition,
4006
+ rangeLength,
4007
+ true
4008
+ );
4009
+ cutsite.bottomSnipPosition = reversePositionInRange(
4010
+ cutsite.bottomSnipPosition,
4011
+ rangeLength,
4012
+ true
4013
+ );
4014
+ if (cutsite.cutsTwice) {
4015
+ cutsite.upstreamTopSnip = reversePositionInRange(
4016
+ cutsite.upstreamTopSnip,
4079
4017
  rangeLength,
4080
- false
4018
+ true
4081
4019
  );
4082
- cutsite.recognitionSiteRange.end = reversePositionInRange(
4083
- cutsite.recognitionSiteRange.end,
4020
+ cutsite.upstreamBottomSnip = reversePositionInRange(
4021
+ cutsite.upstreamBottomSnip,
4084
4022
  rangeLength,
4085
- false
4023
+ true
4086
4024
  );
4087
4025
  }
4088
- return __spreadProps(__spreadValues({}, cutsite), {
4026
+ cutsite.recognitionSiteRange.start = reversePositionInRange(
4027
+ cutsite.recognitionSiteRange.start,
4028
+ rangeLength,
4029
+ false
4030
+ );
4031
+ cutsite.recognitionSiteRange.end = reversePositionInRange(
4032
+ cutsite.recognitionSiteRange.end,
4033
+ rangeLength,
4034
+ false
4035
+ );
4036
+ return assign({}, cutsite, {
4089
4037
  start: cutsite.end,
4090
4038
  end: cutsite.start,
4091
- overhangBps: getReverseComplementSequenceString(
4092
- cutsite.overhangBps || ""
4093
- ),
4039
+ overhangBps: getReverseComplementSequenceString(cutsite.overhangBps),
4094
4040
  topSnipPosition: cutsite.bottomSnipPosition,
4095
4041
  bottomSnipPosition: cutsite.topSnipPosition,
4096
4042
  upstreamTopSnip: cutsite.upstreamBottomSnip,
4097
4043
  upstreamBottomSnip: cutsite.upstreamTopSnip,
4098
4044
  upstreamTopBeforeBottom: !!cutsite.upstreamTopBeforeBottom,
4099
4045
  topSnipBeforeBottom: !!cutsite.topSnipBeforeBottom,
4100
- recognitionSiteRange: cutsite.recognitionSiteRange ? {
4046
+ recognitionSiteRange: {
4101
4047
  start: cutsite.recognitionSiteRange.end,
4102
4048
  end: cutsite.recognitionSiteRange.start
4103
- } : void 0,
4049
+ },
4104
4050
  forward: false
4105
4051
  });
4106
4052
  }
@@ -4112,7 +4058,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4112
4058
  let restrictionCutSite;
4113
4059
  const recognitionSiteLength = restrictionEnzyme.site.length;
4114
4060
  const originalSequence = sequence;
4115
- const originalSequenceLengthVal = sequence.length;
4061
+ const originalSequenceLength = sequence.length;
4116
4062
  if (circular) {
4117
4063
  sequence += sequence;
4118
4064
  }
@@ -4121,10 +4067,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4121
4067
  let startIndex = 0;
4122
4068
  let subSequence = sequence;
4123
4069
  while (matchIndex !== -1) {
4124
- const recognitionSiteRange = {
4125
- start: 0,
4126
- end: 0
4127
- };
4070
+ const recognitionSiteRange = {};
4128
4071
  let start;
4129
4072
  let end;
4130
4073
  let upstreamTopSnip = null;
@@ -4139,39 +4082,37 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4139
4082
  recognitionSiteRange.end = matchIndex + recognitionSiteLength - 1 + startIndex;
4140
4083
  end = recognitionSiteRange.end;
4141
4084
  if (restrictionEnzyme.cutType === 1) {
4142
- if (restrictionEnzyme.usForward != null && restrictionEnzyme.usReverse != null) {
4143
- upstreamTopSnip = recognitionSiteRange.end - restrictionEnzyme.usForward;
4144
- upstreamBottomSnip = recognitionSiteRange.end - restrictionEnzyme.usReverse;
4145
- if (upstreamTopSnip >= 0 && upstreamBottomSnip >= 0) {
4146
- fitsWithinSequence = true;
4147
- if (upstreamTopSnip < upstreamBottomSnip) {
4148
- if (start > upstreamTopSnip) {
4149
- start = upstreamTopSnip + 1;
4150
- }
4151
- upstreamTopBeforeBottom = true;
4152
- } else {
4153
- if (start > upstreamBottomSnip) {
4154
- start = upstreamBottomSnip + 1;
4155
- }
4085
+ upstreamTopSnip = recognitionSiteRange.end - restrictionEnzyme.usForward;
4086
+ upstreamBottomSnip = recognitionSiteRange.end - restrictionEnzyme.usReverse;
4087
+ if (upstreamTopSnip >= 0 && upstreamBottomSnip >= 0) {
4088
+ fitsWithinSequence = true;
4089
+ if (upstreamTopSnip < upstreamBottomSnip) {
4090
+ if (start > upstreamTopSnip) {
4091
+ start = upstreamTopSnip + 1;
4156
4092
  }
4157
- upstreamTopSnip = normalizePositionByRangeLength(
4158
- upstreamTopSnip,
4159
- originalSequenceLengthVal,
4160
- true
4161
- );
4162
- upstreamBottomSnip = normalizePositionByRangeLength(
4163
- upstreamBottomSnip,
4164
- originalSequenceLengthVal,
4165
- true
4166
- );
4093
+ upstreamTopBeforeBottom = true;
4167
4094
  } else {
4168
- upstreamTopSnip = null;
4169
- upstreamBottomSnip = null;
4095
+ if (start > upstreamBottomSnip) {
4096
+ start = upstreamBottomSnip + 1;
4097
+ }
4170
4098
  }
4099
+ upstreamTopSnip = normalizePositionByRangeLength(
4100
+ upstreamTopSnip,
4101
+ originalSequenceLength,
4102
+ true
4103
+ );
4104
+ upstreamBottomSnip = normalizePositionByRangeLength(
4105
+ upstreamBottomSnip,
4106
+ originalSequenceLength,
4107
+ true
4108
+ );
4109
+ } else {
4110
+ upstreamTopSnip = null;
4111
+ upstreamBottomSnip = null;
4171
4112
  }
4172
4113
  }
4173
- topSnipPosition = recognitionSiteRange.start + (restrictionEnzyme.topSnipOffset || 0);
4174
- bottomSnipPosition = recognitionSiteRange.start + (restrictionEnzyme.bottomSnipOffset || 0);
4114
+ topSnipPosition = recognitionSiteRange.start + restrictionEnzyme.topSnipOffset;
4115
+ bottomSnipPosition = recognitionSiteRange.start + restrictionEnzyme.bottomSnipOffset;
4175
4116
  if (bottomSnipPosition <= currentSequenceLength && topSnipPosition <= currentSequenceLength) {
4176
4117
  fitsWithinSequence = true;
4177
4118
  if (topSnipPosition > bottomSnipPosition) {
@@ -4186,70 +4127,61 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4186
4127
  }
4187
4128
  topSnipPosition = normalizePositionByRangeLength(
4188
4129
  topSnipPosition,
4189
- originalSequenceLengthVal,
4130
+ originalSequenceLength,
4190
4131
  true
4191
4132
  );
4192
4133
  bottomSnipPosition = normalizePositionByRangeLength(
4193
4134
  bottomSnipPosition,
4194
- originalSequenceLengthVal,
4135
+ originalSequenceLength,
4195
4136
  true
4196
4137
  );
4197
4138
  } else {
4198
4139
  topSnipPosition = null;
4199
4140
  bottomSnipPosition = null;
4200
4141
  }
4201
- if (fitsWithinSequence && start >= 0 && end >= 0 && start < originalSequenceLengthVal && end < currentSequenceLength) {
4142
+ if (fitsWithinSequence && start >= 0 && end >= 0 && start < originalSequenceLength && end < currentSequenceLength) {
4202
4143
  start = normalizePositionByRangeLength(
4203
4144
  start,
4204
- originalSequenceLengthVal,
4205
- false
4206
- );
4207
- end = normalizePositionByRangeLength(
4208
- end,
4209
- originalSequenceLengthVal,
4145
+ originalSequenceLength,
4210
4146
  false
4211
4147
  );
4148
+ end = normalizePositionByRangeLength(end, originalSequenceLength, false);
4212
4149
  recognitionSiteRange.start = normalizePositionByRangeLength(
4213
4150
  recognitionSiteRange.start,
4214
- originalSequenceLengthVal,
4151
+ originalSequenceLength,
4215
4152
  false
4216
4153
  );
4217
4154
  recognitionSiteRange.end = normalizePositionByRangeLength(
4218
4155
  recognitionSiteRange.end,
4219
- originalSequenceLengthVal,
4156
+ originalSequenceLength,
4220
4157
  false
4221
4158
  );
4222
4159
  let cutRange = {
4223
4160
  start: -1,
4224
4161
  end: -1
4225
4162
  };
4226
- if (topSnipPosition !== null && bottomSnipPosition !== null && topSnipPosition !== bottomSnipPosition) {
4163
+ if (topSnipPosition !== bottomSnipPosition) {
4227
4164
  cutRange = topSnipBeforeBottom ? {
4228
4165
  start: topSnipPosition,
4229
4166
  end: normalizePositionByRangeLength(
4230
4167
  bottomSnipPosition - 1,
4231
- originalSequenceLengthVal
4168
+ originalSequenceLength
4232
4169
  )
4233
4170
  } : {
4234
4171
  start: bottomSnipPosition,
4235
4172
  end: normalizePositionByRangeLength(
4236
4173
  topSnipPosition - 1,
4237
- originalSequenceLengthVal
4174
+ originalSequenceLength
4238
4175
  )
4239
4176
  };
4240
4177
  }
4241
- const overhangBps = getSequenceWithinRange(
4242
- cutRange,
4243
- originalSequence
4244
- );
4178
+ const overhangBps = getSequenceWithinRange(cutRange, originalSequence);
4245
4179
  restrictionCutSite = {
4246
4180
  id: shortid(),
4247
4181
  start,
4248
4182
  end,
4249
4183
  topSnipPosition,
4250
- // Allow null
4251
4184
  bottomSnipPosition,
4252
- // Allow null
4253
4185
  topSnipBeforeBottom,
4254
4186
  overhangBps,
4255
4187
  overhangSize: overhangBps.length,
@@ -4271,19 +4203,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4271
4203
  return restrictionCutSites;
4272
4204
  }
4273
4205
  __name(cutSequence, "cutSequence");
4274
- function getCutsitesFromSequence(sequence, circular, contextEnzymes) {
4275
- const cutsites = flatMap(contextEnzymes, (enzyme) => {
4276
- return cutSequenceByRestrictionEnzyme(sequence, circular, enzyme);
4277
- });
4278
- const cutsitesByNameMap = {};
4279
- cutsites.forEach((cutsite) => {
4280
- const name = cutsite.name || "";
4281
- if (!cutsitesByNameMap[name]) {
4282
- cutsitesByNameMap[name] = [];
4206
+ function getCutsitesFromSequence(sequence, circular, restrictionEnzymes) {
4207
+ const cutsitesByName = {};
4208
+ for (let i = 0; i < restrictionEnzymes.length; i++) {
4209
+ const re = restrictionEnzymes[i];
4210
+ const cutsites = cutSequenceByRestrictionEnzyme(sequence, circular, re);
4211
+ if (cutsites.length) {
4212
+ cutsitesByName[re.name] = cutsites;
4283
4213
  }
4284
- cutsitesByNameMap[name].push(cutsite);
4285
- });
4286
- return cutsitesByNameMap;
4214
+ }
4215
+ return cutsitesByName;
4287
4216
  }
4288
4217
  __name(getCutsitesFromSequence, "getCutsitesFromSequence");
4289
4218
  function computeDigestFragments({
@@ -4301,9 +4230,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4301
4230
  const fragments = [];
4302
4231
  const overlappingEnzymes = [];
4303
4232
  const pairs = [];
4304
- const sortedCutsites = cutsites.filter(
4305
- (c) => c.topSnipPosition != null && c.bottomSnipPosition != null
4306
- );
4233
+ const sortedCutsites = cutsites.sort((a, b) => {
4234
+ return a.topSnipPosition - b.topSnipPosition;
4235
+ });
4307
4236
  if (!circular && cutsites.length) {
4308
4237
  sortedCutsites.push({
4309
4238
  id: "seqTerm_" + shortid(),
@@ -4312,8 +4241,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4312
4241
  overhangBps: "",
4313
4242
  topSnipPosition: 0,
4314
4243
  bottomSnipPosition: 0,
4315
- overhangSize: 0,
4316
- // Added to satisfy CutSite
4317
4244
  upstreamTopSnip: 0,
4318
4245
  upstreamBottomSnip: 0,
4319
4246
  upstreamTopBeforeBottom: false,
@@ -4324,34 +4251,26 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4324
4251
  },
4325
4252
  forward: true,
4326
4253
  name: "Sequence_Terminus",
4327
- type: "START_OR_END_OF_SEQ",
4328
4254
  restrictionEnzyme: {
4329
- name: "Sequence_Terminus",
4330
- site: "",
4331
- forwardRegex: "",
4332
- reverseRegex: ""
4255
+ name: "Sequence_Terminus"
4333
4256
  }
4334
4257
  });
4335
4258
  }
4336
- sortedCutsites.sort((a, b) => {
4337
- return a.topSnipPosition - b.topSnipPosition;
4338
- });
4339
4259
  sortedCutsites.forEach((cutsite1, index) => {
4340
- if (!computeDigestDisabled) {
4341
- pairs.push([
4342
- cutsite1,
4343
- sortedCutsites[index + 1] ? sortedCutsites[index + 1] : sortedCutsites[0]
4344
- ]);
4345
- }
4346
4260
  if (computePartialDigest && !computePartialDigestDisabled) {
4347
4261
  sortedCutsites.forEach((cs, index2) => {
4348
- const isAdjacent = index2 === index + 1 || index === sortedCutsites.length - 1 && index2 === 0;
4349
- if (isAdjacent) {
4262
+ if (index2 === index + 1 || index2 === 0) {
4350
4263
  return;
4351
4264
  }
4352
4265
  pairs.push([cutsite1, sortedCutsites[index2]]);
4353
4266
  });
4354
4267
  }
4268
+ if (!computeDigestDisabled) {
4269
+ pairs.push([
4270
+ cutsite1,
4271
+ sortedCutsites[index + 1] ? sortedCutsites[index + 1] : sortedCutsites[0]
4272
+ ]);
4273
+ }
4355
4274
  });
4356
4275
  pairs.forEach((r) => {
4357
4276
  let [cut1, cut2] = r;
@@ -4396,17 +4315,12 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4396
4315
  cut2.name = "Linear_Sequence_End";
4397
4316
  cut2.restrictionEnzyme.name = "Linear_Sequence_End";
4398
4317
  }
4399
- cut1 = __spreadProps(__spreadValues({}, cut1), {
4400
- isOverhangIncludedInFragmentSize: cut1.name !== "Linear_Sequence_Start" && cut1.name !== "Sequence_Terminus" && (cut1.overhangSize || 0) > 0 && !!cut1.topSnipBeforeBottom
4401
- });
4402
- cut2 = __spreadProps(__spreadValues({}, cut2), {
4403
- isOverhangIncludedInFragmentSize: cut2.name !== "Linear_Sequence_End" && cut2.name !== "Sequence_Terminus" && (cut2.overhangSize || 0) > 0 && !cut2.topSnipBeforeBottom
4404
- });
4405
4318
  const id = start + "-" + end + "-" + size + "-";
4406
4319
  const name = `${cut1.restrictionEnzyme.name} -- ${cut2.restrictionEnzyme.name} ${size} bps`;
4320
+ getRangeLength({ start, end }, sequenceLength);
4407
4321
  fragments.push({
4408
4322
  isFormedFromLinearEnd,
4409
- madeFromOneCutsite: cut1.id === cut2.id,
4323
+ madeFromOneCutsite: cut1 === cut2,
4410
4324
  start,
4411
4325
  end,
4412
4326
  size,
@@ -4447,14 +4361,12 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4447
4361
  includeOverAndUnderHangs
4448
4362
  }) {
4449
4363
  const cutsitesByName = getCutsitesFromSequence(sequence, circular, enzymes);
4450
- const digest = computeDigestFragments({
4364
+ return computeDigestFragments({
4451
4365
  includeOverAndUnderHangs,
4452
4366
  cutsites: flatMap(cutsitesByName),
4453
4367
  sequenceLength: sequence.length,
4454
4368
  circular
4455
4369
  });
4456
- digest.fragments.sort((a, b) => b.size - a.size);
4457
- return digest;
4458
4370
  }
4459
4371
  __name(getDigestFragsForSeqAndEnzymes, "getDigestFragsForSeqAndEnzymes");
4460
4372
  function cloneRegExp(re) {
@@ -6023,8 +5935,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6023
5935
  let allPossibleThreeLetterCodons = [""];
6024
5936
  for (const set of picks) {
6025
5937
  const next = [];
6026
- for (const prefix of allPossibleThreeLetterCodons)
6027
- for (const b of set) next.push(prefix + b);
5938
+ for (const prefix of allPossibleThreeLetterCodons) for (const b of set) next.push(prefix + b);
6028
5939
  allPossibleThreeLetterCodons = next;
6029
5940
  }
6030
5941
  let foundAminoAcid = null;
@@ -6070,13 +5981,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6070
5981
  if (aa) {
6071
5982
  return aa;
6072
5983
  }
6073
- const letter = (
6074
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6075
- degenerateDnaToAminoAcidMap[
6076
- sequenceString.replace("x", "n")
6077
- //replace x's with n's as those are equivalent dna chars
6078
- ] || "x"
6079
- );
5984
+ const letter = degenerateDnaToAminoAcidMap[
5985
+ sequenceString.replace("x", "n")
5986
+ //replace x's with n's as those are equivalent dna chars
5987
+ ] || "x";
6080
5988
  return proteinAlphabet[letter.toUpperCase()];
6081
5989
  }
6082
5990
  __name(getAminoAcidFromSequenceTriplet, "getAminoAcidFromSequenceTriplet");
@@ -6290,14 +6198,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6290
6198
  name,
6291
6199
  isProtein,
6292
6200
  isRna,
6293
- isMixedRnaAndDna
6201
+ isMixedRnaAndDna,
6202
+ getAcceptedInsertChars
6294
6203
  } = {}) {
6295
- const acceptedChars = getAcceptedChars({
6204
+ const sequenceTypeInfo = {
6296
6205
  isOligo,
6297
6206
  isProtein,
6298
6207
  isRna,
6299
6208
  isMixedRnaAndDna
6300
- });
6209
+ };
6210
+ const acceptedChars = isFunction(getAcceptedInsertChars) ? getAcceptedInsertChars(sequenceTypeInfo) : getAcceptedChars(sequenceTypeInfo);
6301
6211
  const replaceChars = getReplaceChars({
6302
6212
  isOligo,
6303
6213
  isProtein,
@@ -6473,25 +6383,25 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6473
6383
  circular,
6474
6384
  name
6475
6385
  }) {
6476
- location.start = parseInt(String(location.start), 10);
6477
- location.end = parseInt(String(location.end), 10);
6386
+ location.start = parseInt(location.start, 10);
6387
+ location.end = parseInt(location.end, 10);
6478
6388
  if (convertAnnotationsFromAAIndices) {
6479
6389
  location.start = location.start * 3;
6480
6390
  location.end = location.end * 3 + 2;
6481
6391
  }
6482
- if (size !== void 0 && (location.start < 0 || location.start > size - 1)) {
6392
+ if (location.start < 0 || !(location.start <= size - 1) || location.start > size - 1) {
6483
6393
  messages.push(
6484
6394
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
6485
6395
  );
6486
6396
  location.start = Math.max(0, size - (isProtein ? 3 : 1));
6487
6397
  }
6488
- if (size !== void 0 && (location.end < 0 || location.end > size - 1)) {
6398
+ if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
6489
6399
  messages.push(
6490
6400
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
6491
6401
  );
6492
6402
  location.end = Math.max(0, size - 1);
6493
6403
  }
6494
- if (size !== void 0 && location.start > location.end && circular === false) {
6404
+ if (location.start > location.end && circular === false) {
6495
6405
  messages.push(
6496
6406
  "Invalid circular annotation detected for " + name + ". end set to 1"
6497
6407
  );
@@ -6500,30 +6410,21 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6500
6410
  }
6501
6411
  __name(coerceLocation, "coerceLocation");
6502
6412
  function getDegenerateDnaStringFromAAString(aaString) {
6503
- return aaString.split("").map(
6504
- (char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn"
6505
- ).join("");
6413
+ return aaString.split("").map((char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn").join("");
6506
6414
  }
6507
6415
  __name(getDegenerateDnaStringFromAAString, "getDegenerateDnaStringFromAAString");
6508
- function getAminoAcidStringFromSequenceString(sequenceString, options = {}) {
6509
- const { doNotExcludeAsterisk } = options;
6416
+ function getAminoAcidStringFromSequenceString(sequenceString, { doNotExcludeAsterisk } = {}) {
6510
6417
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
6511
6418
  sequenceString,
6512
- true,
6513
- null,
6514
- false
6419
+ true
6515
6420
  );
6516
6421
  const aaArray = [];
6517
6422
  let aaString = "";
6518
6423
  aminoAcidsPerBase.forEach((aa, index) => {
6519
- var _a;
6520
6424
  if (!aa.fullCodon) {
6521
6425
  return;
6522
6426
  }
6523
- if (!doNotExcludeAsterisk && index >= aminoAcidsPerBase.length - 3 && ((_a = aa.aminoAcid) == null ? void 0 : _a.value) === "*") {
6524
- return;
6525
- }
6526
- if (aa.aminoAcidIndex === null || !aa.aminoAcid) {
6427
+ if (!doNotExcludeAsterisk && index >= aminoAcidsPerBase.length - 3 && aa.aminoAcid.value === "*") {
6527
6428
  return;
6528
6429
  }
6529
6430
  aaArray[aa.aminoAcidIndex] = aa.aminoAcid.value;
@@ -6543,6 +6444,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6543
6444
  doNotProvideIdsForAnnotations,
6544
6445
  noCdsTranslations,
6545
6446
  convertAnnotationsFromAAIndices,
6447
+ getAcceptedInsertChars,
6546
6448
  topLevelSeqData
6547
6449
  } = options;
6548
6450
  let seqData = cloneDeep(pSeqData);
@@ -6550,7 +6452,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6550
6452
  messages: []
6551
6453
  };
6552
6454
  if (!seqData) {
6553
- seqData = { sequence: "" };
6455
+ seqData = {};
6554
6456
  }
6555
6457
  if (!seqData.sequence) {
6556
6458
  seqData.sequence = "";
@@ -6574,13 +6476,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6574
6476
  if (!doNotRemoveInvalidChars) {
6575
6477
  if (seqData.isProtein) {
6576
6478
  const [newSeq] = filterSequenceString(seqData.proteinSequence, __spreadProps(__spreadValues({}, topLevelSeqData || seqData), {
6577
- isProtein: true
6479
+ isProtein: true,
6480
+ getAcceptedInsertChars
6578
6481
  }));
6579
6482
  seqData.proteinSequence = newSeq;
6580
6483
  } else {
6581
- const [newSeq] = filterSequenceString(seqData.sequence, __spreadValues({
6484
+ const [newSeq] = filterSequenceString(seqData.sequence, __spreadProps(__spreadValues({
6582
6485
  additionalValidChars
6583
- }, topLevelSeqData || seqData));
6486
+ }, topLevelSeqData || seqData), {
6487
+ getAcceptedInsertChars
6488
+ }));
6584
6489
  seqData.sequence = newSeq;
6585
6490
  }
6586
6491
  }
@@ -6613,27 +6518,25 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6613
6518
  const featureTypes = getFeatureTypes();
6614
6519
  annotationTypes.forEach((annotationType) => {
6615
6520
  if (!Array.isArray(seqData[annotationType])) {
6616
- if (seqData[annotationType] && typeof seqData[annotationType] === "object") {
6617
- seqData[annotationType] = Object.keys(
6618
- seqData[annotationType]
6619
- ).map((key) => {
6620
- return seqData[annotationType][key];
6621
- });
6521
+ if (typeof seqData[annotationType] === "object") {
6522
+ seqData[annotationType] = Object.keys(seqData[annotationType]).map(
6523
+ (key) => {
6524
+ return seqData[annotationType][key];
6525
+ }
6526
+ );
6622
6527
  } else {
6623
6528
  seqData[annotationType] = [];
6624
6529
  }
6625
6530
  }
6626
- seqData[annotationType] = seqData[annotationType].filter(
6627
- (annotation) => {
6628
- return tidyUpAnnotation(annotation, __spreadProps(__spreadValues({}, options), {
6629
- featureTypes,
6630
- sequenceData: seqData,
6631
- convertAnnotationsFromAAIndices,
6632
- mutative: true,
6633
- annotationType
6634
- }));
6635
- }
6636
- );
6531
+ seqData[annotationType] = seqData[annotationType].filter((annotation) => {
6532
+ return tidyUpAnnotation(annotation, __spreadProps(__spreadValues({}, options), {
6533
+ featureTypes,
6534
+ sequenceData: seqData,
6535
+ convertAnnotationsFromAAIndices,
6536
+ mutative: true,
6537
+ annotationType
6538
+ }));
6539
+ });
6637
6540
  });
6638
6541
  if (!noTranslationData) {
6639
6542
  seqData.translations = flatMap(seqData.translations, (translation) => {
@@ -6641,7 +6544,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6641
6544
  if (noCdsTranslations && translation.translationType === "CDS Feature") {
6642
6545
  return [];
6643
6546
  }
6644
- const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a["codon_start"]) == null ? void 0 : _b[0]) - 1 || 0;
6547
+ const codonStart = ((_b = (_a = translation == null ? void 0 : translation.notes) == null ? void 0 : _a.codon_start) == null ? void 0 : _b[0]) - 1 || 0;
6645
6548
  const expandedRange = expandOrContractRangeByLength(
6646
6549
  translation,
6647
6550
  -codonStart,
@@ -6651,9 +6554,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6651
6554
  if (!expandedRange.aminoAcids && !seqData.noSequence) {
6652
6555
  expandedRange.aminoAcids = getAminoAcidDataForEachBaseOfDna(
6653
6556
  seqData.sequence,
6654
- expandedRange.forward || false,
6655
- expandedRange,
6656
- false
6557
+ expandedRange.forward,
6558
+ expandedRange
6657
6559
  );
6658
6560
  }
6659
6561
  return expandedRange;
@@ -6661,22 +6563,19 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6661
6563
  }
6662
6564
  if (annotationsAsObjects) {
6663
6565
  annotationTypes.forEach((name) => {
6664
- seqData[name] = seqData[name].reduce(
6665
- (acc, item) => {
6666
- let itemId;
6667
- if (item.id || item.id === 0) {
6668
- itemId = item.id;
6669
- } else {
6670
- itemId = shortid();
6671
- if (!doNotProvideIdsForAnnotations) {
6672
- item.id = itemId;
6673
- }
6566
+ seqData[name] = seqData[name].reduce((acc, item) => {
6567
+ let itemId;
6568
+ if (item.id || item.id === 0) {
6569
+ itemId = item.id;
6570
+ } else {
6571
+ itemId = shortid();
6572
+ if (!doNotProvideIdsForAnnotations) {
6573
+ item.id = itemId;
6674
6574
  }
6675
- acc[itemId] = item;
6676
- return acc;
6677
- },
6678
- {}
6679
- );
6575
+ }
6576
+ acc[itemId] = item;
6577
+ return acc;
6578
+ }, {});
6680
6579
  });
6681
6580
  }
6682
6581
  if (logMessages && response.messages.length > 0) {
@@ -6686,17 +6585,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6686
6585
  }
6687
6586
  __name(tidyUpSequenceData, "tidyUpSequenceData");
6688
6587
  const getDiffFromSeqs = /* @__PURE__ */ __name((oldData, newData, { ignoreKeys = [] } = {}) => {
6689
- const cleanedOldData = tidyUpSequenceData(oldData, {
6588
+ oldData = tidyUpSequenceData(oldData, {
6690
6589
  annotationsAsObjects: true,
6691
6590
  noTranslationData: true,
6692
6591
  doNotRemoveInvalidChars: true
6693
6592
  });
6694
- const cleanedNewData = tidyUpSequenceData(newData, {
6593
+ newData = tidyUpSequenceData(newData, {
6695
6594
  annotationsAsObjects: true,
6696
6595
  noTranslationData: true,
6697
6596
  doNotRemoveInvalidChars: true
6698
6597
  });
6699
- [cleanedOldData, cleanedNewData].forEach((d) => {
6598
+ [oldData, newData].forEach((d) => {
6700
6599
  [
6701
6600
  "cutsites",
6702
6601
  "orfs",
@@ -6719,26 +6618,27 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6719
6618
  });
6720
6619
  }
6721
6620
  });
6722
- return diff(cleanedOldData, cleanedNewData);
6621
+ return diff(oldData, newData);
6723
6622
  }, "getDiffFromSeqs");
6724
- const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diffData, { ignoreKeys = [] } = {}) => {
6623
+ const patchSeqWithDiff = /* @__PURE__ */ __name((oldData, diff2, { ignoreKeys = [] } = {}) => {
6725
6624
  ignoreKeys.forEach((k) => {
6726
- delete diffData[k];
6727
- });
6728
- const tidyOld = tidyUpSequenceData(cloneDeep(oldData), {
6729
- annotationsAsObjects: true,
6730
- doNotRemoveInvalidChars: true
6625
+ delete diff2[k];
6731
6626
  });
6732
- return patch(tidyOld, diffData);
6627
+ return patch(
6628
+ tidyUpSequenceData(cloneDeep(oldData), {
6629
+ annotationsAsObjects: true,
6630
+ doNotRemoveInvalidChars: true
6631
+ }),
6632
+ diff2
6633
+ );
6733
6634
  }, "patchSeqWithDiff");
6734
- const reverseSeqDiff = /* @__PURE__ */ __name((diffData) => {
6735
- return reverse(diffData);
6635
+ const reverseSeqDiff = /* @__PURE__ */ __name((diff2) => {
6636
+ return reverse(diff2);
6736
6637
  }, "reverseSeqDiff");
6737
6638
  function getAllInsertionsInSeqReads(seqReads) {
6738
6639
  const allInsertionsInSeqReads = [];
6739
6640
  seqReads.forEach((seqRead) => {
6740
6641
  const splitSeqRead = seqRead.cigar.match(/([0-9]*[MDI])/g);
6741
- if (!splitSeqRead) return;
6742
6642
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
6743
6643
  if (splitSeqRead[componentI].slice(-1) === "I") {
6744
6644
  let bpPosOfInsertion = seqRead.pos;
@@ -6782,19 +6682,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6782
6682
  return sortedInsertions;
6783
6683
  }
6784
6684
  __name(getAllInsertionsInSeqReads, "getAllInsertionsInSeqReads");
6785
- function annotateSingleSeq({
6786
- fullSeq,
6787
- searchSeq
6788
- }) {
6685
+ function annotateSingleSeq({ fullSeq, searchSeq }) {
6789
6686
  const fullSeqId = fullSeq.id || "fullSeqId";
6790
6687
  const searchSeqId = searchSeq.id || "searchSeqId";
6791
6688
  const results = autoAnnotate({
6792
6689
  seqsToAnnotateById: {
6793
- [fullSeqId]: {
6794
- sequence: fullSeq.sequence,
6795
- circular: fullSeq.circular,
6796
- annotations: fullSeq.features || []
6797
- }
6690
+ [fullSeqId]: __spreadProps(__spreadValues({}, fullSeq), {
6691
+ id: fullSeqId
6692
+ })
6798
6693
  },
6799
6694
  annotationsToCheckById: {
6800
6695
  [searchSeqId]: __spreadProps(__spreadValues({}, searchSeq), {
@@ -6844,9 +6739,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6844
6739
  z: "sar"
6845
6740
  };
6846
6741
  function getDegenerateRnaStringFromAAString(aaString) {
6847
- return aaString.split("").map(
6848
- (char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn"
6849
- ).join("");
6742
+ return aaString.split("").map((char) => aminoAcidToDegenerateRnaMap[char.toLowerCase()] || "nnn").join("");
6850
6743
  }
6851
6744
  __name(getDegenerateRnaStringFromAAString, "getDegenerateRnaStringFromAAString");
6852
6745
  function getVirtualDigest({
@@ -6861,7 +6754,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6861
6754
  const overlappingEnzymes = [];
6862
6755
  const pairs = [];
6863
6756
  const sortedCutsites = cutsites.sort((a, b) => {
6864
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
6757
+ return a.topSnipPosition - b.topSnipPosition;
6865
6758
  });
6866
6759
  sortedCutsites.forEach((cutsite1, index) => {
6867
6760
  if (computePartialDigest && !computePartialDigestDisabled) {
@@ -6878,11 +6771,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6878
6771
  });
6879
6772
  pairs.forEach(([cut1, cut2]) => {
6880
6773
  const start = normalizePositionByRangeLength(
6881
- cut1.topSnipPosition || 0,
6774
+ cut1.topSnipPosition,
6882
6775
  sequenceLength
6883
6776
  );
6884
6777
  const end = normalizePositionByRangeLength(
6885
- (cut2.topSnipPosition || 0) - 1,
6778
+ cut2.topSnipPosition - 1,
6886
6779
  sequenceLength
6887
6780
  );
6888
6781
  if (!isCircular && start > end) {
@@ -6896,7 +6789,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6896
6789
  name: "End Of Seq"
6897
6790
  }
6898
6791
  }
6899
- // Cast to CutSite as it's a mock
6900
6792
  };
6901
6793
  const frag2 = {
6902
6794
  start: 0,
@@ -6907,7 +6799,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6907
6799
  name: "Start Of Seq"
6908
6800
  }
6909
6801
  },
6910
- // Cast
6911
6802
  cut2
6912
6803
  };
6913
6804
  fragments.push(addSizeIdName(frag1, sequenceLength));
@@ -7010,18 +6901,27 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7010
6901
  return matches;
7011
6902
  }
7012
6903
  __name(findApproxMatches, "findApproxMatches");
6904
+ var spliceString$1;
6905
+ var hasRequiredSpliceString;
6906
+ function requireSpliceString() {
6907
+ if (hasRequiredSpliceString) return spliceString$1;
6908
+ hasRequiredSpliceString = 1;
6909
+ spliceString$1 = /* @__PURE__ */ __name(function spliceSlice(str, index, count, add) {
6910
+ return str.slice(0, index) + (add || "") + str.slice(index + count);
6911
+ }, "spliceSlice");
6912
+ return spliceString$1;
6913
+ }
6914
+ __name(requireSpliceString, "requireSpliceString");
6915
+ var spliceStringExports = requireSpliceString();
6916
+ const spliceString = /* @__PURE__ */ getDefaultExportFromCjs(spliceStringExports);
7013
6917
  function adjustBpsToReplaceOrInsert(bpString, insertString = "", caretPositionOrRange) {
7014
6918
  let stringToReturn = bpString;
7015
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange && caretPositionOrRange.start > -1) {
6919
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7016
6920
  if (getRangeLength(caretPositionOrRange, bpString.length) === bpString.length) {
7017
6921
  return insertString;
7018
6922
  }
7019
6923
  const ranges = splitRangeIntoTwoPartsIfItIsCircular(
7020
- invertRange(
7021
- caretPositionOrRange,
7022
- bpString.length
7023
- ),
7024
- bpString.length
6924
+ invertRange(caretPositionOrRange, bpString.length)
7025
6925
  );
7026
6926
  stringToReturn = "";
7027
6927
  ranges.forEach((range, index) => {
@@ -7047,16 +6947,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7047
6947
  return stringToReturn;
7048
6948
  }
7049
6949
  __name(adjustBpsToReplaceOrInsert, "adjustBpsToReplaceOrInsert");
7050
- const spliceString = /* @__PURE__ */ __name((str, index, count, add) => {
7051
- let i = index;
7052
- if (i < 0) {
7053
- i = str.length + i;
7054
- if (i < 0) {
7055
- i = 0;
7056
- }
7057
- }
7058
- return str.slice(0, i) + (add || "") + str.slice(i + count);
7059
- }, "spliceString");
7060
6950
  function calculatePercentGC(bps) {
7061
6951
  return (bps.match(/[cg]/gi) || []).length / bps.length * 100 || 0;
7062
6952
  }
@@ -7082,17 +6972,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7082
6972
  * monovalentCationConc - THe monovalent salt concentration. Defaults to 50e-3M.
7083
6973
  * return - Temperature for the given sequence, in Celsius.
7084
6974
  */
7085
- calculateTemperature: /* @__PURE__ */ __name(function(_sequence, {
7086
- type,
7087
- A,
7088
- R,
7089
- primerConc,
7090
- monovalentCationConc
7091
- } = {}) {
6975
+ calculateTemperature: /* @__PURE__ */ __name(function(_sequence, { type, A, R, primerConc, monovalentCationConc } = {}) {
7092
6976
  const sequence = (_sequence || "").toLowerCase();
7093
6977
  if (typeof type === "undefined") {
7094
6978
  type = this.TABLE_BRESLAUER;
7095
- } else if (type !== this.TABLE_BRESLAUER && type !== this.TABLE_UNIFIED && type !== this.TABLE_SUGIMOTO) {
6979
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
7096
6980
  throw new Error("Invalid table type!");
7097
6981
  }
7098
6982
  if (!A) {
@@ -7108,14 +6992,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7108
6992
  monovalentCationConc = this.monovalentCationConc;
7109
6993
  }
7110
6994
  const sequenceLength = sequence.length;
7111
- if (sequenceLength === 0) {
6995
+ if (sequenceLength == 0) {
7112
6996
  return 0;
7113
6997
  }
7114
6998
  const deltaHTable = this.getDeltaHTable(type);
7115
6999
  const deltaSTable = this.getDeltaSTable(type);
7116
- if (!deltaHTable || !deltaSTable) {
7117
- return 0;
7118
- }
7119
7000
  const neighbors = [];
7120
7001
  neighbors.push(this.calculateReps(sequence, "aa"));
7121
7002
  neighbors.push(this.calculateNumberOfOccurrences(sequence, "at"));
@@ -7149,7 +7030,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7149
7030
  * @return {Number[]} deltaH table for given algorithm.
7150
7031
  */
7151
7032
  getDeltaHTable: /* @__PURE__ */ __name(function(type) {
7152
- if (type === this.TABLE_BRESLAUER) {
7033
+ if (type == this.TABLE_BRESLAUER) {
7153
7034
  return [
7154
7035
  9.1,
7155
7036
  8.6,
@@ -7168,7 +7049,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7168
7049
  6.5,
7169
7050
  11.1
7170
7051
  ];
7171
- } else if (type === this.TABLE_SUGIMOTO) {
7052
+ } else if (type == this.TABLE_SUGIMOTO) {
7172
7053
  return [
7173
7054
  8,
7174
7055
  5.6,
@@ -7187,7 +7068,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7187
7068
  9.4,
7188
7069
  11.9
7189
7070
  ];
7190
- } else if (type === this.TABLE_UNIFIED) {
7071
+ } else if (type == this.TABLE_UNIFIED) {
7191
7072
  return [
7192
7073
  7.9,
7193
7074
  7.2,
@@ -7210,6 +7091,39 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7210
7091
  return null;
7211
7092
  }
7212
7093
  }, "getDeltaHTable"),
7094
+ // "AA/TT": -7.9, 7.9
7095
+ // "AT/TA": -7.2, 7.2
7096
+ // "AC/TG": -8.4, 8.4
7097
+ // "AG/TC": -7.8, 7.8
7098
+ // "TT/AA": -7.9, 7.9
7099
+ // "TA/AT": -7.2, 7.2
7100
+ // "TG/AC": -8.5, 8.2
7101
+ // "TC/AG": -8.2, 8.5
7102
+ // "CC/GG": -8.0, 8.0
7103
+ // "CA/GT": -8.5, 8.5
7104
+ // "CT/GA": -7.8, 7.8
7105
+ // "CG/GC": -10.6, 10.6
7106
+ // "GG/CC": -8.0, 8.0
7107
+ // "GA/CT": -8.2, 8.2,
7108
+ // "GT/CA": -8.4, 8.4
7109
+ // "GC/CG": -9.8, 9.8
7110
+ // aa, at, ac, ag, tt, ta, tc, tg, cc, ca, ct, cg, gg, ga, gt, gc
7111
+ // "AA/TT": -22.2,22.2,
7112
+ // "AT/TA": -20.4,20.4,
7113
+ // "AC/TG": -22.4,22.4,
7114
+ // "AG/TC": -21.0,21.0,
7115
+ // "TT/AA": -22.2,22.2,
7116
+ // "TA/AT": -21.3,21.3,
7117
+ // "TC/AG": -22.2,22.2,
7118
+ // "TG/AC": -22.7,22.7,
7119
+ // "CC/GG": -19.9,19.9,
7120
+ // "CA/GT": -22.7,22.7,
7121
+ // "CT/GA": -21.0,21.0,
7122
+ // "CG/GC": -27.2,27.2,
7123
+ // "GG/CC": -19.9,19.9,
7124
+ // "GT/CA": -22.4,22.2,
7125
+ // "GA/CT": -22.2,22.4,
7126
+ // "GC/CG": -24.4,24.4
7213
7127
  /**
7214
7128
  * @private
7215
7129
  * Function to return deltaS table for given algorithm.
@@ -7217,7 +7131,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7217
7131
  * @return {Number[]} deltaS table for given algorithm.
7218
7132
  */
7219
7133
  getDeltaSTable: /* @__PURE__ */ __name(function(type) {
7220
- if (type === this.TABLE_BRESLAUER) {
7134
+ if (type == this.TABLE_BRESLAUER) {
7221
7135
  return [
7222
7136
  24,
7223
7137
  23.9,
@@ -7236,7 +7150,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7236
7150
  17.3,
7237
7151
  26.7
7238
7152
  ];
7239
- } else if (type === this.TABLE_SUGIMOTO) {
7153
+ } else if (type == this.TABLE_SUGIMOTO) {
7240
7154
  return [
7241
7155
  21.9,
7242
7156
  15.2,
@@ -7255,7 +7169,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7255
7169
  25.5,
7256
7170
  29
7257
7171
  ];
7258
- } else if (type === this.TABLE_UNIFIED) {
7172
+ } else if (type == this.TABLE_UNIFIED) {
7259
7173
  return [
7260
7174
  22.2,
7261
7175
  20.4,
@@ -7289,14 +7203,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7289
7203
  */
7290
7204
  calculateReps: /* @__PURE__ */ __name(function(sequence, target) {
7291
7205
  const sequenceLength = sequence.length;
7292
- if (sequenceLength === 0) {
7206
+ if (sequenceLength == 0) {
7293
7207
  return 0;
7294
7208
  }
7295
7209
  let numFound = 0;
7296
7210
  let seqOffset = 0;
7297
7211
  while (true) {
7298
7212
  const foundSeq = sequence.indexOf(target, seqOffset);
7299
- if (foundSeq === -1) {
7213
+ if (foundSeq == -1) {
7300
7214
  break;
7301
7215
  }
7302
7216
  seqOffset = foundSeq + 1;
@@ -7316,7 +7230,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7316
7230
  */
7317
7231
  calculateNumberOfOccurrences: /* @__PURE__ */ __name(function(sequence, target) {
7318
7232
  const sequenceLength = sequence.length;
7319
- if (sequenceLength === 0) {
7233
+ if (sequenceLength == 0) {
7320
7234
  return 0;
7321
7235
  }
7322
7236
  const numberFound = sequence.split(target).length - 1;
@@ -7351,11 +7265,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7351
7265
  __name(rotateBpsToPosition, "rotateBpsToPosition");
7352
7266
  function arrayRotate(arr, count) {
7353
7267
  count -= arr.length * Math.floor(count / arr.length);
7354
- arr.push(...arr.splice(0, count));
7268
+ arr.push.apply(arr, arr.splice(0, count));
7355
7269
  return arr;
7356
7270
  }
7357
7271
  __name(arrayRotate, "arrayRotate");
7358
- function rotateSequenceDataToPosition(sequenceData, caretPosition, options = {}) {
7272
+ function rotateSequenceDataToPosition(sequenceData, caretPosition, options) {
7359
7273
  const newSequenceData = tidyUpSequenceData(sequenceData, __spreadValues({
7360
7274
  doNotRemoveInvalidChars: true
7361
7275
  }, options));
@@ -7403,24 +7317,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7403
7317
  }, options));
7404
7318
  const newSequenceData = cloneDeep(existingSequenceData);
7405
7319
  const insertLength = sequenceDataToInsert.isProtein && sequenceDataToInsert.proteinSequence ? sequenceDataToInsert.proteinSequence.length * 3 : sequenceDataToInsert.sequence.length;
7406
- let caretPosition = typeof caretPositionOrRange === "number" ? caretPositionOrRange : caretPositionOrRange.start;
7407
- const isInsertSameLengthAsSelection = typeof caretPositionOrRange !== "number" && sequenceDataToInsert.sequence.length === getRangeLength(
7408
- caretPositionOrRange,
7409
- existingSequenceData.sequence.length
7410
- );
7411
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1 && getRangeLength(
7320
+ let caretPosition = caretPositionOrRange;
7321
+ const isInsertSameLengthAsSelection = sequenceDataToInsert.sequence.length === getRangeLength(caretPositionOrRange, existingSequenceData.sequence.length);
7322
+ if (caretPositionOrRange.start > -1 && getRangeLength(
7412
7323
  caretPositionOrRange,
7413
7324
  existingSequenceData.sequence.length
7414
7325
  ) === existingSequenceData.sequence.length) {
7415
- const emptyAnnotations = modifiableTypes.reduce(
7416
- (acc, type) => {
7417
- acc[type] = [];
7418
- return acc;
7419
- },
7420
- {}
7421
- );
7422
7326
  existingSequenceData = tidyUpSequenceData(
7423
- __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), emptyAnnotations), {
7327
+ __spreadProps(__spreadValues(__spreadValues({}, existingSequenceData), modifiableTypes.reduce((acc, type) => {
7328
+ return acc[type] = [];
7329
+ }, {})), {
7424
7330
  sequence: "",
7425
7331
  doNotRemoveInvalidChars: true,
7426
7332
  proteinSequence: "",
@@ -7430,7 +7336,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7430
7336
  );
7431
7337
  newSequenceData.chromatogramData = void 0;
7432
7338
  } else if (newSequenceData.chromatogramData && newSequenceData.chromatogramData.baseTraces) {
7433
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7339
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7434
7340
  if (caretPositionOrRange.start > caretPositionOrRange.end) {
7435
7341
  newSequenceData.chromatogramData = trimChromatogram({
7436
7342
  chromatogramData: newSequenceData.chromatogramData,
@@ -7440,16 +7346,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7440
7346
  },
7441
7347
  justBaseCalls: isInsertSameLengthAsSelection
7442
7348
  });
7443
- if (newSequenceData.chromatogramData) {
7444
- newSequenceData.chromatogramData = trimChromatogram({
7445
- chromatogramData: newSequenceData.chromatogramData,
7446
- range: {
7447
- start: 0,
7448
- end: caretPositionOrRange.end
7449
- },
7450
- justBaseCalls: isInsertSameLengthAsSelection
7451
- });
7452
- }
7349
+ newSequenceData.chromatogramData = trimChromatogram({
7350
+ chromatogramData: newSequenceData.chromatogramData,
7351
+ range: {
7352
+ start: 0,
7353
+ end: caretPositionOrRange.end
7354
+ },
7355
+ justBaseCalls: isInsertSameLengthAsSelection
7356
+ });
7453
7357
  } else {
7454
7358
  newSequenceData.chromatogramData = trimChromatogram({
7455
7359
  chromatogramData: newSequenceData.chromatogramData,
@@ -7461,10 +7365,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7461
7365
  });
7462
7366
  }
7463
7367
  }
7464
- if (sequenceDataToInsert.sequence && newSequenceData.chromatogramData) {
7368
+ if (sequenceDataToInsert.sequence) {
7465
7369
  insertIntoChromatogram({
7466
7370
  chromatogramData: newSequenceData.chromatogramData,
7467
- caretPosition: typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7371
+ caretPosition: caretPositionOrRange.start > -1 ? caretPositionOrRange.start : caretPositionOrRange,
7468
7372
  seqToInsert: sequenceDataToInsert.sequence,
7469
7373
  justBaseCalls: isInsertSameLengthAsSelection
7470
7374
  });
@@ -7477,15 +7381,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7477
7381
  );
7478
7382
  newSequenceData.size = newSequenceData.sequence.length;
7479
7383
  newSequenceData.proteinSequence = adjustBpsToReplaceOrInsert(
7480
- existingSequenceData.proteinSequence || "",
7481
- sequenceDataToInsert.proteinSequence || "",
7384
+ existingSequenceData.proteinSequence,
7385
+ sequenceDataToInsert.proteinSequence,
7482
7386
  convertDnaCaretPositionOrRangeToAA(caretPositionOrRange)
7483
7387
  );
7484
- newSequenceData.proteinSize = (newSequenceData.proteinSequence || "").length;
7388
+ newSequenceData.proteinSize = newSequenceData.proteinSequence.length;
7485
7389
  modifiableTypes.forEach((annotationType) => {
7486
7390
  let existingAnnotations = existingSequenceData[annotationType];
7487
- if (!existingAnnotations) return;
7488
- if (typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > -1) {
7391
+ if (caretPositionOrRange && caretPositionOrRange.start > -1) {
7489
7392
  const range = caretPositionOrRange;
7490
7393
  caretPosition = range.start > range.end ? 0 : range.start;
7491
7394
  existingAnnotations = adjustAnnotationsToDelete(
@@ -7495,23 +7398,22 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7495
7398
  );
7496
7399
  }
7497
7400
  newSequenceData[annotationType] = [];
7498
- const annotationsToInsert = sequenceDataToInsert[annotationType];
7499
- if (newSequenceData[annotationType]) {
7500
- newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7501
- adjustAnnotationsToInsert(
7502
- existingAnnotations,
7503
- caretPosition,
7504
- insertLength
7505
- )
7506
- );
7507
- if (annotationsToInsert) {
7508
- newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7509
- adjustAnnotationsToInsert(annotationsToInsert, 0, caretPosition)
7510
- );
7511
- }
7512
- }
7401
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7402
+ adjustAnnotationsToInsert(
7403
+ existingAnnotations,
7404
+ caretPosition,
7405
+ insertLength
7406
+ )
7407
+ );
7408
+ newSequenceData[annotationType] = newSequenceData[annotationType].concat(
7409
+ adjustAnnotationsToInsert(
7410
+ sequenceDataToInsert[annotationType],
7411
+ 0,
7412
+ caretPosition
7413
+ )
7414
+ );
7513
7415
  });
7514
- if (maintainOriginSplit && typeof caretPositionOrRange !== "number" && caretPositionOrRange.start > caretPositionOrRange.end) {
7416
+ if (maintainOriginSplit && caretPositionOrRange && caretPositionOrRange.start > caretPositionOrRange.end) {
7515
7417
  const caretPosToRotateTo = existingSequenceData.sequence.length - caretPositionOrRange.start;
7516
7418
  return rotateSequenceDataToPosition(
7517
7419
  newSequenceData,
@@ -7529,7 +7431,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7529
7431
  maxLength
7530
7432
  );
7531
7433
  const newLocations = annotation.locations && annotation.locations.map((loc) => adjustRangeToDeletionOfAnotherRange(loc, range, maxLength)).filter((range2) => !!range2);
7532
- if (!newRange) return null;
7533
7434
  if (newLocations && newLocations.length) {
7534
7435
  return __spreadValues(__spreadProps(__spreadValues({}, newRange), {
7535
7436
  start: newLocations[0].start,
@@ -7548,13 +7449,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7548
7449
  justBaseCalls
7549
7450
  }) {
7550
7451
  if (!seqToInsert.length) return;
7551
- if (chromatogramData.baseCalls) {
7552
- chromatogramData.baseCalls.splice(
7553
- caretPosition,
7554
- 0,
7555
- ...seqToInsert.split("")
7556
- );
7557
- }
7452
+ chromatogramData.baseCalls && chromatogramData.baseCalls.splice(
7453
+ caretPosition,
7454
+ 0,
7455
+ ...seqToInsert.split("")
7456
+ );
7558
7457
  if (justBaseCalls) {
7559
7458
  return chromatogramData;
7560
7459
  }
@@ -7570,20 +7469,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7570
7469
  tTrace: toPush
7571
7470
  });
7572
7471
  }
7573
- if (chromatogramData.baseTraces) {
7574
- chromatogramData.baseTraces.splice(
7575
- caretPosition,
7576
- 0,
7577
- ...baseTracesToInsert
7578
- );
7579
- }
7580
- if (chromatogramData.qualNums) {
7581
- chromatogramData.qualNums.splice(
7582
- caretPosition,
7583
- 0,
7584
- ...qualNumsToInsert
7585
- );
7586
- }
7472
+ chromatogramData.baseTraces && chromatogramData.baseTraces.splice(caretPosition, 0, ...baseTracesToInsert);
7473
+ chromatogramData.qualNums && chromatogramData.qualNums.splice(caretPosition, 0, ...qualNumsToInsert);
7587
7474
  return chromatogramData;
7588
7475
  }
7589
7476
  __name(insertIntoChromatogram, "insertIntoChromatogram");
@@ -7596,23 +7483,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7596
7483
  "baseCalls",
7597
7484
  ...justBaseCalls ? [] : ["qualNums", "baseTraces", "basePos"]
7598
7485
  ].forEach((type) => {
7599
- if (chromatogramData[type]) {
7600
- chromatogramData[type].splice(start, end - start + 1);
7601
- }
7486
+ chromatogramData[type] && chromatogramData[type].splice(start, end - start + 1);
7602
7487
  });
7603
7488
  return chromatogramData;
7604
7489
  }
7605
7490
  __name(trimChromatogram, "trimChromatogram");
7606
7491
  function deleteSequenceDataAtRange(sequenceData, range) {
7607
- return insertSequenceDataAtPositionOrRange(
7608
- { sequence: "" },
7609
- sequenceData,
7610
- range
7611
- );
7492
+ return insertSequenceDataAtPositionOrRange({}, sequenceData, range);
7612
7493
  }
7613
7494
  __name(deleteSequenceDataAtRange, "deleteSequenceDataAtRange");
7614
7495
  function doesEnzymeChopOutsideOfRecognitionSite(enzyme) {
7615
- if (enzyme.topSnipOffset && enzyme.bottomSnipOffset && (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length)) {
7496
+ if (enzyme.topSnipOffset > enzyme.site.length || enzyme.bottomSnipOffset > enzyme.site.length) {
7616
7497
  return true;
7617
7498
  } else {
7618
7499
  return false;
@@ -15244,10 +15125,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15244
15125
  defaultEnzymesByName[name] = aliasedEnzymesByName[name];
15245
15126
  });
15246
15127
  function generateAnnotations(numberOfAnnotationsToGenerate, start, end, maxLength) {
15247
- const result = [];
15128
+ const result = {};
15248
15129
  for (let i = 0; i < numberOfAnnotationsToGenerate; i++) {
15249
15130
  const annotation = generateAnnotation(start, end, maxLength);
15250
- result.push(annotation);
15131
+ result[annotation.id] = annotation;
15251
15132
  }
15252
15133
  return result;
15253
15134
  }
@@ -15275,16 +15156,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15275
15156
  numPrimers,
15276
15157
  numTranslations
15277
15158
  } = {}) {
15278
- const proteinSequence = isProtein ? generateSequence(sequenceLength, true) : "";
15279
- const sequence = !isProtein ? generateSequence(sequenceLength) : "";
15159
+ const proteinSequence = isProtein && generateSequence(sequenceLength, true);
15160
+ const sequence = !isProtein && generateSequence(sequenceLength);
15280
15161
  return {
15281
15162
  circular: isProtein ? false : Math.random() > 0.5,
15282
- name: "p-" + Math.floor(Math.random() * 100),
15163
+ name: "p-" + Math.floor(Math.random * 100),
15283
15164
  description: "",
15284
- isProtein: !!isProtein,
15165
+ isProtein,
15285
15166
  sequence,
15286
15167
  proteinSequence,
15287
- translations: isProtein ? [] : generateAnnotations(
15168
+ translations: isProtein ? void 0 : generateAnnotations(
15288
15169
  numTranslations || 5,
15289
15170
  0,
15290
15171
  sequenceLength - 1,
@@ -15296,7 +15177,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15296
15177
  sequenceLength - 1,
15297
15178
  sequenceLength / 3
15298
15179
  ),
15299
- primers: isProtein ? [] : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15180
+ primers: isProtein ? void 0 : generateAnnotations(numPrimers || 10, 0, sequenceLength - 1, 50),
15300
15181
  parts: generateAnnotations(
15301
15182
  numParts || 10,
15302
15183
  0,
@@ -15308,14 +15189,15 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15308
15189
  __name(generateSequenceData, "generateSequenceData");
15309
15190
  function generateSequence(m = 9, isProtein) {
15310
15191
  let s = "";
15311
- const r = isProtein ? "ACDEFGHIKLMNPQRSTVWY" : "gatc";
15192
+ const r = isProtein ? "" : "gatc";
15312
15193
  for (let i = 0; i < m; i++) {
15313
15194
  s += r.charAt(Math.floor(Math.random() * r.length));
15314
15195
  }
15315
15196
  return s;
15316
15197
  }
15317
15198
  __name(generateSequence, "generateSequence");
15318
- function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart = 0, isLinear) {
15199
+ function findNearestRangeOfSequenceOverlapToPosition(sequenceToSearch, overlapSequence, positionStart, isLinear) {
15200
+ if (!positionStart) positionStart = 0;
15319
15201
  if (sequenceToSearch.length < overlapSequence.length) {
15320
15202
  return null;
15321
15203
  }
@@ -15333,9 +15215,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15333
15215
  index = result.index;
15334
15216
  distance = newDistance;
15335
15217
  }
15336
- if (index === void 0) {
15337
- return null;
15338
- }
15339
15218
  return normalizeRange(
15340
15219
  {
15341
15220
  start: index,
@@ -15380,11 +15259,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15380
15259
  internalStartCodonIndices: [],
15381
15260
  frame: start % 3,
15382
15261
  forward,
15383
- // annotationTypePlural: "orfs",
15262
+ annotationTypePlural: "orfs",
15384
15263
  isOrf: true,
15385
- id: shortid(),
15386
- type: "orf",
15387
- name: "ORF"
15264
+ id: shortid()
15388
15265
  });
15389
15266
  }
15390
15267
  }
@@ -15488,10 +15365,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15488
15365
  true
15489
15366
  );
15490
15367
  } else {
15491
- searchStringToUse = convertAmbiguousStringToRegex(
15492
- searchStringToUse,
15493
- false
15494
- );
15368
+ searchStringToUse = convertAmbiguousStringToRegex(searchStringToUse);
15495
15369
  }
15496
15370
  }
15497
15371
  if (!searchStringToUse) return [];
@@ -15611,9 +15485,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15611
15485
  }
15612
15486
  __name(getCodonRangeForAASliver, "getCodonRangeForAASliver");
15613
15487
  function getComplementAminoAcidStringFromSequenceString(sequenceString) {
15614
- const aaString = getAminoAcidStringFromSequenceString(sequenceString, {
15615
- doNotExcludeAsterisk: true
15616
- });
15488
+ const aaString = getAminoAcidStringFromSequenceString(sequenceString, true);
15617
15489
  return aaString.split("").reverse().join("");
15618
15490
  }
15619
15491
  __name(getComplementAminoAcidStringFromSequenceString, "getComplementAminoAcidStringFromSequenceString");
@@ -15651,30 +15523,26 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15651
15523
  sequence: getSequenceWithinRange(range, seqDataToUse.sequence),
15652
15524
  proteinSequence: getSequenceWithinRange(
15653
15525
  convertDnaCaretPositionOrRangeToAA(range),
15654
- seqDataToUse.proteinSequence || ""
15526
+ seqDataToUse.proteinSequence
15655
15527
  )
15656
15528
  },
15657
- annotationTypes.reduce(
15658
- (acc, type) => {
15659
- if (exclude[type]) {
15660
- acc[type] = [];
15661
- return acc;
15662
- }
15663
- acc[type] = getAnnotationsBetweenRange(
15664
- seqDataToUse[type],
15665
- range,
15666
- seqDataToUse.sequence.length,
15667
- excludePartial[type]
15668
- );
15529
+ annotationTypes.reduce((acc, type) => {
15530
+ if (exclude[type]) {
15531
+ acc[type] = [];
15669
15532
  return acc;
15670
- },
15671
- {}
15672
- )
15533
+ }
15534
+ acc[type] = getAnnotationsBetweenRange(
15535
+ seqDataToUse[type],
15536
+ range,
15537
+ seqDataToUse.sequence.length,
15538
+ excludePartial[type]
15539
+ );
15540
+ return acc;
15541
+ }, {})
15673
15542
  );
15674
15543
  if (range.overlapsSelf) {
15675
15544
  const extendedSeqData = insertSequenceDataAtPositionOrRange(
15676
15545
  { sequence: seqDataToReturn.sequence },
15677
- // Wrapping in object as per assumed signature
15678
15546
  seqDataToUse,
15679
15547
  range.start
15680
15548
  );
@@ -15715,6 +15583,15 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15715
15583
  }
15716
15584
  const overlaps = getZeroedRangeOverlaps(annotation, range, maxLength).map(
15717
15585
  (overlap) => {
15586
+ const allLocations = annotation.locations;
15587
+ if (allLocations && allLocations.length) {
15588
+ const newLocations = allLocations.filter((loc) => {
15589
+ return isRangeWithinRange(loc, overlap, maxLength);
15590
+ });
15591
+ return assignIn({}, annotation, overlap, {
15592
+ locations: newLocations
15593
+ });
15594
+ }
15718
15595
  return assignIn({}, annotation, overlap);
15719
15596
  }
15720
15597
  );
@@ -15739,8 +15616,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15739
15616
  __name(getAnnotationsBetweenRange, "getAnnotationsBetweenRange");
15740
15617
  function getComplementSequenceAndAnnotations(pSeqObj, options = {}) {
15741
15618
  const seqObj = tidyUpSequenceData(
15742
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15743
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15619
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15744
15620
  options
15745
15621
  );
15746
15622
  const newSeqObj = Object.assign({}, seqObj, {
@@ -15755,7 +15631,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15755
15631
  const { topSnipOffset, bottomSnipOffset } = restrictionEnzyme;
15756
15632
  if (topSnipOffset === bottomSnipOffset) {
15757
15633
  return "blunt";
15758
- } else if (topSnipOffset !== void 0 && bottomSnipOffset !== void 0 && topSnipOffset < bottomSnipOffset) {
15634
+ } else if (topSnipOffset < bottomSnipOffset) {
15759
15635
  return "5' overhang";
15760
15636
  } else {
15761
15637
  return "3' overhang";
@@ -15789,7 +15665,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15789
15665
  leftHandSide: "",
15790
15666
  rightHandSide: ""
15791
15667
  };
15792
- if (isPositionWithinRange(position, range, sequence.length)) {
15668
+ if (isPositionWithinRange(position, range)) {
15793
15669
  result.leftHandSide = getSequenceWithinRange(
15794
15670
  {
15795
15671
  start: range.start,
@@ -15829,13 +15705,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15829
15705
  }
15830
15706
  }
15831
15707
  __name(getOverlapBetweenTwoSequences, "getOverlapBetweenTwoSequences");
15832
- function getPossiblePartsFromSequenceAndEnzymes(seqData, restrictionEnzymes) {
15833
- const enzymes = Array.isArray(restrictionEnzymes) ? restrictionEnzymes : [restrictionEnzymes];
15708
+ function getPossiblePartsFromSequenceAndEnzyme(seqData, restrictionEnzymes) {
15709
+ restrictionEnzymes = restrictionEnzymes.length ? restrictionEnzymes : [restrictionEnzymes];
15834
15710
  const bps = seqData.sequence;
15835
15711
  const seqLen = bps.length;
15836
- const circular = seqData.circular || false;
15712
+ const circular = seqData.circular;
15837
15713
  let cutsites = [];
15838
- enzymes.forEach((enzyme) => {
15714
+ restrictionEnzymes.forEach((enzyme) => {
15839
15715
  const newCutsites = cutSequenceByRestrictionEnzyme(bps, circular, enzyme);
15840
15716
  cutsites = cutsites.concat(newCutsites);
15841
15717
  });
@@ -15876,13 +15752,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15876
15752
  return parts;
15877
15753
  }
15878
15754
  }
15879
- __name(getPossiblePartsFromSequenceAndEnzymes, "getPossiblePartsFromSequenceAndEnzymes");
15755
+ __name(getPossiblePartsFromSequenceAndEnzyme, "getPossiblePartsFromSequenceAndEnzyme");
15880
15756
  function getPartBetweenEnzymesWithInclusiveOverhangs(cut1, cut2, seqLen) {
15881
15757
  const firstCutOffset = getEnzymeRelativeOffset(cut1.restrictionEnzyme);
15882
15758
  const secondCutOffset = getEnzymeRelativeOffset(cut2.restrictionEnzyme);
15883
- const start = (cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition) || 0;
15759
+ const start = cut1.topSnipBeforeBottom ? cut1.topSnipPosition : cut1.bottomSnipPosition;
15884
15760
  const end = normalizePositionByRangeLength(
15885
- (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition || 0 : cut2.topSnipPosition || 0) - 1,
15761
+ (cut2.topSnipBeforeBottom ? cut2.bottomSnipPosition : cut2.topSnipPosition) - 1,
15886
15762
  seqLen
15887
15763
  );
15888
15764
  return {
@@ -15893,20 +15769,20 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15893
15769
  firstCut: cut1,
15894
15770
  //the offset is always counting with 0 being at the top snip position
15895
15771
  firstCutOffset,
15896
- firstCutOverhang: cut1.overhangBps || "",
15897
- firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps || "" : "",
15898
- firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps || "") : "",
15772
+ firstCutOverhang: cut1.overhangBps,
15773
+ firstCutOverhangTop: firstCutOffset > 0 ? cut1.overhangBps : "",
15774
+ firstCutOverhangBottom: firstCutOffset < 0 ? getComplementSequenceString(cut1.overhangBps) : "",
15899
15775
  secondCut: cut2,
15900
15776
  //the offset is always counting with 0 being at the top snip position
15901
15777
  secondCutOffset,
15902
- secondCutOverhang: cut2.overhangBps || "",
15903
- secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps || "" : "",
15904
- secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps || "") : ""
15778
+ secondCutOverhang: cut2.overhangBps,
15779
+ secondCutOverhangTop: secondCutOffset < 0 ? cut2.overhangBps : "",
15780
+ secondCutOverhangBottom: secondCutOffset > 0 ? getComplementSequenceString(cut2.overhangBps) : ""
15905
15781
  };
15906
15782
  }
15907
15783
  __name(getPartBetweenEnzymesWithInclusiveOverhangs, "getPartBetweenEnzymesWithInclusiveOverhangs");
15908
15784
  function getEnzymeRelativeOffset(enzyme) {
15909
- return (enzyme.bottomSnipOffset || 0) - (enzyme.topSnipOffset || 0);
15785
+ return enzyme.bottomSnipOffset - enzyme.topSnipOffset;
15910
15786
  }
15911
15787
  __name(getEnzymeRelativeOffset, "getEnzymeRelativeOffset");
15912
15788
  function pairwise(list) {
@@ -15922,8 +15798,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15922
15798
  function getReverseAminoAcidStringFromSequenceString(sequenceString) {
15923
15799
  const aminoAcidsPerBase = getAminoAcidDataForEachBaseOfDna(
15924
15800
  sequenceString,
15925
- false,
15926
- null,
15927
15801
  false
15928
15802
  );
15929
15803
  const aaArray = [];
@@ -15962,8 +15836,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15962
15836
  __name(getReverseComplementAnnotation, "getReverseComplementAnnotation");
15963
15837
  function getReverseComplementSequenceAndAnnoations(pSeqObj, options = {}) {
15964
15838
  const seqObj = tidyUpSequenceData(
15965
- getSequenceDataBetweenRange(pSeqObj, options.range || null),
15966
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15839
+ getSequenceDataBetweenRange(pSeqObj, options.range),
15967
15840
  __spreadValues({ doNotRemoveInvalidChars: true }, options)
15968
15841
  );
15969
15842
  const newSeqObj = Object.assign(
@@ -15972,20 +15845,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
15972
15845
  {
15973
15846
  sequence: getReverseComplementSequenceString(seqObj.sequence)
15974
15847
  },
15975
- annotationTypes.reduce(
15976
- (acc, type) => {
15977
- if (seqObj[type]) {
15978
- acc[type] = map(seqObj[type], (annotation) => {
15979
- return getReverseComplementAnnotation(
15980
- annotation,
15981
- seqObj.sequence.length
15982
- );
15983
- });
15984
- }
15985
- return acc;
15986
- },
15987
- {}
15988
- )
15848
+ annotationTypes.reduce((acc, type) => {
15849
+ if (seqObj[type]) {
15850
+ acc[type] = map(seqObj[type], (annotation) => {
15851
+ return getReverseComplementAnnotation(
15852
+ annotation,
15853
+ seqObj.sequence.length
15854
+ );
15855
+ });
15856
+ }
15857
+ return acc;
15858
+ }, {})
15989
15859
  );
15990
15860
  return tidyUpSequenceData(newSeqObj, __spreadValues({
15991
15861
  doNotRemoveInvalidChars: true
@@ -16007,13 +15877,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16007
15877
  function guessIfSequenceIsDnaAndNotProtein(seq, options = {}) {
16008
15878
  const { threshold = 0.9, loose } = options;
16009
15879
  const dnaLetters = options.dnaLetters || loose ? [...ambiguous_dna_letters.split(""), "U"] : ["G", "A", "T", "C", "U"];
16010
- const dnaLetterMap = dnaLetters.reduce(
16011
- (acc, letter) => {
16012
- acc[letter.toUpperCase()] = true;
16013
- return acc;
16014
- },
16015
- {}
16016
- );
15880
+ const dnaLetterMap = dnaLetters.reduce((acc, letter) => {
15881
+ acc[letter.toUpperCase()] = true;
15882
+ return acc;
15883
+ }, {});
16017
15884
  let count = 0;
16018
15885
  if (!seq || !seq.length) return true;
16019
15886
  for (let index = 0; index < seq.length; index++) {
@@ -16033,17 +15900,15 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16033
15900
  const yOffsetLevelMap = {};
16034
15901
  const wrappedAnnotations = {};
16035
15902
  forEach(annotations, (annotation) => {
16036
- var _a;
16037
15903
  const containsLocations = !!(annotation.locations && annotation.locations.length);
16038
15904
  if (annotation.overlapsSelf) {
16039
15905
  if (!wrappedAnnotations[annotation.id]) {
16040
15906
  mapAnnotationToRows({
16041
- annotation: __spreadProps(__spreadValues({}, annotation), {
15907
+ annotation: {
16042
15908
  start: 0,
16043
15909
  end: sequenceLength - 1,
16044
- id: `__tempAnnRemoveMe__${annotation.id}`,
16045
- overlapsSelf: false
16046
- }),
15910
+ id: `__tempAnnRemoveMe__${annotation.id}`
15911
+ },
16047
15912
  sequenceLength,
16048
15913
  bpsPerRow,
16049
15914
  annotationsToRowsMap,
@@ -16064,7 +15929,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16064
15929
  splitForwardReverse
16065
15930
  });
16066
15931
  if (containsLocations) {
16067
- (_a = annotation.locations) == null ? void 0 : _a.forEach((location) => {
15932
+ annotation.locations.forEach((location) => {
16068
15933
  mapAnnotationToRows({
16069
15934
  annotation,
16070
15935
  sequenceLength,
@@ -16080,7 +15945,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16080
15945
  forEach(annotationsToRowsMap, (annotationsForRow, i) => {
16081
15946
  annotationsToRowsMap[i] = filter(
16082
15947
  annotationsForRow,
16083
- (ann) => !startsWith(String(ann.id), "__tempAnnRemoveMe__")
15948
+ (ann) => !startsWith(ann.id, "__tempAnnRemoveMe__")
16084
15949
  );
16085
15950
  });
16086
15951
  return annotationsToRowsMap;
@@ -16122,13 +15987,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16122
15987
  yOffset = ann.yOffset;
16123
15988
  }
16124
15989
  });
16125
- if (yOffset === void 0) {
16126
- annotationsForRow.forEach((ann) => {
16127
- if (ann.id === annotation.id) {
16128
- yOffset = ann.yOffset;
16129
- }
16130
- });
16131
- }
16132
15990
  } else {
16133
15991
  if (location) {
16134
15992
  annotationsForRow.forEach((ann) => {
@@ -16137,74 +15995,32 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16137
15995
  }
16138
15996
  });
16139
15997
  } else {
16140
- if (index > 0 && annotationsForRow.length && annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
15998
+ if (index > 0 && //second half of an annotation range
15999
+ annotationsForRow.length && //there are already annotations within the row
16000
+ annotationsForRow[annotationsForRow.length - 1].annotation === annotation) {
16141
16001
  yOffset = annotationsForRow[annotationsForRow.length - 1].yOffset;
16142
16002
  } else {
16143
- const siblingRangesOnThisRow = ranges.slice(index + 1).filter((r) => {
16144
- const rStartRow = Math.floor(r.start / bpsPerRow);
16145
- const rEndRow = Math.floor(r.end / bpsPerRow);
16146
- return rowNumber >= rStartRow && rowNumber <= rEndRow;
16147
- });
16148
- if (siblingRangesOnThisRow.length > 0) {
16149
- let foundYOffset = -1;
16150
- yOffsetsForRow.some((rangesAlreadyAddedToYOffset, levelIndex) => {
16151
- const rangeBlocked = rangesAlreadyAddedToYOffset.some(
16152
- (comparisonRange) => {
16153
- return checkIfPotentiallyCircularRangesOverlap(
16154
- range,
16155
- comparisonRange
16156
- );
16157
- }
16158
- );
16159
- if (rangeBlocked) return false;
16160
- const siblingBlocked = siblingRangesOnThisRow.some(
16161
- (siblingRange) => {
16162
- return rangesAlreadyAddedToYOffset.some((comparisonRange) => {
16163
- return checkIfPotentiallyCircularRangesOverlap(
16164
- siblingRange,
16165
- comparisonRange
16166
- );
16167
- });
16168
- }
16169
- );
16170
- if (!siblingBlocked) {
16171
- foundYOffset = levelIndex;
16172
- return true;
16173
- }
16174
- return false;
16175
- });
16176
- if (foundYOffset > -1) {
16177
- yOffset = foundYOffset;
16178
- yOffsetsForRow[foundYOffset].push(range);
16179
- } else {
16180
- yOffset = yOffsetsForRow.length;
16181
- yOffsetsForRow.push([range]);
16182
- }
16183
- } else {
16184
- yOffset = getYOffsetForPotentiallyCircularRange(
16185
- range,
16186
- yOffsetsForRow,
16187
- false
16188
- );
16189
- }
16190
- }
16191
- if (yOffset !== void 0) {
16192
- if (!yOffsetsForRow[yOffset]) yOffsetsForRow[yOffset] = [];
16193
- yOffsetsForRow[yOffset].push({
16194
- start,
16195
- end
16196
- });
16003
+ yOffset = getYOffsetForPotentiallyCircularRange(
16004
+ annotation,
16005
+ yOffsetsForRow
16006
+ );
16197
16007
  }
16008
+ if (!yOffsetsForRow[yOffset]) yOffsetsForRow[yOffset] = [];
16009
+ yOffsetsForRow[yOffset].push({
16010
+ start,
16011
+ end
16012
+ });
16198
16013
  }
16199
16014
  }
16200
- annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, annotation), {
16015
+ annotationsForRow.push(__spreadProps(__spreadValues(__spreadValues({
16201
16016
  id: annotation.id,
16202
16017
  annotation,
16203
16018
  start,
16204
16019
  end
16205
- }), containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16020
+ }, containsLocations && { containsLocations }), location && { isJoinedLocation: !!location }), {
16206
16021
  yOffset,
16207
16022
  enclosingRangeType: range.type
16023
+ //either "beginning", "end" or "beginningAndEnd"
16208
16024
  }));
16209
16025
  }
16210
16026
  });
@@ -16214,14 +16030,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16214
16030
  const clonedSeqData = cloneDeep(sequenceData);
16215
16031
  annotationTypes.forEach((annotationType) => {
16216
16032
  if (annotationType !== "cutsites") {
16217
- const annotations = clonedSeqData[annotationType];
16218
- if (annotations) {
16219
- const maxYOffset = getYOffsetsForPotentiallyCircularRanges(
16220
- annotations,
16221
- true
16222
- ).maxYOffset;
16223
- clonedSeqData[annotationType].maxYOffset = maxYOffset;
16224
- }
16033
+ const maxYOffset = getYOffsetsForPotentiallyCircularRanges(
16034
+ clonedSeqData[annotationType]
16035
+ ).maxYOffset;
16036
+ clonedSeqData[annotationType].maxYOffset = maxYOffset;
16225
16037
  }
16226
16038
  });
16227
16039
  return clonedSeqData;
@@ -16234,19 +16046,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16234
16046
  const rowMap = {};
16235
16047
  annotationTypes.forEach((type) => {
16236
16048
  rowMap[type] = mapAnnotationsToRows(
16237
- sequenceData[type] || [],
16049
+ sequenceData[type],
16238
16050
  sequenceLength,
16239
16051
  bpsPerRow,
16240
16052
  { splitForwardReverse: type === "primers" }
16241
16053
  );
16242
16054
  });
16243
16055
  for (let rowNumber = 0; rowNumber < totalRows; rowNumber++) {
16244
- const row = {
16245
- rowNumber,
16246
- start: 0,
16247
- end: 0,
16248
- sequence: ""
16249
- };
16056
+ const row = {};
16250
16057
  row.rowNumber = rowNumber;
16251
16058
  row.start = rowNumber * bpsPerRow;
16252
16059
  row.end = (rowNumber + 1) * bpsPerRow - 1 < sequenceLength ? (rowNumber + 1) * bpsPerRow - 1 : sequenceLength - 1;
@@ -16307,16 +16114,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16307
16114
  }
16308
16115
  }
16309
16116
  const refSeqWithGaps = insertGapsIntoRefSeq(refSeq.sequence, seqReads);
16310
- const seqReadsWithGaps = [{ name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }];
16117
+ const seqReadsWithGaps = [
16118
+ { name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }
16119
+ ];
16311
16120
  seqReads.forEach((seqRead) => {
16312
16121
  const allInsertionsInSeqReads = [];
16313
16122
  seqReads.forEach((seqRead2) => {
16314
16123
  const splitSeqRead = seqRead2.cigar.match(/([0-9]*[SMDI])/g);
16315
- if (!splitSeqRead) return;
16316
16124
  let adjustedSeqReadPos2 = cloneDeep(seqRead2.pos);
16317
16125
  if (splitSeqRead[0].slice(-1) === "S") {
16318
16126
  const numOfBeginningSoftClipped = splitSeqRead[0].slice(0, -1);
16319
- adjustedSeqReadPos2 = seqRead2.pos - Number(numOfBeginningSoftClipped);
16127
+ adjustedSeqReadPos2 = seqRead2.pos - numOfBeginningSoftClipped;
16320
16128
  }
16321
16129
  for (let componentI = 0; componentI < splitSeqRead.length; componentI++) {
16322
16130
  if (splitSeqRead[componentI].slice(-1) === "I") {
@@ -16342,11 +16150,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16342
16150
  }
16343
16151
  });
16344
16152
  const splitSeqReadChunk = seqRead.cigar.match(/([0-9]*[SMDI])/g);
16345
- if (!splitSeqReadChunk) return;
16346
16153
  let adjustedSeqReadPos = cloneDeep(seqRead.pos);
16347
16154
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16348
16155
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16349
- adjustedSeqReadPos = seqRead.pos - Number(numOfBeginningSoftClipped);
16156
+ adjustedSeqReadPos = seqRead.pos - numOfBeginningSoftClipped;
16350
16157
  }
16351
16158
  let eachSeqReadWithGaps = seqRead.seq.split("");
16352
16159
  if (adjustedSeqReadPos > 0) {
@@ -16534,11 +16341,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16534
16341
  const seqReadLengthsBeforeRefSeqStart = [];
16535
16342
  seqReads.forEach((seq) => {
16536
16343
  const splitSeqReadChunk = seq.cigar.match(/([0-9]*[SMDI])/g);
16537
- if (!splitSeqReadChunk) return;
16538
16344
  let adjustedSeqReadPos = cloneDeep(seq.pos);
16539
16345
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16540
16346
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16541
- adjustedSeqReadPos = seq.pos - Number(numOfBeginningSoftClipped);
16347
+ adjustedSeqReadPos = seq.pos - numOfBeginningSoftClipped;
16542
16348
  if (adjustedSeqReadPos < 0) {
16543
16349
  seqReadLengthsBeforeRefSeqStart.push(Math.abs(adjustedSeqReadPos));
16544
16350
  }
@@ -16548,14 +16354,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16548
16354
  for (let i = 1; i < seqReadsWithGaps.length; i++) {
16549
16355
  const eachSeqReadWithGaps = seqReadsWithGaps[i].sequence.split("");
16550
16356
  const splitSeqReadChunk = seqReads[i - 1].cigar.match(/([0-9]*[SMDI])/g);
16551
- if (!splitSeqReadChunk) continue;
16552
16357
  let adjustedSeqReadPos = cloneDeep(seqReads[i - 1].pos);
16553
16358
  if (seqReadLengthsBeforeRefSeqStart.length > 0) {
16554
16359
  longestSeqReadLength = Math.max(...seqReadLengthsBeforeRefSeqStart);
16555
16360
  }
16556
16361
  if (splitSeqReadChunk[0].slice(-1) === "S") {
16557
16362
  const numOfBeginningSoftClipped = splitSeqReadChunk[0].slice(0, -1);
16558
- adjustedSeqReadPos = seqReads[i - 1].pos - Number(numOfBeginningSoftClipped);
16363
+ adjustedSeqReadPos = seqReads[i - 1].pos - numOfBeginningSoftClipped;
16559
16364
  if (adjustedSeqReadPos > 0) {
16560
16365
  if (longestSeqReadLength > 0) {
16561
16366
  eachSeqReadWithGaps.unshift("-".repeat(longestSeqReadLength + 1));
@@ -16669,11 +16474,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16669
16474
  for (let i = 0; i < seq.length; i++) {
16670
16475
  if (i === 0 || i === seq.length - 1) {
16671
16476
  if (seq[i] === "G" || seq[i] === "C") {
16672
- hi += sequenceToEnthalpyMap["initiationWithTerminalGC"];
16673
- si += sequenceToEntropyMap["initiationWithTerminalGC"];
16477
+ hi += sequenceToEnthalpyMap.initiationWithTerminalGC;
16478
+ si += sequenceToEntropyMap.initiationWithTerminalGC;
16674
16479
  } else if (seq[i] === "A" || seq[i] === "T") {
16675
- hi += sequenceToEnthalpyMap["initiationWithTerminalAT"];
16676
- si += sequenceToEntropyMap["initiationWithTerminalAT"];
16480
+ hi += sequenceToEnthalpyMap.initiationWithTerminalAT;
16481
+ si += sequenceToEntropyMap.initiationWithTerminalAT;
16677
16482
  }
16678
16483
  }
16679
16484
  if (i < seq.length - 1) {
@@ -16716,13 +16521,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16716
16521
  `${sequences.length} sequences received when 2 primers were expected`
16717
16522
  );
16718
16523
  }
16719
- const meltingTemperatures = sequences.map((seq) => {
16720
- const tm = calculateNebTm(seq, { monovalentCationConc, primerConc });
16721
- if (typeof tm !== "number") {
16722
- throw new Error(`Invalid Tm calculated for ${seq}: ${tm}`);
16723
- }
16724
- return tm;
16725
- });
16524
+ const meltingTemperatures = sequences.map(
16525
+ (seq) => calculateNebTm(seq, primerConc, { monovalentCationConc })
16526
+ );
16726
16527
  meltingTemperatures.sort((a, b) => a - b);
16727
16528
  const lowerMeltingTemp = meltingTemperatures[0];
16728
16529
  let annealingTemp;
@@ -16799,17 +16600,17 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16799
16600
  __name(isValidSequence, "isValidSequence");
16800
16601
  function calculateSantaLuciaTm(sequence) {
16801
16602
  try {
16802
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16803
- if (!isValidSequence(seq)) {
16603
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16604
+ if (!isValidSequence(sequence)) {
16804
16605
  throw new Error("Invalid sequence: contains non-DNA characters");
16805
16606
  }
16806
- if (seq.length < 2) {
16607
+ if (sequence.length < 2) {
16807
16608
  throw new Error("Sequence too short: minimum length is 2 bases");
16808
16609
  }
16809
16610
  let deltaH = 0;
16810
16611
  let deltaS = 0;
16811
- for (let i = 0; i < seq.length - 1; i++) {
16812
- const dinucleotide = seq.substring(i, i + 2);
16612
+ for (let i = 0; i < sequence.length - 1; i++) {
16613
+ const dinucleotide = sequence.substring(i, i + 2);
16813
16614
  if (dinucleotide.includes("N")) {
16814
16615
  continue;
16815
16616
  }
@@ -16819,23 +16620,23 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16819
16620
  deltaS += params.dS;
16820
16621
  }
16821
16622
  }
16822
- const firstBase = seq[0];
16823
- const lastBase = seq[seq.length - 1];
16623
+ const firstBase = sequence[0];
16624
+ const lastBase = sequence[sequence.length - 1];
16824
16625
  if (firstBase === "G" || firstBase === "C") {
16825
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16826
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16626
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16627
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16827
16628
  } else {
16828
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16829
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16629
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16630
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16830
16631
  }
16831
16632
  if (lastBase === "G" || lastBase === "C") {
16832
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16833
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16633
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16634
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16834
16635
  } else {
16835
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16836
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16636
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16637
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16837
16638
  }
16838
- const nnPairs = seq.length - 1;
16639
+ const nnPairs = sequence.length - 1;
16839
16640
  deltaS = applySaltCorrection(deltaS, nnPairs);
16840
16641
  const C = PRIMER3_PARAMS.dnaConc * 1e-9;
16841
16642
  const Tm = deltaH * 1e3 / (deltaS + PRIMER3_PARAMS.R * Math.log(C / 4));
@@ -16847,16 +16648,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16847
16648
  __name(calculateSantaLuciaTm, "calculateSantaLuciaTm");
16848
16649
  function calculateEndStability(sequence) {
16849
16650
  try {
16850
- const seq = sequence == null ? void 0 : sequence.toUpperCase().trim();
16851
- if (!isValidSequence(seq)) {
16651
+ sequence = sequence == null ? void 0 : sequence.toUpperCase().trim();
16652
+ if (!isValidSequence(sequence)) {
16852
16653
  throw new Error("Invalid sequence: contains non-DNA characters");
16853
16654
  }
16854
- if (seq.length < 5) {
16655
+ if (sequence.length < 5) {
16855
16656
  throw new Error(
16856
16657
  "Sequence too short: minimum length is 5 bases for end stability calculation"
16857
16658
  );
16858
16659
  }
16859
- const last5Bases = seq.substring(seq.length - 5);
16660
+ const last5Bases = sequence.substring(sequence.length - 5);
16860
16661
  let deltaH = 0;
16861
16662
  let deltaS = 0;
16862
16663
  for (let i = 0; i < 4; i++) {
@@ -16873,18 +16674,18 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16873
16674
  const firstBase = last5Bases[0];
16874
16675
  const lastBase = last5Bases[last5Bases.length - 1];
16875
16676
  if (firstBase === "G" || firstBase === "C") {
16876
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16877
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16677
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16678
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16878
16679
  } else {
16879
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16880
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16680
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16681
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16881
16682
  }
16882
16683
  if (lastBase === "G" || lastBase === "C") {
16883
- deltaH += SANTA_LUCIA_INIT["GC"].dH;
16884
- deltaS += SANTA_LUCIA_INIT["GC"].dS;
16684
+ deltaH += SANTA_LUCIA_INIT.GC.dH;
16685
+ deltaS += SANTA_LUCIA_INIT.GC.dS;
16885
16686
  } else {
16886
- deltaH += SANTA_LUCIA_INIT["AT"].dH;
16887
- deltaS += SANTA_LUCIA_INIT["AT"].dS;
16687
+ deltaH += SANTA_LUCIA_INIT.AT.dH;
16688
+ deltaS += SANTA_LUCIA_INIT.AT.dS;
16888
16689
  }
16889
16690
  const T = 310.15;
16890
16691
  const deltaG = deltaH - T * deltaS / 1e3;
@@ -16899,40 +16700,24 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16899
16700
  const pairs = [];
16900
16701
  if (!cutsites.length) return [];
16901
16702
  let sortedCutsites = cutsites.sort((a, b) => {
16902
- return (a.topSnipPosition || 0) - (b.topSnipPosition || 0);
16703
+ return a.topSnipPosition - b.topSnipPosition;
16903
16704
  });
16904
16705
  if (!circular) {
16905
16706
  sortedCutsites = [
16906
16707
  {
16907
- start: 0,
16908
- end: 0,
16909
16708
  topSnipPosition: 0,
16910
16709
  bottomSnipPosition: 0,
16911
16710
  overhangSize: 0,
16912
16711
  type: "START_OR_END_OF_SEQ",
16913
- name: "START_OF_SEQ",
16914
- restrictionEnzyme: {
16915
- name: "START_OF_SEQ",
16916
- site: "",
16917
- forwardRegex: "",
16918
- reverseRegex: ""
16919
- }
16712
+ name: "START_OF_SEQ"
16920
16713
  },
16921
16714
  ...sortedCutsites,
16922
16715
  {
16923
- start: sequenceLength,
16924
- end: sequenceLength,
16925
16716
  topSnipPosition: sequenceLength,
16926
16717
  bottomSnipPosition: sequenceLength,
16927
16718
  overhangSize: 0,
16928
16719
  type: "START_OR_END_OF_SEQ",
16929
- name: "END_OF_SEQ",
16930
- restrictionEnzyme: {
16931
- name: "END_OF_SEQ",
16932
- site: "",
16933
- forwardRegex: "",
16934
- reverseRegex: ""
16935
- }
16720
+ name: "END_OF_SEQ"
16936
16721
  }
16937
16722
  ];
16938
16723
  }
@@ -16955,11 +16740,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16955
16740
  });
16956
16741
  pairs.forEach(([cut1, cut2]) => {
16957
16742
  const start = normalizePositionByRangeLength(
16958
- cut1.topSnipPosition || 0,
16743
+ cut1.topSnipPosition,
16959
16744
  sequenceLength
16960
16745
  );
16961
16746
  const end = normalizePositionByRangeLength(
16962
- (cut2.topSnipPosition || 0) - 1,
16747
+ cut2.topSnipPosition - 1,
16963
16748
  sequenceLength
16964
16749
  );
16965
16750
  const fragmentRange = { start, end };
@@ -16977,9 +16762,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16977
16762
  })
16978
16763
  }, fragmentRange), {
16979
16764
  size,
16980
- id,
16981
- name: `${cut1.restrictionEnzyme.name} -- ${cut2.restrictionEnzyme.name} ${size} bps`
16982
- // Add missing name property
16765
+ id
16983
16766
  }));
16984
16767
  });
16985
16768
  fragments.filter((fragment) => {
@@ -16991,33 +16774,21 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
16991
16774
  return fragments;
16992
16775
  }
16993
16776
  __name(getDigestFragmentsForCutsites, "getDigestFragmentsForCutsites");
16994
- function getDigestFragmentsForRestrictionEnzymes(sequence, circular, contextEnzymes, options) {
16995
- const cutsitesByName = getCutsitesFromSequence(
16996
- sequence,
16997
- circular,
16998
- Array.isArray(contextEnzymes) ? contextEnzymes : [contextEnzymes]
16999
- );
17000
- const digest = computeDigestFragments(__spreadProps(__spreadValues({
17001
- cutsites: flatMap(cutsitesByName),
17002
- sequenceLength: sequence.length,
17003
- circular
17004
- }, options), {
17005
- computePartialDigest: (options == null ? void 0 : options.computePartialDigest) || (options == null ? void 0 : options.computePartialDigests)
17006
- }));
17007
- const fragments = uniqBy(digest.fragments, (fragment) => {
17008
- return `${fragment.start}-${fragment.end}-${fragment.size}`;
17009
- });
17010
- if (circular && ((options == null ? void 0 : options.computePartialDigest) || (options == null ? void 0 : options.computePartialDigests))) {
17011
- const fullLengthFragmentIndex = fragments.findIndex(
17012
- (f) => f.size === sequence.length
16777
+ function getDigestFragmentsForRestrictionEnzymes(sequence, circular, restrictionEnzymeOrEnzymes, opts) {
16778
+ const restrictionEnzymes = Array.isArray(restrictionEnzymeOrEnzymes) ? restrictionEnzymeOrEnzymes : [restrictionEnzymeOrEnzymes];
16779
+ const cutsites = flatMap(restrictionEnzymes, (restrictionEnzyme) => {
16780
+ return cutSequenceByRestrictionEnzyme(
16781
+ sequence,
16782
+ circular,
16783
+ restrictionEnzyme
17013
16784
  );
17014
- if (fullLengthFragmentIndex > -1) {
17015
- fragments.splice(fullLengthFragmentIndex, 1);
17016
- }
17017
- }
17018
- return fragments.sort((a, b) => {
17019
- return a.start - b.start || b.size - a.size;
17020
16785
  });
16786
+ return getDigestFragmentsForCutsites(
16787
+ sequence.length,
16788
+ circular,
16789
+ cutsites,
16790
+ opts
16791
+ );
17021
16792
  }
17022
16793
  __name(getDigestFragmentsForRestrictionEnzymes, "getDigestFragmentsForRestrictionEnzymes");
17023
16794
  function convertAACaretPositionOrRangeToDna(rangeOrCaret) {
@@ -17063,13 +16834,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
17063
16834
  }) {
17064
16835
  modifiableTypes.forEach((annotationType) => {
17065
16836
  const existingAnnotations = seqData[annotationType];
17066
- if (existingAnnotations) {
17067
- seqData[annotationType] = adjustAnnotationsToInsert(
17068
- existingAnnotations,
17069
- caretPosition,
17070
- insertLength
17071
- );
17072
- }
16837
+ seqData[annotationType] = adjustAnnotationsToInsert(
16838
+ existingAnnotations,
16839
+ caretPosition,
16840
+ insertLength
16841
+ );
17073
16842
  });
17074
16843
  }
17075
16844
  __name(shiftAnnotationsByLen, "shiftAnnotationsByLen");
@@ -17139,7 +16908,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
17139
16908
  exports2.getMergedFeatureMap = getMergedFeatureMap;
17140
16909
  exports2.getOrfsFromSequence = getOrfsFromSequence;
17141
16910
  exports2.getOverlapBetweenTwoSequences = getOverlapBetweenTwoSequences;
17142
- exports2.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzymes;
16911
+ exports2.getPossiblePartsFromSequenceAndEnzymes = getPossiblePartsFromSequenceAndEnzyme;
17143
16912
  exports2.getReverseAminoAcidStringFromSequenceString = getReverseAminoAcidStringFromSequenceString;
17144
16913
  exports2.getReverseComplementAminoAcidStringFromSequenceString = getReverseComplementAminoAcidStringFromSequenceString;
17145
16914
  exports2.getReverseComplementAnnotation = getReverseComplementAnnotation;