@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.mjs CHANGED
@@ -5997,31 +5997,8 @@ lodash.exports;
5997
5997
  })(lodash, lodash.exports);
5998
5998
  var lodashExports = lodash.exports;
5999
5999
  const protein_letters = "ACDEFGHIKLMNPQRSTVWY";
6000
+ const protein_letters_withUandX = "ACDEFGHIKLMNPQRSTVWYUX";
6000
6001
  const extended_protein_letters = "ACDEFGHIKLMNPQRSTVWYBXZJUO.*-";
6001
- const protein_letters_1to3 = {
6002
- A: "Ala",
6003
- C: "Cys",
6004
- D: "Asp",
6005
- E: "Glu",
6006
- F: "Phe",
6007
- G: "Gly",
6008
- H: "His",
6009
- I: "Ile",
6010
- K: "Lys",
6011
- L: "Leu",
6012
- M: "Met",
6013
- N: "Asn",
6014
- P: "Pro",
6015
- Q: "Gln",
6016
- R: "Arg",
6017
- S: "Ser",
6018
- T: "Thr",
6019
- V: "Val",
6020
- W: "Trp",
6021
- Y: "Tyr",
6022
- O: "Pyl",
6023
- U: "Sec"
6024
- };
6025
6002
  const ambiguous_dna_letters = "GATCRYWSMKHBVDN";
6026
6003
  const unambiguous_dna_letters = "GATC";
6027
6004
  const ambiguous_rna_letters = "GAUCRYWSMKHBVDN";
@@ -6046,135 +6023,6 @@ const ambiguous_dna_values = {
6046
6023
  X: "GATC",
6047
6024
  N: "GATC"
6048
6025
  };
6049
- const ambiguous_rna_values = {
6050
- ".": ".",
6051
- A: "A",
6052
- C: "C",
6053
- G: "G",
6054
- U: "U",
6055
- M: "AC",
6056
- R: "AG",
6057
- W: "AU",
6058
- S: "CG",
6059
- Y: "CU",
6060
- K: "GU",
6061
- V: "ACG",
6062
- H: "ACU",
6063
- D: "AGU",
6064
- B: "CGU",
6065
- X: "GAUC",
6066
- N: "GAUC"
6067
- };
6068
- const ambiguous_dna_complement = {
6069
- ".": ".",
6070
- A: "T",
6071
- C: "G",
6072
- G: "C",
6073
- T: "A",
6074
- M: "K",
6075
- R: "Y",
6076
- W: "W",
6077
- S: "S",
6078
- Y: "R",
6079
- K: "M",
6080
- V: "B",
6081
- H: "D",
6082
- D: "H",
6083
- B: "V",
6084
- X: "X",
6085
- N: "N"
6086
- };
6087
- const ambiguous_rna_complement = {
6088
- ".": ".",
6089
- A: "U",
6090
- C: "G",
6091
- G: "C",
6092
- U: "A",
6093
- M: "K",
6094
- R: "Y",
6095
- W: "W",
6096
- S: "S",
6097
- Y: "R",
6098
- K: "M",
6099
- V: "B",
6100
- H: "D",
6101
- D: "H",
6102
- B: "V",
6103
- X: "X",
6104
- N: "N"
6105
- };
6106
- const unambiguous_dna_weights = {
6107
- A: 331.2218,
6108
- C: 307.1971,
6109
- G: 347.2212,
6110
- T: 322.2085
6111
- };
6112
- const monoisotopic_unambiguous_dna_weights = {
6113
- A: 331.06817,
6114
- C: 307.056936,
6115
- G: 347.063084,
6116
- T: 322.056602
6117
- };
6118
- const unambiguous_rna_weights = {
6119
- A: 347.2212,
6120
- C: 323.1965,
6121
- G: 363.2206,
6122
- U: 324.1813
6123
- };
6124
- const monoisotopic_unambiguous_rna_weights = {
6125
- A: 347.063084,
6126
- C: 323.051851,
6127
- G: 363.057999,
6128
- U: 324.035867
6129
- };
6130
- const protein_weights = {
6131
- A: 89.0932,
6132
- C: 121.1582,
6133
- D: 133.1027,
6134
- E: 147.1293,
6135
- F: 165.1891,
6136
- G: 75.0666,
6137
- H: 155.1546,
6138
- I: 131.1729,
6139
- K: 146.1876,
6140
- L: 131.1729,
6141
- M: 149.2113,
6142
- N: 132.1179,
6143
- O: 255.3134,
6144
- P: 115.1305,
6145
- Q: 146.1445,
6146
- R: 174.201,
6147
- S: 105.0926,
6148
- T: 119.1192,
6149
- U: 168.0532,
6150
- V: 117.1463,
6151
- W: 204.2252,
6152
- Y: 181.1885
6153
- };
6154
- const monoisotopic_protein_weights = {
6155
- A: 89.047678,
6156
- C: 121.019749,
6157
- D: 133.037508,
6158
- E: 147.053158,
6159
- F: 165.078979,
6160
- G: 75.032028,
6161
- H: 155.069477,
6162
- I: 131.094629,
6163
- K: 146.105528,
6164
- L: 131.094629,
6165
- M: 149.051049,
6166
- N: 132.053492,
6167
- O: 255.158292,
6168
- P: 115.063329,
6169
- Q: 146.069142,
6170
- R: 174.111676,
6171
- S: 105.042593,
6172
- T: 119.058243,
6173
- U: 168.964203,
6174
- V: 117.078979,
6175
- W: 204.089878,
6176
- Y: 181.073893
6177
- };
6178
6026
  const extended_protein_values = {
6179
6027
  A: "A",
6180
6028
  B: "ND",
@@ -6209,140 +6057,18 @@ const extended_protein_values = {
6209
6057
  ".": "\\.\\.",
6210
6058
  "-": "\\-"
6211
6059
  };
6212
- const atom_weights = {
6213
- H: 1.00794,
6214
- D: 2.0141,
6215
- He: 4.002602,
6216
- Li: 6.941,
6217
- Be: 9.012182,
6218
- B: 10.811,
6219
- C: 12.0107,
6220
- N: 14.0067,
6221
- O: 15.9994,
6222
- F: 18.9984032,
6223
- Ne: 20.1797,
6224
- Na: 22.98977,
6225
- Mg: 24.305,
6226
- Al: 26.981538,
6227
- Si: 28.0855,
6228
- P: 30.973761,
6229
- S: 32.065,
6230
- Cl: 35.453,
6231
- Ar: 39.948,
6232
- K: 39.0983,
6233
- Ca: 40.078,
6234
- Sc: 44.95591,
6235
- Ti: 47.867,
6236
- V: 50.9415,
6237
- Cr: 51.9961,
6238
- Mn: 54.938049,
6239
- Fe: 55.845,
6240
- Co: 58.9332,
6241
- Ni: 58.6934,
6242
- Cu: 63.546,
6243
- Zn: 65.39,
6244
- Ga: 69.723,
6245
- Ge: 72.64,
6246
- As: 74.9216,
6247
- Se: 78.96,
6248
- Br: 79.904,
6249
- Kr: 83.8,
6250
- Rb: 85.4678,
6251
- Sr: 87.62,
6252
- Y: 88.90585,
6253
- Zr: 91.224,
6254
- Nb: 92.90638,
6255
- Mo: 95.94,
6256
- Tc: 98,
6257
- Ru: 101.07,
6258
- Rh: 102.9055,
6259
- Pd: 106.42,
6260
- Ag: 107.8682,
6261
- Cd: 112.411,
6262
- In: 114.818,
6263
- Sn: 118.71,
6264
- Sb: 121.76,
6265
- Te: 127.6,
6266
- I: 126.90447,
6267
- Xe: 131.293,
6268
- Cs: 132.90545,
6269
- Ba: 137.327,
6270
- La: 138.9055,
6271
- Ce: 140.116,
6272
- Pr: 140.90765,
6273
- Nd: 144.24,
6274
- Pm: 145,
6275
- Sm: 150.36,
6276
- Eu: 151.964,
6277
- Gd: 157.25,
6278
- Tb: 158.92534,
6279
- Dy: 162.5,
6280
- Ho: 164.93032,
6281
- Er: 167.259,
6282
- Tm: 168.93421,
6283
- Yb: 173.04,
6284
- Lu: 174.967,
6285
- Hf: 178.49,
6286
- Ta: 180.9479,
6287
- W: 183.84,
6288
- Re: 186.207,
6289
- Os: 190.23,
6290
- Ir: 192.217,
6291
- Pt: 195.078,
6292
- Au: 196.96655,
6293
- Hg: 200.59,
6294
- Tl: 204.3833,
6295
- Pb: 207.2,
6296
- Bi: 208.98038,
6297
- Po: 208.98,
6298
- At: 209.99,
6299
- Rn: 222.02,
6300
- Fr: 223.02,
6301
- Ra: 226.03,
6302
- Ac: 227.03,
6303
- Th: 232.0381,
6304
- Pa: 231.03588,
6305
- U: 238.02891,
6306
- Np: 237.05,
6307
- Pu: 244.06,
6308
- Am: 243.06,
6309
- Cm: 247.07,
6310
- Bk: 247.07,
6311
- Cf: 251.08,
6312
- Es: 252.08,
6313
- Fm: 257.1,
6314
- Md: 258.1,
6315
- No: 259.1,
6316
- Lr: 262.11,
6317
- Rf: 261.11,
6318
- Db: 262.11,
6319
- Sg: 266.12,
6320
- Bh: 264.12,
6321
- Hs: 269.13,
6322
- Mt: 268.14
6323
- };
6324
6060
  const bioData = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6325
6061
  __proto__: null,
6326
- ambiguous_dna_complement,
6327
6062
  ambiguous_dna_letters,
6328
6063
  ambiguous_dna_values,
6329
- ambiguous_rna_complement,
6330
6064
  ambiguous_rna_letters,
6331
- ambiguous_rna_values,
6332
- atom_weights,
6333
6065
  extended_dna_letters,
6334
6066
  extended_protein_letters,
6335
6067
  extended_protein_values,
6336
- monoisotopic_protein_weights,
6337
- monoisotopic_unambiguous_dna_weights,
6338
- monoisotopic_unambiguous_rna_weights,
6339
6068
  protein_letters,
6340
- protein_letters_1to3,
6341
- protein_weights,
6069
+ protein_letters_withUandX,
6342
6070
  unambiguous_dna_letters,
6343
- unambiguous_dna_weights,
6344
- unambiguous_rna_letters,
6345
- unambiguous_rna_weights
6071
+ unambiguous_rna_letters
6346
6072
  }, Symbol.toStringTag, { value: "Module" }));
6347
6073
  const aminoAcidToDegenerateDnaMap = {
6348
6074
  "-": "---",
@@ -6456,8 +6182,8 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
6456
6182
  maxRangeLength
6457
6183
  );
6458
6184
  let overlaps = [];
6459
- normalizedRangeA.forEach(function(nonCircularRangeA, iA) {
6460
- normalizedRangeB.forEach(function(nonCircularRangeB, iB) {
6185
+ normalizedRangeA.forEach(function(nonCircularRangeA) {
6186
+ normalizedRangeB.forEach(function(nonCircularRangeB) {
6461
6187
  const overlap = getOverlapOfNonCircularRanges(
6462
6188
  nonCircularRangeA,
6463
6189
  nonCircularRangeB
@@ -6469,7 +6195,7 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
6469
6195
  });
6470
6196
  if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
6471
6197
  const joinedOverlap = {};
6472
- overlaps = lodashExports.flatMap(overlaps, (o, i) => {
6198
+ overlaps = lodashExports.flatMap(overlaps, (o) => {
6473
6199
  if (o.start === 0) {
6474
6200
  joinedOverlap.end = o.end;
6475
6201
  return [];
@@ -6567,12 +6293,14 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
6567
6293
  });
6568
6294
  splitRangesToBeTrimmed[index] = nonCircularRangeToBeTrimmed;
6569
6295
  });
6570
- const outputSplitRanges = splitRangesToBeTrimmed.filter(function(trimmedRange) {
6571
- if (trimmedRange) {
6572
- return true;
6296
+ const outputSplitRanges = splitRangesToBeTrimmed.filter(
6297
+ function(trimmedRange) {
6298
+ if (trimmedRange) {
6299
+ return true;
6300
+ }
6301
+ return false;
6573
6302
  }
6574
- return false;
6575
- });
6303
+ );
6576
6304
  let outputTrimmedRange;
6577
6305
  if (outputSplitRanges.length < 0)
6578
6306
  ;
@@ -6671,11 +6399,19 @@ function checkIfNonCircularRangesOverlap(range, comparisonRange) {
6671
6399
  }
6672
6400
  __name(checkIfNonCircularRangesOverlap, "checkIfNonCircularRangesOverlap");
6673
6401
  function checkIfPotentiallyCircularRangesOverlap(range, comparisonRange) {
6674
- return splitRangeIntoTwoPartsIfItIsCircular(range, Infinity).some(function(splitRange) {
6675
- return splitRangeIntoTwoPartsIfItIsCircular(comparisonRange, Infinity).some(function(splitComparisonRange) {
6676
- return checkIfNonCircularRangesOverlap(splitRange, splitComparisonRange);
6677
- });
6678
- });
6402
+ return splitRangeIntoTwoPartsIfItIsCircular(range, Infinity).some(
6403
+ function(splitRange) {
6404
+ return splitRangeIntoTwoPartsIfItIsCircular(
6405
+ comparisonRange,
6406
+ Infinity
6407
+ ).some(function(splitComparisonRange) {
6408
+ return checkIfNonCircularRangesOverlap(
6409
+ splitRange,
6410
+ splitComparisonRange
6411
+ );
6412
+ });
6413
+ }
6414
+ );
6679
6415
  }
6680
6416
  __name(checkIfPotentiallyCircularRangesOverlap, "checkIfPotentiallyCircularRangesOverlap");
6681
6417
  function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequenceLength, optionalOriginalRange) {
@@ -6684,15 +6420,19 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
6684
6420
  return overlaps;
6685
6421
  } else if (overlaps.length === 2) {
6686
6422
  if (overlaps[0].start === 0 && overlaps[1].end + 1 === sequenceLength && !originalRangeLinear) {
6687
- return [{
6688
- start: overlaps[1].start,
6689
- end: overlaps[0].end
6690
- }];
6423
+ return [
6424
+ {
6425
+ start: overlaps[1].start,
6426
+ end: overlaps[0].end
6427
+ }
6428
+ ];
6691
6429
  } else if (overlaps[1].start === 0 && overlaps[0].end + 1 === sequenceLength && !originalRangeLinear) {
6692
- return [{
6693
- start: overlaps[0].start,
6694
- end: overlaps[1].end
6695
- }];
6430
+ return [
6431
+ {
6432
+ start: overlaps[0].start,
6433
+ end: overlaps[1].end
6434
+ }
6435
+ ];
6696
6436
  } else {
6697
6437
  return overlaps;
6698
6438
  }
@@ -6700,17 +6440,29 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
6700
6440
  const firstOverlap = overlaps[0];
6701
6441
  const secondOverlap = overlaps[1];
6702
6442
  const thirdOverlap = overlaps[2];
6703
- let collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([firstOverlap, secondOverlap], sequenceLength, optionalOriginalRange);
6443
+ let collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6444
+ [firstOverlap, secondOverlap],
6445
+ sequenceLength,
6446
+ optionalOriginalRange
6447
+ );
6704
6448
  if (collapsedOverlaps.length === 1) {
6705
6449
  collapsedOverlaps.push(thirdOverlap);
6706
6450
  return collapsedOverlaps;
6707
6451
  } else {
6708
- collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([firstOverlap, thirdOverlap], sequenceLength, optionalOriginalRange);
6452
+ collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6453
+ [firstOverlap, thirdOverlap],
6454
+ sequenceLength,
6455
+ optionalOriginalRange
6456
+ );
6709
6457
  if (collapsedOverlaps.length === 1) {
6710
6458
  collapsedOverlaps.push(secondOverlap);
6711
6459
  return collapsedOverlaps;
6712
6460
  } else {
6713
- collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible([secondOverlap, thirdOverlap], sequenceLength, optionalOriginalRange);
6461
+ collapsedOverlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6462
+ [secondOverlap, thirdOverlap],
6463
+ sequenceLength,
6464
+ optionalOriginalRange
6465
+ );
6714
6466
  if (collapsedOverlaps.length === 1) {
6715
6467
  collapsedOverlaps.push(firstOverlap);
6716
6468
  return collapsedOverlaps;
@@ -6817,13 +6569,23 @@ function expandOrContractRangeByLength(range, shiftBy, shiftStart, sequenceLengt
6817
6569
  __name(expandOrContractRangeByLength, "expandOrContractRangeByLength");
6818
6570
  function translateRange(rangeToBeAdjusted, translateBy, rangeLength) {
6819
6571
  return lodashExports.assign({}, rangeToBeAdjusted, {
6820
- start: normalizePositionByRangeLength(rangeToBeAdjusted.start + translateBy, rangeLength),
6821
- end: normalizePositionByRangeLength(rangeToBeAdjusted.end + translateBy, rangeLength)
6572
+ start: normalizePositionByRangeLength(
6573
+ rangeToBeAdjusted.start + translateBy,
6574
+ rangeLength
6575
+ ),
6576
+ end: normalizePositionByRangeLength(
6577
+ rangeToBeAdjusted.end + translateBy,
6578
+ rangeLength
6579
+ )
6822
6580
  });
6823
6581
  }
6824
6582
  __name(translateRange, "translateRange");
6825
- function flipRelativeRange(innerRange, outerRange, sequenceLength, options) {
6826
- const isFullyContained = isRangeWithinRange(innerRange, outerRange, sequenceLength);
6583
+ function flipRelativeRange(innerRange, outerRange, sequenceLength) {
6584
+ const isFullyContained = isRangeWithinRange(
6585
+ innerRange,
6586
+ outerRange,
6587
+ sequenceLength
6588
+ );
6827
6589
  if (isFullyContained) {
6828
6590
  return flipFullyContainedRange(innerRange, outerRange, sequenceLength);
6829
6591
  } else {
@@ -6831,42 +6593,92 @@ function flipRelativeRange(innerRange, outerRange, sequenceLength, options) {
6831
6593
  }
6832
6594
  }
6833
6595
  __name(flipRelativeRange, "flipRelativeRange");
6834
- function flipNonFullyContainedRange(innerRange, outerRange, sequenceLength, options) {
6835
- const outerFullyContained = isRangeWithinRange(outerRange, innerRange, sequenceLength);
6596
+ function flipNonFullyContainedRange(innerRange, outerRange, sequenceLength) {
6597
+ const outerFullyContained = isRangeWithinRange(
6598
+ outerRange,
6599
+ innerRange,
6600
+ sequenceLength
6601
+ );
6836
6602
  let flippedInnerRange;
6837
6603
  if (outerFullyContained) {
6838
- const expandBy1 = getRangeLength({
6839
- start: innerRange.start,
6840
- end: outerRange.start
6841
- }, sequenceLength) - 1;
6842
- flippedInnerRange = expandOrContractRangeByLength(outerRange, expandBy1, false, sequenceLength);
6843
- const expandBy2 = getRangeLength({
6844
- end: innerRange.end,
6845
- start: outerRange.end
6846
- }, sequenceLength) - 1;
6847
- flippedInnerRange = expandOrContractRangeByLength(flippedInnerRange, expandBy2, true, sequenceLength);
6604
+ const expandBy1 = getRangeLength(
6605
+ {
6606
+ start: innerRange.start,
6607
+ end: outerRange.start
6608
+ },
6609
+ sequenceLength
6610
+ ) - 1;
6611
+ flippedInnerRange = expandOrContractRangeByLength(
6612
+ outerRange,
6613
+ expandBy1,
6614
+ false,
6615
+ sequenceLength
6616
+ );
6617
+ const expandBy2 = getRangeLength(
6618
+ {
6619
+ end: innerRange.end,
6620
+ start: outerRange.end
6621
+ },
6622
+ sequenceLength
6623
+ ) - 1;
6624
+ flippedInnerRange = expandOrContractRangeByLength(
6625
+ flippedInnerRange,
6626
+ expandBy2,
6627
+ true,
6628
+ sequenceLength
6629
+ );
6848
6630
  } else {
6849
- const overlaps = getOverlapsOfPotentiallyCircularRanges(innerRange, outerRange, sequenceLength);
6631
+ const overlaps = getOverlapsOfPotentiallyCircularRanges(
6632
+ innerRange,
6633
+ outerRange,
6634
+ sequenceLength
6635
+ );
6850
6636
  if (overlaps.length >= 1) {
6851
- let overlapExtendsForward;
6852
6637
  const firstOverlap = overlaps[0];
6853
- overlapExtendsForward = firstOverlap.start !== outerRange.start;
6854
- const flippedTruncatedInner = flipFullyContainedRange(firstOverlap, outerRange, sequenceLength);
6638
+ const overlapExtendsForward = firstOverlap.start !== outerRange.start;
6639
+ const flippedTruncatedInner = flipFullyContainedRange(
6640
+ firstOverlap,
6641
+ outerRange,
6642
+ sequenceLength
6643
+ );
6855
6644
  const lengthToExtend = getRangeLength(innerRange, sequenceLength) - getRangeLength(flippedTruncatedInner, sequenceLength);
6856
- flippedInnerRange = expandOrContractRangeByLength(flippedTruncatedInner, lengthToExtend, overlapExtendsForward, sequenceLength);
6645
+ flippedInnerRange = expandOrContractRangeByLength(
6646
+ flippedTruncatedInner,
6647
+ lengthToExtend,
6648
+ overlapExtendsForward,
6649
+ sequenceLength
6650
+ );
6857
6651
  } else {
6858
- throw new Error("This case (relative ranges that do not overlap) is unsupported! ");
6652
+ throw new Error(
6653
+ "This case (relative ranges that do not overlap) is unsupported! "
6654
+ );
6859
6655
  }
6860
6656
  }
6861
6657
  return flippedInnerRange;
6862
6658
  }
6863
6659
  __name(flipNonFullyContainedRange, "flipNonFullyContainedRange");
6864
- function flipFullyContainedRange(innerRange, outerRange, sequenceLength, options) {
6660
+ function flipFullyContainedRange(innerRange, outerRange, sequenceLength) {
6865
6661
  const translateBy = -outerRange.start;
6866
- const translatedOuterRange = translateRange(outerRange, translateBy, sequenceLength);
6867
- const translatedInnerRange = translateRange(innerRange, translateBy, sequenceLength);
6868
- const translatedFlippedInnerRange = flipNonOriginSpanningContainedRange(translatedInnerRange, translatedOuterRange, sequenceLength);
6869
- const flippedInnerRange = translateRange(translatedFlippedInnerRange, -translateBy, sequenceLength);
6662
+ const translatedOuterRange = translateRange(
6663
+ outerRange,
6664
+ translateBy,
6665
+ sequenceLength
6666
+ );
6667
+ const translatedInnerRange = translateRange(
6668
+ innerRange,
6669
+ translateBy,
6670
+ sequenceLength
6671
+ );
6672
+ const translatedFlippedInnerRange = flipNonOriginSpanningContainedRange(
6673
+ translatedInnerRange,
6674
+ translatedOuterRange,
6675
+ sequenceLength
6676
+ );
6677
+ const flippedInnerRange = translateRange(
6678
+ translatedFlippedInnerRange,
6679
+ -translateBy,
6680
+ sequenceLength
6681
+ );
6870
6682
  return flippedInnerRange;
6871
6683
  }
6872
6684
  __name(flipFullyContainedRange, "flipFullyContainedRange");
@@ -6884,7 +6696,10 @@ function generateRandomRange(minStart, maxEnd, maxLength) {
6884
6696
  const start = getRandomInt$1(minStart, maxEnd);
6885
6697
  let end;
6886
6698
  if (maxLength) {
6887
- end = normalizePositionByRangeLength(getRandomInt$1(start, start + maxLength), maxEnd);
6699
+ end = normalizePositionByRangeLength(
6700
+ getRandomInt$1(start, start + maxLength),
6701
+ maxEnd
6702
+ );
6888
6703
  } else {
6889
6704
  end = getRandomInt$1(minStart, maxEnd);
6890
6705
  }
@@ -6927,18 +6742,26 @@ function getShortestDistanceBetweenTwoPositions(position1, position2, sequenceLe
6927
6742
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
6928
6743
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
6929
6744
  let yOffset = [];
6930
- const openYOffsetFound = YOffsetLevelsWithRanges.some(function(rangesAlreadyAddedToYOffset, index) {
6931
- const rangeBlocked = rangesAlreadyAddedToYOffset.some(function(comparisonRange) {
6932
- return checkIfPotentiallyCircularRangesOverlap(range, comparisonRange);
6933
- });
6934
- if (!rangeBlocked) {
6935
- yOffset = index;
6936
- if (assignYOffsetToRange)
6937
- range.yOffset = index;
6938
- rangesAlreadyAddedToYOffset.push(range);
6939
- return true;
6745
+ const openYOffsetFound = YOffsetLevelsWithRanges.some(
6746
+ function(rangesAlreadyAddedToYOffset, index) {
6747
+ const rangeBlocked = rangesAlreadyAddedToYOffset.some(
6748
+ function(comparisonRange) {
6749
+ return checkIfPotentiallyCircularRangesOverlap(
6750
+ range,
6751
+ comparisonRange
6752
+ );
6753
+ }
6754
+ );
6755
+ if (!rangeBlocked) {
6756
+ yOffset = index;
6757
+ if (assignYOffsetToRange)
6758
+ range.yOffset = index;
6759
+ rangesAlreadyAddedToYOffset.push(range);
6760
+ return true;
6761
+ }
6762
+ return false;
6940
6763
  }
6941
- });
6764
+ );
6942
6765
  if (!openYOffsetFound) {
6943
6766
  yOffset = YOffsetLevelsWithRanges.length;
6944
6767
  if (assignYOffsetToRange)
@@ -6952,7 +6775,11 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
6952
6775
  let maxYOffset = 0;
6953
6776
  const yOffsetLevels = [];
6954
6777
  ranges.forEach(function(range) {
6955
- const yOffset = getYOffsetForPotentiallyCircularRange(range, yOffsetLevels, assignYOffsetToRange);
6778
+ const yOffset = getYOffsetForPotentiallyCircularRange(
6779
+ range,
6780
+ yOffsetLevels,
6781
+ assignYOffsetToRange
6782
+ );
6956
6783
  yOffsets.push(yOffset);
6957
6784
  if (yOffset > maxYOffset) {
6958
6785
  maxYOffset = yOffset;
@@ -6985,8 +6812,16 @@ function invertRange$1(rangeOrCaret, rangeMax) {
6985
6812
  }
6986
6813
  __name(invertRange$1, "invertRange$1");
6987
6814
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
6988
- const distanceFromStart = getShortestDistanceBetweenTwoPositions(range.start, position, maxLength);
6989
- const distanceFromEnd = getShortestDistanceBetweenTwoPositions(range.end, position, maxLength);
6815
+ const distanceFromStart = getShortestDistanceBetweenTwoPositions(
6816
+ range.start,
6817
+ position,
6818
+ maxLength
6819
+ );
6820
+ const distanceFromEnd = getShortestDistanceBetweenTwoPositions(
6821
+ range.end,
6822
+ position,
6823
+ maxLength
6824
+ );
6990
6825
  return distanceFromStart <= distanceFromEnd;
6991
6826
  }
6992
6827
  __name(isPositionCloserToRangeStartThanRangeEnd, "isPositionCloserToRangeStartThanRangeEnd");
@@ -7017,9 +6852,15 @@ function reversePositionInRange(position, rangeLength, isInBetweenPositions) {
7017
6852
  }
7018
6853
  __name(reversePositionInRange, "reversePositionInRange");
7019
6854
  function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength) {
7020
- const trimmedSubRange = trimRangeByAnotherRange(subRange, containerRange, sequenceLength);
6855
+ const trimmedSubRange = trimRangeByAnotherRange(
6856
+ subRange,
6857
+ containerRange,
6858
+ sequenceLength
6859
+ );
7021
6860
  if (trimmedSubRange) {
7022
- throw new Error("subRange must be fully contained by containerRange! Otherwise this function does not make sense");
6861
+ throw new Error(
6862
+ "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
6863
+ );
7023
6864
  }
7024
6865
  const newSubrange = {};
7025
6866
  newSubrange.start = subRange.start - containerRange.start;
@@ -7047,12 +6888,24 @@ function modulo(n, m) {
7047
6888
  }
7048
6889
  __name(modulo, "modulo");
7049
6890
  function getZeroedRangeOverlaps(annotation, selection, sequenceLength) {
7050
- const overlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(getOverlapsOfPotentiallyCircularRanges(annotation, selection, sequenceLength), sequenceLength, annotation);
6891
+ const overlaps = collapseOverlapsGeneratedFromRangeComparisonIfPossible(
6892
+ getOverlapsOfPotentiallyCircularRanges(
6893
+ annotation,
6894
+ selection,
6895
+ sequenceLength
6896
+ ),
6897
+ sequenceLength,
6898
+ annotation
6899
+ );
7051
6900
  const zeroedOverlaps = overlaps.map((overlap) => {
7052
- return zeroSubrangeByContainerRange(overlap, {
7053
- start: selection.start,
7054
- end: normalizePositionByRangeLength(selection.start - 1, sequenceLength)
7055
- }, sequenceLength);
6901
+ return zeroSubrangeByContainerRange(
6902
+ overlap,
6903
+ {
6904
+ start: selection.start,
6905
+ end: normalizePositionByRangeLength(selection.start - 1, sequenceLength)
6906
+ },
6907
+ sequenceLength
6908
+ );
7056
6909
  });
7057
6910
  return zeroedOverlaps;
7058
6911
  }
@@ -11960,7 +11813,7 @@ const proteinAlphabet = {
11960
11813
  hydrophobicity: 1.8,
11961
11814
  colorByFamily: "#00FFFF",
11962
11815
  color: "hsl(327.3, 100%, 69%)",
11963
- mass: 89.1
11816
+ mass: 71.0779
11964
11817
  },
11965
11818
  R: {
11966
11819
  value: "R",
@@ -11969,7 +11822,7 @@ const proteinAlphabet = {
11969
11822
  hydrophobicity: -4.5,
11970
11823
  colorByFamily: "#FFC0CB",
11971
11824
  color: "hsl(258.1, 100%, 69%)",
11972
- mass: 174.2
11825
+ mass: 156.18568
11973
11826
  },
11974
11827
  N: {
11975
11828
  value: "N",
@@ -11978,7 +11831,7 @@ const proteinAlphabet = {
11978
11831
  hydrophobicity: -3.5,
11979
11832
  colorByFamily: "#D3D3D3",
11980
11833
  color: "hsl(268.9, 100%, 69%)",
11981
- mass: 132.1
11834
+ mass: 114.10264
11982
11835
  },
11983
11836
  D: {
11984
11837
  value: "D",
@@ -11987,7 +11840,7 @@ const proteinAlphabet = {
11987
11840
  hydrophobicity: -3.5,
11988
11841
  colorByFamily: "#EE82EE",
11989
11842
  color: "hsl(268.9, 100%, 69%)",
11990
- mass: 133.1
11843
+ mass: 115.0874
11991
11844
  },
11992
11845
  C: {
11993
11846
  value: "C",
@@ -11996,7 +11849,7 @@ const proteinAlphabet = {
11996
11849
  hydrophobicity: 2.5,
11997
11850
  colorByFamily: "#FFFF00",
11998
11851
  color: "hsl(335.1, 100%, 69%)",
11999
- mass: 121.2
11852
+ mass: 103.1429
12000
11853
  },
12001
11854
  E: {
12002
11855
  value: "E",
@@ -12005,7 +11858,7 @@ const proteinAlphabet = {
12005
11858
  hydrophobicity: -3.5,
12006
11859
  colorByFamily: "#EE82EE",
12007
11860
  color: "hsl(268.9, 100%, 69%)",
12008
- mass: 147.1
11861
+ mass: 129.11398
12009
11862
  },
12010
11863
  Q: {
12011
11864
  value: "Q",
@@ -12014,7 +11867,7 @@ const proteinAlphabet = {
12014
11867
  hydrophobicity: -3.5,
12015
11868
  colorByFamily: "#D3D3D3",
12016
11869
  color: "hsl(268.9, 100%, 69%)",
12017
- mass: 146.2
11870
+ mass: 128.12922
12018
11871
  },
12019
11872
  G: {
12020
11873
  value: "G",
@@ -12023,7 +11876,7 @@ const proteinAlphabet = {
12023
11876
  hydrophobicity: -0.4,
12024
11877
  colorByFamily: "#00FFFF",
12025
11878
  color: "hsl(303.1, 100%, 69%)",
12026
- mass: 75.1
11879
+ mass: 57.05132
12027
11880
  },
12028
11881
  H: {
12029
11882
  value: "H",
@@ -12032,7 +11885,7 @@ const proteinAlphabet = {
12032
11885
  hydrophobicity: -3.2,
12033
11886
  colorByFamily: "#FFC0CB",
12034
11887
  color: "hsl(272.2, 100%, 69%)",
12035
- mass: 155.2
11888
+ mass: 137.13928
12036
11889
  },
12037
11890
  I: {
12038
11891
  value: "I",
@@ -12041,7 +11894,7 @@ const proteinAlphabet = {
12041
11894
  hydrophobicity: 4.5,
12042
11895
  colorByFamily: "#00FFFF",
12043
11896
  color: "hsl(356.9, 100%, 69%)",
12044
- mass: 131.2
11897
+ mass: 113.15764
12045
11898
  },
12046
11899
  L: {
12047
11900
  value: "L",
@@ -12050,7 +11903,7 @@ const proteinAlphabet = {
12050
11903
  hydrophobicity: 3.8,
12051
11904
  colorByFamily: "#00FFFF",
12052
11905
  color: "hsl(349.4, 100%, 69%)",
12053
- mass: 131.2
11906
+ mass: 113.15764
12054
11907
  },
12055
11908
  K: {
12056
11909
  value: "K",
@@ -12059,7 +11912,7 @@ const proteinAlphabet = {
12059
11912
  hydrophobicity: -3.9,
12060
11913
  colorByFamily: "#FFC0CB",
12061
11914
  color: "hsl(264.7, 100%, 69%)",
12062
- mass: 146.2
11915
+ mass: 128.17228
12063
11916
  },
12064
11917
  M: {
12065
11918
  value: "M",
@@ -12068,7 +11921,7 @@ const proteinAlphabet = {
12068
11921
  hydrophobicity: 1.9,
12069
11922
  colorByFamily: "#FFFF00",
12070
11923
  color: "hsl(328.5, 100%, 69%)",
12071
- mass: 149.2
11924
+ mass: 131.19606
12072
11925
  },
12073
11926
  F: {
12074
11927
  value: "F",
@@ -12077,7 +11930,7 @@ const proteinAlphabet = {
12077
11930
  hydrophobicity: 2.8,
12078
11931
  colorByFamily: "#FFA500",
12079
11932
  color: "hsl(338.4, 100%, 69%)",
12080
- mass: 165.2
11933
+ mass: 147.17386
12081
11934
  },
12082
11935
  P: {
12083
11936
  value: "P",
@@ -12086,7 +11939,7 @@ const proteinAlphabet = {
12086
11939
  hydrophobicity: -1.6,
12087
11940
  colorByFamily: "#00FFFF",
12088
11941
  color: "hsl(289.9, 100%, 69%)",
12089
- mass: 115.1
11942
+ mass: 97.11518
12090
11943
  },
12091
11944
  S: {
12092
11945
  value: "S",
@@ -12095,7 +11948,7 @@ const proteinAlphabet = {
12095
11948
  hydrophobicity: -0.8,
12096
11949
  colorByFamily: "#90EE90",
12097
11950
  color: "hsl(298.6, 100%, 69%)",
12098
- mass: 105.1
11951
+ mass: 87.0773
12099
11952
  },
12100
11953
  T: {
12101
11954
  value: "T",
@@ -12104,7 +11957,7 @@ const proteinAlphabet = {
12104
11957
  hydrophobicity: -0.7,
12105
11958
  colorByFamily: "#90EE90",
12106
11959
  color: "hsl(299.8, 100%, 69%)",
12107
- mass: 119.1
11960
+ mass: 101.10388
12108
11961
  },
12109
11962
  U: {
12110
11963
  value: "U",
@@ -12112,7 +11965,7 @@ const proteinAlphabet = {
12112
11965
  threeLettersName: "Sec",
12113
11966
  colorByFamily: "#FF0000",
12114
11967
  color: "hsl(0, 100%, 69%)",
12115
- mass: 168.1
11968
+ mass: 150.3079
12116
11969
  },
12117
11970
  W: {
12118
11971
  value: "W",
@@ -12121,7 +11974,7 @@ const proteinAlphabet = {
12121
11974
  hydrophobicity: -0.9,
12122
11975
  colorByFamily: "#FFA500",
12123
11976
  color: "hsl(297.6, 100%, 69%)",
12124
- mass: 204.2
11977
+ mass: 186.2099
12125
11978
  },
12126
11979
  Y: {
12127
11980
  value: "Y",
@@ -12130,7 +11983,7 @@ const proteinAlphabet = {
12130
11983
  hydrophobicity: -1.3,
12131
11984
  colorByFamily: "#FFA500",
12132
11985
  color: "hsl(293.2, 100%, 69%)",
12133
- mass: 181.2
11986
+ mass: 163.17326
12134
11987
  },
12135
11988
  V: {
12136
11989
  value: "V",
@@ -12139,7 +11992,7 @@ const proteinAlphabet = {
12139
11992
  hydrophobicity: 4.2,
12140
11993
  colorByFamily: "#00FFFF",
12141
11994
  color: "hsl(353.6, 100%, 69%)",
12142
- mass: 117.1
11995
+ mass: 99.13106
12143
11996
  },
12144
11997
  "*": {
12145
11998
  value: "*",
@@ -12468,20 +12321,91 @@ const modifiableTypes = [
12468
12321
  "primers",
12469
12322
  "guides"
12470
12323
  ];
12471
- function filterSequenceString(sequenceString, additionalValidChars = "", charOverrides) {
12472
- if (sequenceString) {
12473
- return sequenceString.replace(
12474
- new RegExp(
12475
- `[^${charOverrides || `atgcyrswkmbvdhnu${additionalValidChars.split("").join("\\")}`}]`,
12476
- "gi"
12477
- ),
12478
- ""
12324
+ function filterSequenceString(sequenceString, {
12325
+ additionalValidChars = "",
12326
+ isOligo,
12327
+ name,
12328
+ isProtein,
12329
+ isRna,
12330
+ isMixedRnaAndDna,
12331
+ includeStopCodon
12332
+ } = {}) {
12333
+ const acceptedChars = getAcceptedChars({
12334
+ isOligo,
12335
+ isProtein,
12336
+ isRna,
12337
+ isMixedRnaAndDna,
12338
+ includeStopCodon
12339
+ });
12340
+ const replaceChars = getReplaceChars({
12341
+ isOligo,
12342
+ isProtein,
12343
+ isRna,
12344
+ isMixedRnaAndDna
12345
+ });
12346
+ let sanitizedVal = "";
12347
+ const invalidChars = [];
12348
+ const chars = `${acceptedChars}${additionalValidChars.split("").join("\\")}`;
12349
+ const warnings = [];
12350
+ const replaceCount = {};
12351
+ sequenceString.split("").forEach((letter) => {
12352
+ const lowerLetter = letter.toLowerCase();
12353
+ if (replaceChars && replaceChars[lowerLetter]) {
12354
+ if (!replaceCount[lowerLetter]) {
12355
+ replaceCount[lowerLetter] = 0;
12356
+ }
12357
+ replaceCount[lowerLetter]++;
12358
+ const isUpper = lowerLetter !== letter;
12359
+ sanitizedVal += isUpper ? replaceChars[lowerLetter].toUpperCase() : replaceChars[lowerLetter];
12360
+ } else if (chars.includes(lowerLetter)) {
12361
+ sanitizedVal += letter;
12362
+ } else {
12363
+ invalidChars.push(letter);
12364
+ }
12365
+ });
12366
+ Object.keys(replaceCount).forEach((letter) => {
12367
+ warnings.push(
12368
+ `Replaced "${letter}" with "${replaceChars[letter]}"${replaceCount[letter] > 1 ? ` ${replaceCount[letter]} times` : ""}`
12479
12369
  );
12480
- } else {
12481
- return sequenceString;
12370
+ });
12371
+ if (sequenceString.length !== sanitizedVal.length) {
12372
+ warnings.push(
12373
+ `${name ? `Sequence ${name}: ` : ""}Invalid character(s) detected and removed: ${invalidChars.slice(0, 100).join(", ")} `
12374
+ );
12375
+ }
12376
+ if (typeof window !== "undefined" && window.toastr && warnings.length) {
12377
+ warnings.forEach((warning) => {
12378
+ window.toastr.warning(warning);
12379
+ });
12482
12380
  }
12381
+ return [sanitizedVal, warnings];
12483
12382
  }
12484
12383
  __name(filterSequenceString, "filterSequenceString");
12384
+ function getAcceptedChars({
12385
+ isOligo,
12386
+ isProtein,
12387
+ isRna,
12388
+ isMixedRnaAndDna,
12389
+ includeStopCodon
12390
+ } = {}) {
12391
+ 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() : (
12392
+ //just plain old dna
12393
+ ambiguous_rna_letters.toLowerCase() + ambiguous_dna_letters.toLowerCase()
12394
+ );
12395
+ }
12396
+ __name(getAcceptedChars, "getAcceptedChars");
12397
+ function getReplaceChars({
12398
+ isOligo,
12399
+ isProtein,
12400
+ isRna,
12401
+ isMixedRnaAndDna
12402
+ } = {}) {
12403
+ return isProtein ? {} : isOligo ? {} : isRna ? { t: "u" } : isMixedRnaAndDna ? {} : (
12404
+ //just plain old dna
12405
+ {}
12406
+ );
12407
+ }
12408
+ __name(getReplaceChars, "getReplaceChars");
12485
12409
  function tidyUpAnnotation(_annotation, {
12486
12410
  sequenceData = {},
12487
12411
  convertAnnotationsFromAAIndices,
@@ -12594,13 +12518,13 @@ function coerceLocation({
12594
12518
  messages.push(
12595
12519
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
12596
12520
  );
12597
- location.start = size - (isProtein ? 3 : 1);
12521
+ location.start = Math.max(0, size - (isProtein ? 3 : 1));
12598
12522
  }
12599
12523
  if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
12600
12524
  messages.push(
12601
12525
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
12602
12526
  );
12603
- location.end = size - 1;
12527
+ location.end = Math.max(0, size - 1);
12604
12528
  }
12605
12529
  if (location.start > location.end && circular === false) {
12606
12530
  messages.push(
@@ -12610,14 +12534,6 @@ function coerceLocation({
12610
12534
  }
12611
12535
  }
12612
12536
  __name(coerceLocation, "coerceLocation");
12613
- function filterAminoAcidSequenceString(sequenceString, options) {
12614
- options = options || {};
12615
- if (options.includeStopCodon) {
12616
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
12617
- }
12618
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
12619
- }
12620
- __name(filterAminoAcidSequenceString, "filterAminoAcidSequenceString");
12621
12537
  function getDegenerateDnaStringFromAAString(aaString) {
12622
12538
  return aaString.split("").map((char) => aminoAcidToDegenerateDnaMap[char.toLowerCase()] || "nnn").join("");
12623
12539
  }
@@ -12629,11 +12545,10 @@ function tidyUpSequenceData(pSeqData, options = {}) {
12629
12545
  removeUnwantedChars,
12630
12546
  additionalValidChars,
12631
12547
  noTranslationData,
12632
- charOverrides,
12633
12548
  doNotProvideIdsForAnnotations,
12634
- proteinFilterOptions,
12635
12549
  noCdsTranslations,
12636
- convertAnnotationsFromAAIndices
12550
+ convertAnnotationsFromAAIndices,
12551
+ topLevelSeqData
12637
12552
  } = options;
12638
12553
  let seqData = lodashExports.cloneDeep(pSeqData);
12639
12554
  const response = {
@@ -12663,16 +12578,15 @@ function tidyUpSequenceData(pSeqData, options = {}) {
12663
12578
  }
12664
12579
  if (removeUnwantedChars) {
12665
12580
  if (seqData.isProtein) {
12666
- seqData.proteinSequence = filterAminoAcidSequenceString(
12667
- seqData.proteinSequence,
12668
- __spreadValues({ includeStopCodon: true }, proteinFilterOptions)
12669
- );
12581
+ const [newSeq] = filterSequenceString(seqData.proteinSequence, __spreadValues({
12582
+ includeStopCodon: true
12583
+ }, topLevelSeqData || seqData));
12584
+ seqData.proteinSequence = newSeq;
12670
12585
  } else {
12671
- seqData.sequence = filterSequenceString(
12672
- seqData.sequence,
12673
- `${additionalValidChars || ""}${seqData.isRna || seqData.isMixedRnaAndDna ? "u" : ""}`,
12674
- charOverrides
12675
- );
12586
+ const [newSeq] = filterSequenceString(seqData.sequence, __spreadValues({
12587
+ additionalValidChars
12588
+ }, topLevelSeqData || seqData));
12589
+ seqData.sequence = newSeq;
12676
12590
  }
12677
12591
  }
12678
12592
  if (seqData.isProtein) {
@@ -13106,7 +13020,7 @@ const calcTmMethods = {
13106
13020
  calculateTemperature: function(sequence, type, A, R, C, Na) {
13107
13021
  if (typeof type === "undefined") {
13108
13022
  type = this.TABLE_BRESLAUER;
13109
- } else if (type != this.TABLE_BRESLAUER && (type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO)) {
13023
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
13110
13024
  throw new Error("Invalid table type!");
13111
13025
  }
13112
13026
  if (!A) {
@@ -21468,12 +21382,7 @@ function findSequenceMatches(sequence, searchString, options = {}) {
21468
21382
  }
21469
21383
  __name(findSequenceMatches, "findSequenceMatches");
21470
21384
  function findSequenceMatchesTopStrand(sequence, searchString, options = {}) {
21471
- const {
21472
- isCircular,
21473
- isAmbiguous,
21474
- isProteinSequence,
21475
- isProteinSearch
21476
- } = options;
21385
+ const { isCircular, isAmbiguous, isProteinSequence, isProteinSearch } = options;
21477
21386
  let searchStringToUse = escapeStringRegexp(searchString);
21478
21387
  if (isAmbiguous) {
21479
21388
  if (isProteinSearch || isProteinSequence) {
@@ -21606,7 +21515,10 @@ function getComplementAminoAcidStringFromSequenceString(sequenceString) {
21606
21515
  __name(getComplementAminoAcidStringFromSequenceString, "getComplementAminoAcidStringFromSequenceString");
21607
21516
  function getComplementSequenceString(sequence, isRna) {
21608
21517
  let complementSeqString = "";
21609
- const complementMap = lodashExports.merge(DNAComplementMap, isRna ? { a: "u", A: "U" } : { a: "t", A: "T" });
21518
+ const complementMap = lodashExports.merge(
21519
+ DNAComplementMap,
21520
+ isRna ? { a: "u", A: "U" } : { a: "t", A: "T" }
21521
+ );
21610
21522
  for (let i = 0; i < sequence.length; i++) {
21611
21523
  let complementChar = complementMap[sequence[i]];
21612
21524
  if (!complementChar) {
@@ -21910,7 +21822,9 @@ function getReverseAminoAcidStringFromSequenceString(sequenceString) {
21910
21822
  }
21911
21823
  __name(getReverseAminoAcidStringFromSequenceString, "getReverseAminoAcidStringFromSequenceString");
21912
21824
  function getReverseComplementAminoAcidStringFromSequenceString(sequenceString) {
21913
- return getAminoAcidStringFromSequenceString(getReverseComplementSequenceString(sequenceString));
21825
+ return getAminoAcidStringFromSequenceString(
21826
+ getReverseComplementSequenceString(sequenceString)
21827
+ );
21914
21828
  }
21915
21829
  __name(getReverseComplementAminoAcidStringFromSequenceString, "getReverseComplementAminoAcidStringFromSequenceString");
21916
21830
  function getReverseComplementAnnotation(annotation, sequenceLength) {
@@ -22760,6 +22674,9 @@ function getMassOfAaString(aaString, numsAfterDecimal = 2, divideByThree = false
22760
22674
  if (divideByThree) {
22761
22675
  sumMass /= 3;
22762
22676
  }
22677
+ if (aaString.length > 0) {
22678
+ sumMass = sumMass + 18.0153;
22679
+ }
22763
22680
  return Math.round(sumMass * __pow(10, numsAfterDecimal)) / __pow(10, numsAfterDecimal);
22764
22681
  }
22765
22682
  __name(getMassOfAaString, "getMassOfAaString");
@@ -22810,7 +22727,6 @@ export {
22810
22727
  deleteSequenceDataAtRange,
22811
22728
  doesEnzymeChopOutsideOfRecognitionSite,
22812
22729
  featureColors,
22813
- filterAminoAcidSequenceString,
22814
22730
  filterSequenceString,
22815
22731
  findNearestRangeOfSequenceOverlapToPosition,
22816
22732
  findOrfsInPlasmid,