@teselagen/sequence-utils 0.3.7 → 0.3.9

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 (108) hide show
  1. package/README.md +89 -0
  2. package/bioData.d.ts +1 -339
  3. package/filterSequenceString.d.ts +26 -1
  4. package/index.d.ts +7 -8
  5. package/index.js +329 -413
  6. package/index.mjs +329 -413
  7. package/index.umd.js +329 -413
  8. package/package.json +1 -2
  9. package/src/addGapsToSeqReads.js +2 -2
  10. package/src/adjustAnnotationsToInsert.js +3 -3
  11. package/src/adjustBpsToReplaceOrInsert.js +3 -3
  12. package/src/adjustBpsToReplaceOrInsert.test.js +0 -1
  13. package/src/aminoAcidToDnaRna.test.js +1 -1
  14. package/src/annotateSingleSeq.js +1 -1
  15. package/src/annotateSingleSeq.test.js +1 -4
  16. package/src/autoAnnotate.js +5 -2
  17. package/src/autoAnnotate.test.js +6 -30
  18. package/src/bioData.js +1 -366
  19. package/src/calculateNebTa.js +1 -1
  20. package/src/calculateNebTm.js +1 -1
  21. package/src/calculatePercentGC.js +2 -2
  22. package/src/calculateTm.js +19 -102
  23. package/src/computeDigestFragments.js +7 -4
  24. package/src/computeDigestFragments.test.js +1 -1
  25. package/src/condensePairwiseAlignmentDifferences.js +1 -1
  26. package/src/convertAACaretPositionOrRangeToDna.js +1 -1
  27. package/src/convertDnaCaretPositionOrRangeToAA.js +1 -1
  28. package/src/cutSequenceByRestrictionEnzyme.js +3 -3
  29. package/src/cutSequenceByRestrictionEnzyme.test.js +0 -1
  30. package/src/degenerateDnaToAminoAcidMap.js +1 -1
  31. package/src/degenerateRnaToAminoAcidMap.js +1 -1
  32. package/src/deleteSequenceDataAtRange.js +1 -1
  33. package/src/deleteSequenceDataAtRange.test.js +23 -9
  34. package/src/diffUtils.js +4 -4
  35. package/src/diffUtils.test.js +2 -2
  36. package/src/doesEnzymeChopOutsideOfRecognitionSite.js +1 -1
  37. package/src/doesEnzymeChopOutsideOfRecognitionSite.test.js +0 -2
  38. package/src/featureTypesAndColors.js +5 -5
  39. package/src/featureTypesAndColors.test.js +1 -1
  40. package/src/filterSequenceString.js +111 -16
  41. package/src/filterSequenceString.test.js +62 -3
  42. package/src/findNearestRangeOfSequenceOverlapToPosition.js +1 -1
  43. package/src/findOrfsInPlasmid.js +1 -1
  44. package/src/findSequenceMatches.js +9 -10
  45. package/src/generateAnnotations.js +1 -1
  46. package/src/generateSequenceData.js +1 -1
  47. package/src/generateSequenceData.test.js +1 -1
  48. package/src/getAllInsertionsInSeqReads.js +1 -1
  49. package/src/getAminoAcidDataForEachBaseOfDna.js +2 -2
  50. package/src/getAminoAcidDataForEachBaseOfDna.test.js +0 -2
  51. package/src/getAminoAcidFromSequenceTriplet.js +1 -1
  52. package/src/getAminoAcidStringFromSequenceString.js +1 -1
  53. package/src/getCodonRangeForAASliver.js +1 -1
  54. package/src/getComplementAminoAcidStringFromSequenceString.js +2 -5
  55. package/src/getComplementSequenceAndAnnotations.js +1 -2
  56. package/src/getComplementSequenceString.js +5 -3
  57. package/src/getComplementSequenceString.test.js +6 -6
  58. package/src/getCutsiteType.js +1 -1
  59. package/src/getCutsitesFromSequence.js +1 -1
  60. package/src/getDegenerateDnaStringFromAAString.js +1 -1
  61. package/src/getDegenerateRnaStringFromAAString.js +1 -1
  62. package/src/getDigestFragmentsForCutsites.js +5 -2
  63. package/src/getDigestFragmentsForRestrictionEnzymes.js +2 -2
  64. package/src/getInsertBetweenVals.js +2 -2
  65. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.js +2 -2
  66. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.test.js +0 -2
  67. package/src/getMassOfAaString.js +4 -1
  68. package/src/getMassofAaString.test.js +9 -8
  69. package/src/getOrfsFromSequence.js +1 -2
  70. package/src/getOrfsFromSequence.test.js +1 -3
  71. package/src/getOverlapBetweenTwoSequences.js +3 -3
  72. package/src/getOverlapBetweenTwoSequences.test.js +1 -1
  73. package/src/getPossiblePartsFromSequenceAndEnzymes.js +2 -2
  74. package/src/getReverseAminoAcidStringFromSequenceString.js +1 -1
  75. package/src/getReverseComplementAminoAcidStringFromSequenceString.js +9 -6
  76. package/src/getReverseComplementAnnotation.js +1 -1
  77. package/src/getReverseComplementSequenceAndAnnotations.js +2 -3
  78. package/src/getReverseComplementSequenceString.js +1 -2
  79. package/src/getReverseSequenceString.js +1 -1
  80. package/src/getSequenceDataBetweenRange.js +7 -4
  81. package/src/getSequenceDataBetweenRange.test.js +0 -1
  82. package/src/getVirtualDigest.js +6 -3
  83. package/src/guessIfSequenceIsDnaAndNotProtein.js +2 -2
  84. package/src/index.js +79 -80
  85. package/src/index.test.js +5 -4
  86. package/src/insertGapsIntoRefSeq.js +1 -1
  87. package/src/insertSequenceDataAtPosition.test.js +4 -2
  88. package/src/insertSequenceDataAtPositionOrRange.js +5 -5
  89. package/src/insertSequenceDataAtPositionOrRange.test.js +3 -17
  90. package/src/isEnzymeType2S.js +1 -1
  91. package/src/mapAnnotationsToRows.js +3 -3
  92. package/src/mapAnnotationsToRows.test.js +1 -3
  93. package/src/prepareCircularViewData.js +5 -5
  94. package/src/prepareCircularViewData.test.js +1 -1
  95. package/src/prepareRowData.js +1 -2
  96. package/src/prepareRowData.test.js +1 -3
  97. package/src/prepareRowData_output1.json +381 -381
  98. package/src/proteinAlphabet.js +31 -26
  99. package/src/rotateBpsToPosition.js +7 -11
  100. package/src/rotateBpsToPosition.test.js +6 -6
  101. package/src/rotateSequenceDataToPosition.js +4 -4
  102. package/src/shiftAnnotationsByLen.js +2 -2
  103. package/src/tidyUpAnnotation.js +8 -7
  104. package/src/tidyUpSequenceData.js +15 -18
  105. package/filterAminoAcidSequenceString.d.ts +0 -1
  106. package/filterAminoAcidSequenceString.test.d.ts +0 -1
  107. package/src/filterAminoAcidSequenceString.js +0 -13
  108. package/src/filterAminoAcidSequenceString.test.js +0 -22
package/index.umd.js CHANGED
@@ -6001,31 +6001,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6001
6001
  })(lodash, lodash.exports);
6002
6002
  var lodashExports = lodash.exports;
6003
6003
  const protein_letters = "ACDEFGHIKLMNPQRSTVWY";
6004
+ const protein_letters_withUandX = "ACDEFGHIKLMNPQRSTVWYUX";
6004
6005
  const extended_protein_letters = "ACDEFGHIKLMNPQRSTVWYBXZJUO.*-";
6005
- const protein_letters_1to3 = {
6006
- A: "Ala",
6007
- C: "Cys",
6008
- D: "Asp",
6009
- E: "Glu",
6010
- F: "Phe",
6011
- G: "Gly",
6012
- H: "His",
6013
- I: "Ile",
6014
- K: "Lys",
6015
- L: "Leu",
6016
- M: "Met",
6017
- N: "Asn",
6018
- P: "Pro",
6019
- Q: "Gln",
6020
- R: "Arg",
6021
- S: "Ser",
6022
- T: "Thr",
6023
- V: "Val",
6024
- W: "Trp",
6025
- Y: "Tyr",
6026
- O: "Pyl",
6027
- U: "Sec"
6028
- };
6029
6006
  const ambiguous_dna_letters = "GATCRYWSMKHBVDN";
6030
6007
  const unambiguous_dna_letters = "GATC";
6031
6008
  const ambiguous_rna_letters = "GAUCRYWSMKHBVDN";
@@ -6050,135 +6027,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6050
6027
  X: "GATC",
6051
6028
  N: "GATC"
6052
6029
  };
6053
- const ambiguous_rna_values = {
6054
- ".": ".",
6055
- A: "A",
6056
- C: "C",
6057
- G: "G",
6058
- U: "U",
6059
- M: "AC",
6060
- R: "AG",
6061
- W: "AU",
6062
- S: "CG",
6063
- Y: "CU",
6064
- K: "GU",
6065
- V: "ACG",
6066
- H: "ACU",
6067
- D: "AGU",
6068
- B: "CGU",
6069
- X: "GAUC",
6070
- N: "GAUC"
6071
- };
6072
- const ambiguous_dna_complement = {
6073
- ".": ".",
6074
- A: "T",
6075
- C: "G",
6076
- G: "C",
6077
- T: "A",
6078
- M: "K",
6079
- R: "Y",
6080
- W: "W",
6081
- S: "S",
6082
- Y: "R",
6083
- K: "M",
6084
- V: "B",
6085
- H: "D",
6086
- D: "H",
6087
- B: "V",
6088
- X: "X",
6089
- N: "N"
6090
- };
6091
- const ambiguous_rna_complement = {
6092
- ".": ".",
6093
- A: "U",
6094
- C: "G",
6095
- G: "C",
6096
- U: "A",
6097
- M: "K",
6098
- R: "Y",
6099
- W: "W",
6100
- S: "S",
6101
- Y: "R",
6102
- K: "M",
6103
- V: "B",
6104
- H: "D",
6105
- D: "H",
6106
- B: "V",
6107
- X: "X",
6108
- N: "N"
6109
- };
6110
- const unambiguous_dna_weights = {
6111
- A: 331.2218,
6112
- C: 307.1971,
6113
- G: 347.2212,
6114
- T: 322.2085
6115
- };
6116
- const monoisotopic_unambiguous_dna_weights = {
6117
- A: 331.06817,
6118
- C: 307.056936,
6119
- G: 347.063084,
6120
- T: 322.056602
6121
- };
6122
- const unambiguous_rna_weights = {
6123
- A: 347.2212,
6124
- C: 323.1965,
6125
- G: 363.2206,
6126
- U: 324.1813
6127
- };
6128
- const monoisotopic_unambiguous_rna_weights = {
6129
- A: 347.063084,
6130
- C: 323.051851,
6131
- G: 363.057999,
6132
- U: 324.035867
6133
- };
6134
- const protein_weights = {
6135
- A: 89.0932,
6136
- C: 121.1582,
6137
- D: 133.1027,
6138
- E: 147.1293,
6139
- F: 165.1891,
6140
- G: 75.0666,
6141
- H: 155.1546,
6142
- I: 131.1729,
6143
- K: 146.1876,
6144
- L: 131.1729,
6145
- M: 149.2113,
6146
- N: 132.1179,
6147
- O: 255.3134,
6148
- P: 115.1305,
6149
- Q: 146.1445,
6150
- R: 174.201,
6151
- S: 105.0926,
6152
- T: 119.1192,
6153
- U: 168.0532,
6154
- V: 117.1463,
6155
- W: 204.2252,
6156
- Y: 181.1885
6157
- };
6158
- const monoisotopic_protein_weights = {
6159
- A: 89.047678,
6160
- C: 121.019749,
6161
- D: 133.037508,
6162
- E: 147.053158,
6163
- F: 165.078979,
6164
- G: 75.032028,
6165
- H: 155.069477,
6166
- I: 131.094629,
6167
- K: 146.105528,
6168
- L: 131.094629,
6169
- M: 149.051049,
6170
- N: 132.053492,
6171
- O: 255.158292,
6172
- P: 115.063329,
6173
- Q: 146.069142,
6174
- R: 174.111676,
6175
- S: 105.042593,
6176
- T: 119.058243,
6177
- U: 168.964203,
6178
- V: 117.078979,
6179
- W: 204.089878,
6180
- Y: 181.073893
6181
- };
6182
6030
  const extended_protein_values = {
6183
6031
  A: "A",
6184
6032
  B: "ND",
@@ -6213,140 +6061,18 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6213
6061
  ".": "\\.\\.",
6214
6062
  "-": "\\-"
6215
6063
  };
6216
- const atom_weights = {
6217
- H: 1.00794,
6218
- D: 2.0141,
6219
- He: 4.002602,
6220
- Li: 6.941,
6221
- Be: 9.012182,
6222
- B: 10.811,
6223
- C: 12.0107,
6224
- N: 14.0067,
6225
- O: 15.9994,
6226
- F: 18.9984032,
6227
- Ne: 20.1797,
6228
- Na: 22.98977,
6229
- Mg: 24.305,
6230
- Al: 26.981538,
6231
- Si: 28.0855,
6232
- P: 30.973761,
6233
- S: 32.065,
6234
- Cl: 35.453,
6235
- Ar: 39.948,
6236
- K: 39.0983,
6237
- Ca: 40.078,
6238
- Sc: 44.95591,
6239
- Ti: 47.867,
6240
- V: 50.9415,
6241
- Cr: 51.9961,
6242
- Mn: 54.938049,
6243
- Fe: 55.845,
6244
- Co: 58.9332,
6245
- Ni: 58.6934,
6246
- Cu: 63.546,
6247
- Zn: 65.39,
6248
- Ga: 69.723,
6249
- Ge: 72.64,
6250
- As: 74.9216,
6251
- Se: 78.96,
6252
- Br: 79.904,
6253
- Kr: 83.8,
6254
- Rb: 85.4678,
6255
- Sr: 87.62,
6256
- Y: 88.90585,
6257
- Zr: 91.224,
6258
- Nb: 92.90638,
6259
- Mo: 95.94,
6260
- Tc: 98,
6261
- Ru: 101.07,
6262
- Rh: 102.9055,
6263
- Pd: 106.42,
6264
- Ag: 107.8682,
6265
- Cd: 112.411,
6266
- In: 114.818,
6267
- Sn: 118.71,
6268
- Sb: 121.76,
6269
- Te: 127.6,
6270
- I: 126.90447,
6271
- Xe: 131.293,
6272
- Cs: 132.90545,
6273
- Ba: 137.327,
6274
- La: 138.9055,
6275
- Ce: 140.116,
6276
- Pr: 140.90765,
6277
- Nd: 144.24,
6278
- Pm: 145,
6279
- Sm: 150.36,
6280
- Eu: 151.964,
6281
- Gd: 157.25,
6282
- Tb: 158.92534,
6283
- Dy: 162.5,
6284
- Ho: 164.93032,
6285
- Er: 167.259,
6286
- Tm: 168.93421,
6287
- Yb: 173.04,
6288
- Lu: 174.967,
6289
- Hf: 178.49,
6290
- Ta: 180.9479,
6291
- W: 183.84,
6292
- Re: 186.207,
6293
- Os: 190.23,
6294
- Ir: 192.217,
6295
- Pt: 195.078,
6296
- Au: 196.96655,
6297
- Hg: 200.59,
6298
- Tl: 204.3833,
6299
- Pb: 207.2,
6300
- Bi: 208.98038,
6301
- Po: 208.98,
6302
- At: 209.99,
6303
- Rn: 222.02,
6304
- Fr: 223.02,
6305
- Ra: 226.03,
6306
- Ac: 227.03,
6307
- Th: 232.0381,
6308
- Pa: 231.03588,
6309
- U: 238.02891,
6310
- Np: 237.05,
6311
- Pu: 244.06,
6312
- Am: 243.06,
6313
- Cm: 247.07,
6314
- Bk: 247.07,
6315
- Cf: 251.08,
6316
- Es: 252.08,
6317
- Fm: 257.1,
6318
- Md: 258.1,
6319
- No: 259.1,
6320
- Lr: 262.11,
6321
- Rf: 261.11,
6322
- Db: 262.11,
6323
- Sg: 266.12,
6324
- Bh: 264.12,
6325
- Hs: 269.13,
6326
- Mt: 268.14
6327
- };
6328
6064
  const bioData = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6329
6065
  __proto__: null,
6330
- ambiguous_dna_complement,
6331
6066
  ambiguous_dna_letters,
6332
6067
  ambiguous_dna_values,
6333
- ambiguous_rna_complement,
6334
6068
  ambiguous_rna_letters,
6335
- ambiguous_rna_values,
6336
- atom_weights,
6337
6069
  extended_dna_letters,
6338
6070
  extended_protein_letters,
6339
6071
  extended_protein_values,
6340
- monoisotopic_protein_weights,
6341
- monoisotopic_unambiguous_dna_weights,
6342
- monoisotopic_unambiguous_rna_weights,
6343
6072
  protein_letters,
6344
- protein_letters_1to3,
6345
- protein_weights,
6073
+ protein_letters_withUandX,
6346
6074
  unambiguous_dna_letters,
6347
- unambiguous_dna_weights,
6348
- unambiguous_rna_letters,
6349
- unambiguous_rna_weights
6075
+ unambiguous_rna_letters
6350
6076
  }, Symbol.toStringTag, { value: "Module" }));
6351
6077
  const aminoAcidToDegenerateDnaMap = {
6352
6078
  "-": "---",
@@ -6460,8 +6186,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6460
6186
  maxRangeLength
6461
6187
  );
6462
6188
  let overlaps = [];
6463
- normalizedRangeA.forEach(function(nonCircularRangeA, iA) {
6464
- normalizedRangeB.forEach(function(nonCircularRangeB, iB) {
6189
+ normalizedRangeA.forEach(function(nonCircularRangeA) {
6190
+ normalizedRangeB.forEach(function(nonCircularRangeB) {
6465
6191
  const overlap = getOverlapOfNonCircularRanges(
6466
6192
  nonCircularRangeA,
6467
6193
  nonCircularRangeB
@@ -6473,7 +6199,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6473
6199
  });
6474
6200
  if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
6475
6201
  const joinedOverlap = {};
6476
- overlaps = lodashExports.flatMap(overlaps, (o, i) => {
6202
+ overlaps = lodashExports.flatMap(overlaps, (o) => {
6477
6203
  if (o.start === 0) {
6478
6204
  joinedOverlap.end = o.end;
6479
6205
  return [];
@@ -6571,12 +6297,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6571
6297
  });
6572
6298
  splitRangesToBeTrimmed[index] = nonCircularRangeToBeTrimmed;
6573
6299
  });
6574
- const outputSplitRanges = splitRangesToBeTrimmed.filter(function(trimmedRange) {
6575
- if (trimmedRange) {
6576
- return true;
6300
+ const outputSplitRanges = splitRangesToBeTrimmed.filter(
6301
+ function(trimmedRange) {
6302
+ if (trimmedRange) {
6303
+ return true;
6304
+ }
6305
+ return false;
6577
6306
  }
6578
- return false;
6579
- });
6307
+ );
6580
6308
  let outputTrimmedRange;
6581
6309
  if (outputSplitRanges.length < 0)
6582
6310
  ;
@@ -6675,11 +6403,19 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6675
6403
  }
6676
6404
  __name(checkIfNonCircularRangesOverlap, "checkIfNonCircularRangesOverlap");
6677
6405
  function checkIfPotentiallyCircularRangesOverlap(range, comparisonRange) {
6678
- return splitRangeIntoTwoPartsIfItIsCircular(range, Infinity).some(function(splitRange) {
6679
- return splitRangeIntoTwoPartsIfItIsCircular(comparisonRange, Infinity).some(function(splitComparisonRange) {
6680
- return checkIfNonCircularRangesOverlap(splitRange, splitComparisonRange);
6681
- });
6682
- });
6406
+ return splitRangeIntoTwoPartsIfItIsCircular(range, Infinity).some(
6407
+ function(splitRange) {
6408
+ return splitRangeIntoTwoPartsIfItIsCircular(
6409
+ comparisonRange,
6410
+ Infinity
6411
+ ).some(function(splitComparisonRange) {
6412
+ return checkIfNonCircularRangesOverlap(
6413
+ splitRange,
6414
+ splitComparisonRange
6415
+ );
6416
+ });
6417
+ }
6418
+ );
6683
6419
  }
6684
6420
  __name(checkIfPotentiallyCircularRangesOverlap, "checkIfPotentiallyCircularRangesOverlap");
6685
6421
  function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequenceLength, optionalOriginalRange) {
@@ -6688,15 +6424,19 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6688
6424
  return overlaps;
6689
6425
  } else if (overlaps.length === 2) {
6690
6426
  if (overlaps[0].start === 0 && overlaps[1].end + 1 === sequenceLength && !originalRangeLinear) {
6691
- return [{
6692
- start: overlaps[1].start,
6693
- end: overlaps[0].end
6694
- }];
6427
+ return [
6428
+ {
6429
+ start: overlaps[1].start,
6430
+ end: overlaps[0].end
6431
+ }
6432
+ ];
6695
6433
  } else if (overlaps[1].start === 0 && overlaps[0].end + 1 === sequenceLength && !originalRangeLinear) {
6696
- return [{
6697
- start: overlaps[0].start,
6698
- end: overlaps[1].end
6699
- }];
6434
+ return [
6435
+ {
6436
+ start: overlaps[0].start,
6437
+ end: overlaps[1].end
6438
+ }
6439
+ ];
6700
6440
  } else {
6701
6441
  return overlaps;
6702
6442
  }
@@ -6704,17 +6444,29 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6704
6444
  const firstOverlap = overlaps[0];
6705
6445
  const secondOverlap = overlaps[1];
6706
6446
  const thirdOverlap = overlaps[2];
6707
- let collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([firstOverlap, secondOverlap], sequenceLength, optionalOriginalRange);
6447
+ let collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6448
+ [firstOverlap, secondOverlap],
6449
+ sequenceLength,
6450
+ optionalOriginalRange
6451
+ );
6708
6452
  if (collapsedOverlaps.length === 1) {
6709
6453
  collapsedOverlaps.push(thirdOverlap);
6710
6454
  return collapsedOverlaps;
6711
6455
  } else {
6712
- collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([firstOverlap, thirdOverlap], sequenceLength, optionalOriginalRange);
6456
+ collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6457
+ [firstOverlap, thirdOverlap],
6458
+ sequenceLength,
6459
+ optionalOriginalRange
6460
+ );
6713
6461
  if (collapsedOverlaps.length === 1) {
6714
6462
  collapsedOverlaps.push(secondOverlap);
6715
6463
  return collapsedOverlaps;
6716
6464
  } else {
6717
- collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([secondOverlap, thirdOverlap], sequenceLength, optionalOriginalRange);
6465
+ collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6466
+ [secondOverlap, thirdOverlap],
6467
+ sequenceLength,
6468
+ optionalOriginalRange
6469
+ );
6718
6470
  if (collapsedOverlaps.length === 1) {
6719
6471
  collapsedOverlaps.push(firstOverlap);
6720
6472
  return collapsedOverlaps;
@@ -6821,13 +6573,23 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6821
6573
  __name(expandOrContractRangeByLength, "expandOrContractRangeByLength");
6822
6574
  function translateRange(rangeToBeAdjusted, translateBy, rangeLength) {
6823
6575
  return lodashExports.assign({}, rangeToBeAdjusted, {
6824
- start: normalizePositionByRangeLength(rangeToBeAdjusted.start + translateBy, rangeLength),
6825
- end: normalizePositionByRangeLength(rangeToBeAdjusted.end + translateBy, rangeLength)
6576
+ start: normalizePositionByRangeLength(
6577
+ rangeToBeAdjusted.start + translateBy,
6578
+ rangeLength
6579
+ ),
6580
+ end: normalizePositionByRangeLength(
6581
+ rangeToBeAdjusted.end + translateBy,
6582
+ rangeLength
6583
+ )
6826
6584
  });
6827
6585
  }
6828
6586
  __name(translateRange, "translateRange");
6829
- function flipRelativeRange(innerRange, outerRange, sequenceLength, options) {
6830
- const isFullyContained = isRangeWithinRange(innerRange, outerRange, sequenceLength);
6587
+ function flipRelativeRange(innerRange, outerRange, sequenceLength) {
6588
+ const isFullyContained = isRangeWithinRange(
6589
+ innerRange,
6590
+ outerRange,
6591
+ sequenceLength
6592
+ );
6831
6593
  if (isFullyContained) {
6832
6594
  return flipFullyContainedRange(innerRange, outerRange, sequenceLength);
6833
6595
  } else {
@@ -6835,42 +6597,92 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6835
6597
  }
6836
6598
  }
6837
6599
  __name(flipRelativeRange, "flipRelativeRange");
6838
- function flipNonFullyContainedRange(innerRange, outerRange, sequenceLength, options) {
6839
- const outerFullyContained = isRangeWithinRange(outerRange, innerRange, sequenceLength);
6600
+ function flipNonFullyContainedRange(innerRange, outerRange, sequenceLength) {
6601
+ const outerFullyContained = isRangeWithinRange(
6602
+ outerRange,
6603
+ innerRange,
6604
+ sequenceLength
6605
+ );
6840
6606
  let flippedInnerRange;
6841
6607
  if (outerFullyContained) {
6842
- const expandBy1 = getRangeLength({
6843
- start: innerRange.start,
6844
- end: outerRange.start
6845
- }, sequenceLength) - 1;
6846
- flippedInnerRange = expandOrContractRangeByLength(outerRange, expandBy1, false, sequenceLength);
6847
- const expandBy2 = getRangeLength({
6848
- end: innerRange.end,
6849
- start: outerRange.end
6850
- }, sequenceLength) - 1;
6851
- flippedInnerRange = expandOrContractRangeByLength(flippedInnerRange, expandBy2, true, sequenceLength);
6608
+ const expandBy1 = getRangeLength(
6609
+ {
6610
+ start: innerRange.start,
6611
+ end: outerRange.start
6612
+ },
6613
+ sequenceLength
6614
+ ) - 1;
6615
+ flippedInnerRange = expandOrContractRangeByLength(
6616
+ outerRange,
6617
+ expandBy1,
6618
+ false,
6619
+ sequenceLength
6620
+ );
6621
+ const expandBy2 = getRangeLength(
6622
+ {
6623
+ end: innerRange.end,
6624
+ start: outerRange.end
6625
+ },
6626
+ sequenceLength
6627
+ ) - 1;
6628
+ flippedInnerRange = expandOrContractRangeByLength(
6629
+ flippedInnerRange,
6630
+ expandBy2,
6631
+ true,
6632
+ sequenceLength
6633
+ );
6852
6634
  } else {
6853
- const overlaps = getOverlapsOfPotentiallyCircularRanges(innerRange, outerRange, sequenceLength);
6635
+ const overlaps = getOverlapsOfPotentiallyCircularRanges(
6636
+ innerRange,
6637
+ outerRange,
6638
+ sequenceLength
6639
+ );
6854
6640
  if (overlaps.length >= 1) {
6855
- let overlapExtendsForward;
6856
6641
  const firstOverlap = overlaps[0];
6857
- overlapExtendsForward = firstOverlap.start !== outerRange.start;
6858
- const flippedTruncatedInner = flipFullyContainedRange(firstOverlap, outerRange, sequenceLength);
6642
+ const overlapExtendsForward = firstOverlap.start !== outerRange.start;
6643
+ const flippedTruncatedInner = flipFullyContainedRange(
6644
+ firstOverlap,
6645
+ outerRange,
6646
+ sequenceLength
6647
+ );
6859
6648
  const lengthToExtend = getRangeLength(innerRange, sequenceLength) - getRangeLength(flippedTruncatedInner, sequenceLength);
6860
- flippedInnerRange = expandOrContractRangeByLength(flippedTruncatedInner, lengthToExtend, overlapExtendsForward, sequenceLength);
6649
+ flippedInnerRange = expandOrContractRangeByLength(
6650
+ flippedTruncatedInner,
6651
+ lengthToExtend,
6652
+ overlapExtendsForward,
6653
+ sequenceLength
6654
+ );
6861
6655
  } else {
6862
- throw new Error("This case (relative ranges that do not overlap) is unsupported! ");
6656
+ throw new Error(
6657
+ "This case (relative ranges that do not overlap) is unsupported! "
6658
+ );
6863
6659
  }
6864
6660
  }
6865
6661
  return flippedInnerRange;
6866
6662
  }
6867
6663
  __name(flipNonFullyContainedRange, "flipNonFullyContainedRange");
6868
- function flipFullyContainedRange(innerRange, outerRange, sequenceLength, options) {
6664
+ function flipFullyContainedRange(innerRange, outerRange, sequenceLength) {
6869
6665
  const translateBy = -outerRange.start;
6870
- const translatedOuterRange = translateRange(outerRange, translateBy, sequenceLength);
6871
- const translatedInnerRange = translateRange(innerRange, translateBy, sequenceLength);
6872
- const translatedFlippedInnerRange = flipNonOriginSpanningContainedRange(translatedInnerRange, translatedOuterRange, sequenceLength);
6873
- const flippedInnerRange = translateRange(translatedFlippedInnerRange, -translateBy, sequenceLength);
6666
+ const translatedOuterRange = translateRange(
6667
+ outerRange,
6668
+ translateBy,
6669
+ sequenceLength
6670
+ );
6671
+ const translatedInnerRange = translateRange(
6672
+ innerRange,
6673
+ translateBy,
6674
+ sequenceLength
6675
+ );
6676
+ const translatedFlippedInnerRange = flipNonOriginSpanningContainedRange(
6677
+ translatedInnerRange,
6678
+ translatedOuterRange,
6679
+ sequenceLength
6680
+ );
6681
+ const flippedInnerRange = translateRange(
6682
+ translatedFlippedInnerRange,
6683
+ -translateBy,
6684
+ sequenceLength
6685
+ );
6874
6686
  return flippedInnerRange;
6875
6687
  }
6876
6688
  __name(flipFullyContainedRange, "flipFullyContainedRange");
@@ -6888,7 +6700,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6888
6700
  const start = getRandomInt$1(minStart, maxEnd);
6889
6701
  let end;
6890
6702
  if (maxLength) {
6891
- end = normalizePositionByRangeLength(getRandomInt$1(start, start + maxLength), maxEnd);
6703
+ end = normalizePositionByRangeLength(
6704
+ getRandomInt$1(start, start + maxLength),
6705
+ maxEnd
6706
+ );
6892
6707
  } else {
6893
6708
  end = getRandomInt$1(minStart, maxEnd);
6894
6709
  }
@@ -6931,18 +6746,26 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6931
6746
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
6932
6747
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
6933
6748
  let yOffset = [];
6934
- const openYOffsetFound = YOffsetLevelsWithRanges.some(function(rangesAlreadyAddedToYOffset, index) {
6935
- const rangeBlocked = rangesAlreadyAddedToYOffset.some(function(comparisonRange) {
6936
- return checkIfPotentiallyCircularRangesOverlap(range, comparisonRange);
6937
- });
6938
- if (!rangeBlocked) {
6939
- yOffset = index;
6940
- if (assignYOffsetToRange)
6941
- range.yOffset = index;
6942
- rangesAlreadyAddedToYOffset.push(range);
6943
- return true;
6749
+ const openYOffsetFound = YOffsetLevelsWithRanges.some(
6750
+ function(rangesAlreadyAddedToYOffset, index) {
6751
+ const rangeBlocked = rangesAlreadyAddedToYOffset.some(
6752
+ function(comparisonRange) {
6753
+ return checkIfPotentiallyCircularRangesOverlap(
6754
+ range,
6755
+ comparisonRange
6756
+ );
6757
+ }
6758
+ );
6759
+ if (!rangeBlocked) {
6760
+ yOffset = index;
6761
+ if (assignYOffsetToRange)
6762
+ range.yOffset = index;
6763
+ rangesAlreadyAddedToYOffset.push(range);
6764
+ return true;
6765
+ }
6766
+ return false;
6944
6767
  }
6945
- });
6768
+ );
6946
6769
  if (!openYOffsetFound) {
6947
6770
  yOffset = YOffsetLevelsWithRanges.length;
6948
6771
  if (assignYOffsetToRange)
@@ -6956,7 +6779,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6956
6779
  let maxYOffset = 0;
6957
6780
  const yOffsetLevels = [];
6958
6781
  ranges.forEach(function(range) {
6959
- const yOffset = getYOffsetForPotentiallyCircularRange(range, yOffsetLevels, assignYOffsetToRange);
6782
+ const yOffset = getYOffsetForPotentiallyCircularRange(
6783
+ range,
6784
+ yOffsetLevels,
6785
+ assignYOffsetToRange
6786
+ );
6960
6787
  yOffsets.push(yOffset);
6961
6788
  if (yOffset > maxYOffset) {
6962
6789
  maxYOffset = yOffset;
@@ -6989,8 +6816,16 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6989
6816
  }
6990
6817
  __name(invertRange$1, "invertRange$1");
6991
6818
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
6992
- const distanceFromStart = getShortestDistanceBetweenTwoPositions(range.start, position, maxLength);
6993
- const distanceFromEnd = getShortestDistanceBetweenTwoPositions(range.end, position, maxLength);
6819
+ const distanceFromStart = getShortestDistanceBetweenTwoPositions(
6820
+ range.start,
6821
+ position,
6822
+ maxLength
6823
+ );
6824
+ const distanceFromEnd = getShortestDistanceBetweenTwoPositions(
6825
+ range.end,
6826
+ position,
6827
+ maxLength
6828
+ );
6994
6829
  return distanceFromStart <= distanceFromEnd;
6995
6830
  }
6996
6831
  __name(isPositionCloserToRangeStartThanRangeEnd, "isPositionCloserToRangeStartThanRangeEnd");
@@ -7021,9 +6856,15 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7021
6856
  }
7022
6857
  __name(reversePositionInRange, "reversePositionInRange");
7023
6858
  function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength) {
7024
- const trimmedSubRange = trimRangeByAnotherRange(subRange, containerRange, sequenceLength);
6859
+ const trimmedSubRange = trimRangeByAnotherRange(
6860
+ subRange,
6861
+ containerRange,
6862
+ sequenceLength
6863
+ );
7025
6864
  if (trimmedSubRange) {
7026
- throw new Error("subRange must be fully contained by containerRange! Otherwise this function does not make sense");
6865
+ throw new Error(
6866
+ "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
6867
+ );
7027
6868
  }
7028
6869
  const newSubrange = {};
7029
6870
  newSubrange.start = subRange.start - containerRange.start;
@@ -7051,12 +6892,24 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7051
6892
  }
7052
6893
  __name(modulo, "modulo");
7053
6894
  function getZeroedRangeOverlaps(annotation, selection, sequenceLength) {
7054
- const overlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(getOverlapsOfPotentiallyCircularRanges(annotation, selection, sequenceLength), sequenceLength, annotation);
6895
+ const overlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6896
+ getOverlapsOfPotentiallyCircularRanges(
6897
+ annotation,
6898
+ selection,
6899
+ sequenceLength
6900
+ ),
6901
+ sequenceLength,
6902
+ annotation
6903
+ );
7055
6904
  const zeroedOverlaps = overlaps.map((overlap) => {
7056
- return zeroSubrangeByContainerRange(overlap, {
7057
- start: selection.start,
7058
- end: normalizePositionByRangeLength(selection.start - 1, sequenceLength)
7059
- }, sequenceLength);
6905
+ return zeroSubrangeByContainerRange(
6906
+ overlap,
6907
+ {
6908
+ start: selection.start,
6909
+ end: normalizePositionByRangeLength(selection.start - 1, sequenceLength)
6910
+ },
6911
+ sequenceLength
6912
+ );
7060
6913
  });
7061
6914
  return zeroedOverlaps;
7062
6915
  }
@@ -11964,7 +11817,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
11964
11817
  hydrophobicity: 1.8,
11965
11818
  colorByFamily: "#00FFFF",
11966
11819
  color: "hsl(327.3, 100%, 69%)",
11967
- mass: 89.1
11820
+ mass: 71.0779
11968
11821
  },
11969
11822
  R: {
11970
11823
  value: "R",
@@ -11973,7 +11826,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
11973
11826
  hydrophobicity: -4.5,
11974
11827
  colorByFamily: "#FFC0CB",
11975
11828
  color: "hsl(258.1, 100%, 69%)",
11976
- mass: 174.2
11829
+ mass: 156.18568
11977
11830
  },
11978
11831
  N: {
11979
11832
  value: "N",
@@ -11982,7 +11835,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
11982
11835
  hydrophobicity: -3.5,
11983
11836
  colorByFamily: "#D3D3D3",
11984
11837
  color: "hsl(268.9, 100%, 69%)",
11985
- mass: 132.1
11838
+ mass: 114.10264
11986
11839
  },
11987
11840
  D: {
11988
11841
  value: "D",
@@ -11991,7 +11844,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
11991
11844
  hydrophobicity: -3.5,
11992
11845
  colorByFamily: "#EE82EE",
11993
11846
  color: "hsl(268.9, 100%, 69%)",
11994
- mass: 133.1
11847
+ mass: 115.0874
11995
11848
  },
11996
11849
  C: {
11997
11850
  value: "C",
@@ -12000,7 +11853,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12000
11853
  hydrophobicity: 2.5,
12001
11854
  colorByFamily: "#FFFF00",
12002
11855
  color: "hsl(335.1, 100%, 69%)",
12003
- mass: 121.2
11856
+ mass: 103.1429
12004
11857
  },
12005
11858
  E: {
12006
11859
  value: "E",
@@ -12009,7 +11862,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12009
11862
  hydrophobicity: -3.5,
12010
11863
  colorByFamily: "#EE82EE",
12011
11864
  color: "hsl(268.9, 100%, 69%)",
12012
- mass: 147.1
11865
+ mass: 129.11398
12013
11866
  },
12014
11867
  Q: {
12015
11868
  value: "Q",
@@ -12018,7 +11871,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12018
11871
  hydrophobicity: -3.5,
12019
11872
  colorByFamily: "#D3D3D3",
12020
11873
  color: "hsl(268.9, 100%, 69%)",
12021
- mass: 146.2
11874
+ mass: 128.12922
12022
11875
  },
12023
11876
  G: {
12024
11877
  value: "G",
@@ -12027,7 +11880,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12027
11880
  hydrophobicity: -0.4,
12028
11881
  colorByFamily: "#00FFFF",
12029
11882
  color: "hsl(303.1, 100%, 69%)",
12030
- mass: 75.1
11883
+ mass: 57.05132
12031
11884
  },
12032
11885
  H: {
12033
11886
  value: "H",
@@ -12036,7 +11889,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12036
11889
  hydrophobicity: -3.2,
12037
11890
  colorByFamily: "#FFC0CB",
12038
11891
  color: "hsl(272.2, 100%, 69%)",
12039
- mass: 155.2
11892
+ mass: 137.13928
12040
11893
  },
12041
11894
  I: {
12042
11895
  value: "I",
@@ -12045,7 +11898,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12045
11898
  hydrophobicity: 4.5,
12046
11899
  colorByFamily: "#00FFFF",
12047
11900
  color: "hsl(356.9, 100%, 69%)",
12048
- mass: 131.2
11901
+ mass: 113.15764
12049
11902
  },
12050
11903
  L: {
12051
11904
  value: "L",
@@ -12054,7 +11907,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12054
11907
  hydrophobicity: 3.8,
12055
11908
  colorByFamily: "#00FFFF",
12056
11909
  color: "hsl(349.4, 100%, 69%)",
12057
- mass: 131.2
11910
+ mass: 113.15764
12058
11911
  },
12059
11912
  K: {
12060
11913
  value: "K",
@@ -12063,7 +11916,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12063
11916
  hydrophobicity: -3.9,
12064
11917
  colorByFamily: "#FFC0CB",
12065
11918
  color: "hsl(264.7, 100%, 69%)",
12066
- mass: 146.2
11919
+ mass: 128.17228
12067
11920
  },
12068
11921
  M: {
12069
11922
  value: "M",
@@ -12072,7 +11925,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12072
11925
  hydrophobicity: 1.9,
12073
11926
  colorByFamily: "#FFFF00",
12074
11927
  color: "hsl(328.5, 100%, 69%)",
12075
- mass: 149.2
11928
+ mass: 131.19606
12076
11929
  },
12077
11930
  F: {
12078
11931
  value: "F",
@@ -12081,7 +11934,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12081
11934
  hydrophobicity: 2.8,
12082
11935
  colorByFamily: "#FFA500",
12083
11936
  color: "hsl(338.4, 100%, 69%)",
12084
- mass: 165.2
11937
+ mass: 147.17386
12085
11938
  },
12086
11939
  P: {
12087
11940
  value: "P",
@@ -12090,7 +11943,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12090
11943
  hydrophobicity: -1.6,
12091
11944
  colorByFamily: "#00FFFF",
12092
11945
  color: "hsl(289.9, 100%, 69%)",
12093
- mass: 115.1
11946
+ mass: 97.11518
12094
11947
  },
12095
11948
  S: {
12096
11949
  value: "S",
@@ -12099,7 +11952,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12099
11952
  hydrophobicity: -0.8,
12100
11953
  colorByFamily: "#90EE90",
12101
11954
  color: "hsl(298.6, 100%, 69%)",
12102
- mass: 105.1
11955
+ mass: 87.0773
12103
11956
  },
12104
11957
  T: {
12105
11958
  value: "T",
@@ -12108,7 +11961,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12108
11961
  hydrophobicity: -0.7,
12109
11962
  colorByFamily: "#90EE90",
12110
11963
  color: "hsl(299.8, 100%, 69%)",
12111
- mass: 119.1
11964
+ mass: 101.10388
12112
11965
  },
12113
11966
  U: {
12114
11967
  value: "U",
@@ -12116,7 +11969,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12116
11969
  threeLettersName: "Sec",
12117
11970
  colorByFamily: "#FF0000",
12118
11971
  color: "hsl(0, 100%, 69%)",
12119
- mass: 168.1
11972
+ mass: 150.3079
12120
11973
  },
12121
11974
  W: {
12122
11975
  value: "W",
@@ -12125,7 +11978,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12125
11978
  hydrophobicity: -0.9,
12126
11979
  colorByFamily: "#FFA500",
12127
11980
  color: "hsl(297.6, 100%, 69%)",
12128
- mass: 204.2
11981
+ mass: 186.2099
12129
11982
  },
12130
11983
  Y: {
12131
11984
  value: "Y",
@@ -12134,7 +11987,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12134
11987
  hydrophobicity: -1.3,
12135
11988
  colorByFamily: "#FFA500",
12136
11989
  color: "hsl(293.2, 100%, 69%)",
12137
- mass: 181.2
11990
+ mass: 163.17326
12138
11991
  },
12139
11992
  V: {
12140
11993
  value: "V",
@@ -12143,7 +11996,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12143
11996
  hydrophobicity: 4.2,
12144
11997
  colorByFamily: "#00FFFF",
12145
11998
  color: "hsl(353.6, 100%, 69%)",
12146
- mass: 117.1
11999
+ mass: 99.13106
12147
12000
  },
12148
12001
  "*": {
12149
12002
  value: "*",
@@ -12472,20 +12325,91 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12472
12325
  "primers",
12473
12326
  "guides"
12474
12327
  ];
12475
- function filterSequenceString(sequenceString, additionalValidChars = "", charOverrides) {
12476
- if (sequenceString) {
12477
- return sequenceString.replace(
12478
- new RegExp(
12479
- `[^${charOverrides || `atgcyrswkmbvdhnu${additionalValidChars.split("").join("\\")}`}]`,
12480
- "gi"
12481
- ),
12482
- ""
12328
+ function filterSequenceString(sequenceString, {
12329
+ additionalValidChars = "",
12330
+ isOligo,
12331
+ name,
12332
+ isProtein,
12333
+ isRna,
12334
+ isMixedRnaAndDna,
12335
+ includeStopCodon
12336
+ } = {}) {
12337
+ const acceptedChars = getAcceptedChars({
12338
+ isOligo,
12339
+ isProtein,
12340
+ isRna,
12341
+ isMixedRnaAndDna,
12342
+ includeStopCodon
12343
+ });
12344
+ const replaceChars = getReplaceChars({
12345
+ isOligo,
12346
+ isProtein,
12347
+ isRna,
12348
+ isMixedRnaAndDna
12349
+ });
12350
+ let sanitizedVal = "";
12351
+ const invalidChars = [];
12352
+ const chars = `${acceptedChars}${additionalValidChars.split("").join("\\")}`;
12353
+ const warnings = [];
12354
+ const replaceCount = {};
12355
+ sequenceString.split("").forEach((letter) => {
12356
+ const lowerLetter = letter.toLowerCase();
12357
+ if (replaceChars && replaceChars[lowerLetter]) {
12358
+ if (!replaceCount[lowerLetter]) {
12359
+ replaceCount[lowerLetter] = 0;
12360
+ }
12361
+ replaceCount[lowerLetter]++;
12362
+ const isUpper = lowerLetter !== letter;
12363
+ sanitizedVal += isUpper ? replaceChars[lowerLetter].toUpperCase() : replaceChars[lowerLetter];
12364
+ } else if (chars.includes(lowerLetter)) {
12365
+ sanitizedVal += letter;
12366
+ } else {
12367
+ invalidChars.push(letter);
12368
+ }
12369
+ });
12370
+ Object.keys(replaceCount).forEach((letter) => {
12371
+ warnings.push(
12372
+ `Replaced "${letter}" with "${replaceChars[letter]}"${replaceCount[letter] > 1 ? ` ${replaceCount[letter]} times` : ""}`
12483
12373
  );
12484
- } else {
12485
- return sequenceString;
12374
+ });
12375
+ if (sequenceString.length !== sanitizedVal.length) {
12376
+ warnings.push(
12377
+ `${name ? `Sequence ${name}: ` : ""}Invalid character(s) detected and removed: ${invalidChars.slice(0, 100).join(", ")} `
12378
+ );
12379
+ }
12380
+ if (typeof window !== "undefined" && window.toastr && warnings.length) {
12381
+ warnings.forEach((warning) => {
12382
+ window.toastr.warning(warning);
12383
+ });
12486
12384
  }
12385
+ return [sanitizedVal, warnings];
12487
12386
  }
12488
12387
  __name(filterSequenceString, "filterSequenceString");
12388
+ function getAcceptedChars({
12389
+ isOligo,
12390
+ isProtein,
12391
+ isRna,
12392
+ isMixedRnaAndDna,
12393
+ includeStopCodon
12394
+ } = {}) {
12395
+ return isProtein ? `${protein_letters_withUandX.toLowerCase()}${includeStopCodon ? "*." : ""}}` : isOligo ? ambiguous_rna_letters.toLowerCase() + "t" : isRna ? ambiguous_rna_letters.toLowerCase() + "t" : isMixedRnaAndDna ? ambiguous_rna_letters.toLowerCase() + ambiguous_dna_letters.toLowerCase() : (
12396
+ //just plain old dna
12397
+ ambiguous_rna_letters.toLowerCase() + ambiguous_dna_letters.toLowerCase()
12398
+ );
12399
+ }
12400
+ __name(getAcceptedChars, "getAcceptedChars");
12401
+ function getReplaceChars({
12402
+ isOligo,
12403
+ isProtein,
12404
+ isRna,
12405
+ isMixedRnaAndDna
12406
+ } = {}) {
12407
+ return isProtein ? {} : isOligo ? {} : isRna ? { t: "u" } : isMixedRnaAndDna ? {} : (
12408
+ //just plain old dna
12409
+ {}
12410
+ );
12411
+ }
12412
+ __name(getReplaceChars, "getReplaceChars");
12489
12413
  function tidyUpAnnotation(_annotation, {
12490
12414
  sequenceData = {},
12491
12415
  convertAnnotationsFromAAIndices,
@@ -12598,13 +12522,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12598
12522
  messages.push(
12599
12523
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
12600
12524
  );
12601
- location.start = size - (isProtein ? 3 : 1);
12525
+ location.start = Math.max(0, size - (isProtein ? 3 : 1));
12602
12526
  }
12603
12527
  if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
12604
12528
  messages.push(
12605
12529
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
12606
12530
  );
12607
- location.end = size - 1;
12531
+ location.end = Math.max(0, size - 1);
12608
12532
  }
12609
12533
  if (location.start > location.end && circular === false) {
12610
12534
  messages.push(
@@ -12614,14 +12538,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12614
12538
  }
12615
12539
  }
12616
12540
  __name(coerceLocation, "coerceLocation");
12617
- function filterAminoAcidSequenceString(sequenceString, options) {
12618
- options = options || {};
12619
- if (options.includeStopCodon) {
12620
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
12621
- }
12622
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
12623
- }
12624
- __name(filterAminoAcidSequenceString, "filterAminoAcidSequenceString");
12625
12541
  function getDegenerateDnaStringFromAAString(aaString) {
12626
12542
  return aaString.split("").map((char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn").join("");
12627
12543
  }
@@ -12633,11 +12549,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12633
12549
  removeUnwantedChars,
12634
12550
  additionalValidChars,
12635
12551
  noTranslationData,
12636
- charOverrides,
12637
12552
  doNotProvideIdsForAnnotations,
12638
- proteinFilterOptions,
12639
12553
  noCdsTranslations,
12640
- convertAnnotationsFromAAIndices
12554
+ convertAnnotationsFromAAIndices,
12555
+ topLevelSeqData
12641
12556
  } = options;
12642
12557
  let seqData = lodashExports.cloneDeep(pSeqData);
12643
12558
  const response = {
@@ -12667,16 +12582,15 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
12667
12582
  }
12668
12583
  if (removeUnwantedChars) {
12669
12584
  if (seqData.isProtein) {
12670
- seqData.proteinSequence = filterAminoAcidSequenceString(
12671
- seqData.proteinSequence,
12672
- __spreadValues({ includeStopCodon: true }, proteinFilterOptions)
12673
- );
12585
+ const [newSeq] = filterSequenceString(seqData.proteinSequence, __spreadValues({
12586
+ includeStopCodon: true
12587
+ }, topLevelSeqData || seqData));
12588
+ seqData.proteinSequence = newSeq;
12674
12589
  } else {
12675
- seqData.sequence = filterSequenceString(
12676
- seqData.sequence,
12677
- `${additionalValidChars || ""}${seqData.isRna || seqData.isMixedRnaAndDna ? "u" : ""}`,
12678
- charOverrides
12679
- );
12590
+ const [newSeq] = filterSequenceString(seqData.sequence, __spreadValues({
12591
+ additionalValidChars
12592
+ }, topLevelSeqData || seqData));
12593
+ seqData.sequence = newSeq;
12680
12594
  }
12681
12595
  }
12682
12596
  if (seqData.isProtein) {
@@ -13110,7 +13024,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
13110
13024
  calculateTemperature: function(sequence, type, A, R, C, Na) {
13111
13025
  if (typeof type === "undefined") {
13112
13026
  type = this.TABLE_BRESLAUER;
13113
- } else if (type != this.TABLE_BRESLAUER && (type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO)) {
13027
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
13114
13028
  throw new Error("Invalid table type!");
13115
13029
  }
13116
13030
  if (!A) {
@@ -21472,12 +21386,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
21472
21386
  }
21473
21387
  __name(findSequenceMatches, "findSequenceMatches");
21474
21388
  function findSequenceMatchesTopStrand(sequence, searchString, options = {}) {
21475
- const {
21476
- isCircular,
21477
- isAmbiguous,
21478
- isProteinSequence,
21479
- isProteinSearch
21480
- } = options;
21389
+ const { isCircular, isAmbiguous, isProteinSequence, isProteinSearch } = options;
21481
21390
  let searchStringToUse = escapeStringRegexp(searchString);
21482
21391
  if (isAmbiguous) {
21483
21392
  if (isProteinSearch || isProteinSequence) {
@@ -21610,7 +21519,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
21610
21519
  __name(getComplementAminoAcidStringFromSequenceString, "getComplementAminoAcidStringFromSequenceString");
21611
21520
  function getComplementSequenceString(sequence, isRna) {
21612
21521
  let complementSeqString = "";
21613
- const complementMap = lodashExports.merge(DNAComplementMap, isRna ? { a: "u", A: "U" } : { a: "t", A: "T" });
21522
+ const complementMap = lodashExports.merge(
21523
+ DNAComplementMap,
21524
+ isRna ? { a: "u", A: "U" } : { a: "t", A: "T" }
21525
+ );
21614
21526
  for (let i = 0; i < sequence.length; i++) {
21615
21527
  let complementChar = complementMap[sequence[i]];
21616
21528
  if (!complementChar) {
@@ -21914,7 +21826,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
21914
21826
  }
21915
21827
  __name(getReverseAminoAcidStringFromSequenceString, "getReverseAminoAcidStringFromSequenceString");
21916
21828
  function getReverseComplementAminoAcidStringFromSequenceString(sequenceString) {
21917
- return getAminoAcidStringFromSequenceString(getReverseComplementSequenceString(sequenceString));
21829
+ return getAminoAcidStringFromSequenceString(
21830
+ getReverseComplementSequenceString(sequenceString)
21831
+ );
21918
21832
  }
21919
21833
  __name(getReverseComplementAminoAcidStringFromSequenceString, "getReverseComplementAminoAcidStringFromSequenceString");
21920
21834
  function getReverseComplementAnnotation(annotation, sequenceLength) {
@@ -22764,6 +22678,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
22764
22678
  if (divideByThree) {
22765
22679
  sumMass /= 3;
22766
22680
  }
22681
+ if (aaString.length > 0) {
22682
+ sumMass = sumMass + 18.0153;
22683
+ }
22767
22684
  return Math.round(sumMass * __pow(10, numsAfterDecimal)) / __pow(10, numsAfterDecimal);
22768
22685
  }
22769
22686
  __name(getMassOfAaString, "getMassOfAaString");
@@ -22813,7 +22730,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
22813
22730
  exports2.deleteSequenceDataAtRange = deleteSequenceDataAtRange;
22814
22731
  exports2.doesEnzymeChopOutsideOfRecognitionSite = doesEnzymeChopOutsideOfRecognitionSite;
22815
22732
  exports2.featureColors = featureColors;
22816
- exports2.filterAminoAcidSequenceString = filterAminoAcidSequenceString;
22817
22733
  exports2.filterSequenceString = filterSequenceString;
22818
22734
  exports2.findNearestRangeOfSequenceOverlapToPosition = findNearestRangeOfSequenceOverlapToPosition;
22819
22735
  exports2.findOrfsInPlasmid = findOrfsInPlasmid;