@teselagen/bio-parsers 0.3.8 → 0.3.10

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.
package/index.mjs CHANGED
@@ -6281,8 +6281,8 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
6281
6281
  maxRangeLength
6282
6282
  );
6283
6283
  let overlaps = [];
6284
- normalizedRangeA.forEach(function(nonCircularRangeA, iA) {
6285
- normalizedRangeB.forEach(function(nonCircularRangeB, iB) {
6284
+ normalizedRangeA.forEach(function(nonCircularRangeA) {
6285
+ normalizedRangeB.forEach(function(nonCircularRangeB) {
6286
6286
  const overlap = getOverlapOfNonCircularRanges(
6287
6287
  nonCircularRangeA,
6288
6288
  nonCircularRangeB
@@ -6294,7 +6294,7 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
6294
6294
  });
6295
6295
  if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
6296
6296
  const joinedOverlap = {};
6297
- overlaps = lodashExports.flatMap(overlaps, (o, i) => {
6297
+ overlaps = lodashExports.flatMap(overlaps, (o) => {
6298
6298
  if (o.start === 0) {
6299
6299
  joinedOverlap.end = o.end;
6300
6300
  return [];
@@ -6392,12 +6392,14 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
6392
6392
  });
6393
6393
  splitRangesToBeTrimmed[index] = nonCircularRangeToBeTrimmed;
6394
6394
  });
6395
- const outputSplitRanges = splitRangesToBeTrimmed.filter(function(trimmedRange) {
6396
- if (trimmedRange) {
6397
- return true;
6395
+ const outputSplitRanges = splitRangesToBeTrimmed.filter(
6396
+ function(trimmedRange) {
6397
+ if (trimmedRange) {
6398
+ return true;
6399
+ }
6400
+ return false;
6398
6401
  }
6399
- return false;
6400
- });
6402
+ );
6401
6403
  let outputTrimmedRange;
6402
6404
  if (outputSplitRanges.length < 0)
6403
6405
  ;
@@ -6447,8 +6449,14 @@ function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPo
6447
6449
  __name(normalizePositionByRangeLength, "normalizePositionByRangeLength");
6448
6450
  function translateRange(rangeToBeAdjusted, translateBy, rangeLength) {
6449
6451
  return lodashExports.assign({}, rangeToBeAdjusted, {
6450
- start: normalizePositionByRangeLength(rangeToBeAdjusted.start + translateBy, rangeLength),
6451
- end: normalizePositionByRangeLength(rangeToBeAdjusted.end + translateBy, rangeLength)
6452
+ start: normalizePositionByRangeLength(
6453
+ rangeToBeAdjusted.start + translateBy,
6454
+ rangeLength
6455
+ ),
6456
+ end: normalizePositionByRangeLength(
6457
+ rangeToBeAdjusted.end + translateBy,
6458
+ rangeLength
6459
+ )
6452
6460
  });
6453
6461
  }
6454
6462
  __name(translateRange, "translateRange");
@@ -10765,7 +10773,7 @@ const proteinAlphabet = {
10765
10773
  hydrophobicity: 1.8,
10766
10774
  colorByFamily: "#00FFFF",
10767
10775
  color: "hsl(327.3, 100%, 69%)",
10768
- mass: 89.1
10776
+ mass: 71.0779
10769
10777
  },
10770
10778
  R: {
10771
10779
  value: "R",
@@ -10774,7 +10782,7 @@ const proteinAlphabet = {
10774
10782
  hydrophobicity: -4.5,
10775
10783
  colorByFamily: "#FFC0CB",
10776
10784
  color: "hsl(258.1, 100%, 69%)",
10777
- mass: 174.2
10785
+ mass: 156.18568
10778
10786
  },
10779
10787
  N: {
10780
10788
  value: "N",
@@ -10783,7 +10791,7 @@ const proteinAlphabet = {
10783
10791
  hydrophobicity: -3.5,
10784
10792
  colorByFamily: "#D3D3D3",
10785
10793
  color: "hsl(268.9, 100%, 69%)",
10786
- mass: 132.1
10794
+ mass: 114.10264
10787
10795
  },
10788
10796
  D: {
10789
10797
  value: "D",
@@ -10792,7 +10800,7 @@ const proteinAlphabet = {
10792
10800
  hydrophobicity: -3.5,
10793
10801
  colorByFamily: "#EE82EE",
10794
10802
  color: "hsl(268.9, 100%, 69%)",
10795
- mass: 133.1
10803
+ mass: 115.0874
10796
10804
  },
10797
10805
  C: {
10798
10806
  value: "C",
@@ -10801,7 +10809,7 @@ const proteinAlphabet = {
10801
10809
  hydrophobicity: 2.5,
10802
10810
  colorByFamily: "#FFFF00",
10803
10811
  color: "hsl(335.1, 100%, 69%)",
10804
- mass: 121.2
10812
+ mass: 103.1429
10805
10813
  },
10806
10814
  E: {
10807
10815
  value: "E",
@@ -10810,7 +10818,7 @@ const proteinAlphabet = {
10810
10818
  hydrophobicity: -3.5,
10811
10819
  colorByFamily: "#EE82EE",
10812
10820
  color: "hsl(268.9, 100%, 69%)",
10813
- mass: 147.1
10821
+ mass: 129.11398
10814
10822
  },
10815
10823
  Q: {
10816
10824
  value: "Q",
@@ -10819,7 +10827,7 @@ const proteinAlphabet = {
10819
10827
  hydrophobicity: -3.5,
10820
10828
  colorByFamily: "#D3D3D3",
10821
10829
  color: "hsl(268.9, 100%, 69%)",
10822
- mass: 146.2
10830
+ mass: 128.12922
10823
10831
  },
10824
10832
  G: {
10825
10833
  value: "G",
@@ -10828,7 +10836,7 @@ const proteinAlphabet = {
10828
10836
  hydrophobicity: -0.4,
10829
10837
  colorByFamily: "#00FFFF",
10830
10838
  color: "hsl(303.1, 100%, 69%)",
10831
- mass: 75.1
10839
+ mass: 57.05132
10832
10840
  },
10833
10841
  H: {
10834
10842
  value: "H",
@@ -10837,7 +10845,7 @@ const proteinAlphabet = {
10837
10845
  hydrophobicity: -3.2,
10838
10846
  colorByFamily: "#FFC0CB",
10839
10847
  color: "hsl(272.2, 100%, 69%)",
10840
- mass: 155.2
10848
+ mass: 137.13928
10841
10849
  },
10842
10850
  I: {
10843
10851
  value: "I",
@@ -10846,7 +10854,7 @@ const proteinAlphabet = {
10846
10854
  hydrophobicity: 4.5,
10847
10855
  colorByFamily: "#00FFFF",
10848
10856
  color: "hsl(356.9, 100%, 69%)",
10849
- mass: 131.2
10857
+ mass: 113.15764
10850
10858
  },
10851
10859
  L: {
10852
10860
  value: "L",
@@ -10855,7 +10863,7 @@ const proteinAlphabet = {
10855
10863
  hydrophobicity: 3.8,
10856
10864
  colorByFamily: "#00FFFF",
10857
10865
  color: "hsl(349.4, 100%, 69%)",
10858
- mass: 131.2
10866
+ mass: 113.15764
10859
10867
  },
10860
10868
  K: {
10861
10869
  value: "K",
@@ -10864,7 +10872,7 @@ const proteinAlphabet = {
10864
10872
  hydrophobicity: -3.9,
10865
10873
  colorByFamily: "#FFC0CB",
10866
10874
  color: "hsl(264.7, 100%, 69%)",
10867
- mass: 146.2
10875
+ mass: 128.17228
10868
10876
  },
10869
10877
  M: {
10870
10878
  value: "M",
@@ -10873,7 +10881,7 @@ const proteinAlphabet = {
10873
10881
  hydrophobicity: 1.9,
10874
10882
  colorByFamily: "#FFFF00",
10875
10883
  color: "hsl(328.5, 100%, 69%)",
10876
- mass: 149.2
10884
+ mass: 131.19606
10877
10885
  },
10878
10886
  F: {
10879
10887
  value: "F",
@@ -10882,7 +10890,7 @@ const proteinAlphabet = {
10882
10890
  hydrophobicity: 2.8,
10883
10891
  colorByFamily: "#FFA500",
10884
10892
  color: "hsl(338.4, 100%, 69%)",
10885
- mass: 165.2
10893
+ mass: 147.17386
10886
10894
  },
10887
10895
  P: {
10888
10896
  value: "P",
@@ -10891,7 +10899,7 @@ const proteinAlphabet = {
10891
10899
  hydrophobicity: -1.6,
10892
10900
  colorByFamily: "#00FFFF",
10893
10901
  color: "hsl(289.9, 100%, 69%)",
10894
- mass: 115.1
10902
+ mass: 97.11518
10895
10903
  },
10896
10904
  S: {
10897
10905
  value: "S",
@@ -10900,7 +10908,7 @@ const proteinAlphabet = {
10900
10908
  hydrophobicity: -0.8,
10901
10909
  colorByFamily: "#90EE90",
10902
10910
  color: "hsl(298.6, 100%, 69%)",
10903
- mass: 105.1
10911
+ mass: 87.0773
10904
10912
  },
10905
10913
  T: {
10906
10914
  value: "T",
@@ -10909,7 +10917,7 @@ const proteinAlphabet = {
10909
10917
  hydrophobicity: -0.7,
10910
10918
  colorByFamily: "#90EE90",
10911
10919
  color: "hsl(299.8, 100%, 69%)",
10912
- mass: 119.1
10920
+ mass: 101.10388
10913
10921
  },
10914
10922
  U: {
10915
10923
  value: "U",
@@ -10917,7 +10925,7 @@ const proteinAlphabet = {
10917
10925
  threeLettersName: "Sec",
10918
10926
  colorByFamily: "#FF0000",
10919
10927
  color: "hsl(0, 100%, 69%)",
10920
- mass: 168.1
10928
+ mass: 150.3079
10921
10929
  },
10922
10930
  W: {
10923
10931
  value: "W",
@@ -10926,7 +10934,7 @@ const proteinAlphabet = {
10926
10934
  hydrophobicity: -0.9,
10927
10935
  colorByFamily: "#FFA500",
10928
10936
  color: "hsl(297.6, 100%, 69%)",
10929
- mass: 204.2
10937
+ mass: 186.2099
10930
10938
  },
10931
10939
  Y: {
10932
10940
  value: "Y",
@@ -10935,7 +10943,7 @@ const proteinAlphabet = {
10935
10943
  hydrophobicity: -1.3,
10936
10944
  colorByFamily: "#FFA500",
10937
10945
  color: "hsl(293.2, 100%, 69%)",
10938
- mass: 181.2
10946
+ mass: 163.17326
10939
10947
  },
10940
10948
  V: {
10941
10949
  value: "V",
@@ -10944,7 +10952,7 @@ const proteinAlphabet = {
10944
10952
  hydrophobicity: 4.2,
10945
10953
  colorByFamily: "#00FFFF",
10946
10954
  color: "hsl(353.6, 100%, 69%)",
10947
- mass: 117.1
10955
+ mass: 99.13106
10948
10956
  },
10949
10957
  "*": {
10950
10958
  value: "*",
@@ -11389,13 +11397,13 @@ function coerceLocation({
11389
11397
  messages.push(
11390
11398
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
11391
11399
  );
11392
- location.start = size - (isProtein ? 3 : 1);
11400
+ location.start = Math.max(0, size - (isProtein ? 3 : 1));
11393
11401
  }
11394
11402
  if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
11395
11403
  messages.push(
11396
11404
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
11397
11405
  );
11398
- location.end = size - 1;
11406
+ location.end = Math.max(0, size - 1);
11399
11407
  }
11400
11408
  if (location.start > location.end && circular === false) {
11401
11409
  messages.push(
@@ -11408,9 +11416,9 @@ __name(coerceLocation, "coerceLocation");
11408
11416
  function filterAminoAcidSequenceString(sequenceString, options) {
11409
11417
  options = options || {};
11410
11418
  if (options.includeStopCodon) {
11411
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
11419
+ return sequenceString == null ? void 0 : sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
11412
11420
  }
11413
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
11421
+ return sequenceString == null ? void 0 : sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
11414
11422
  }
11415
11423
  __name(filterAminoAcidSequenceString, "filterAminoAcidSequenceString");
11416
11424
  function getDegenerateDnaStringFromAAString(aaString) {
@@ -11608,7 +11616,7 @@ const calcTmMethods = {
11608
11616
  calculateTemperature: function(sequence, type, A, R, C, Na) {
11609
11617
  if (typeof type === "undefined") {
11610
11618
  type = this.TABLE_BRESLAUER;
11611
- } else if (type != this.TABLE_BRESLAUER && (type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO)) {
11619
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
11612
11620
  throw new Error("Invalid table type!");
11613
11621
  }
11614
11622
  if (!A) {
@@ -19759,18 +19767,20 @@ function genbankToJson(string, options = {}) {
19759
19767
  const isKeyRunon = isKeywordRunon(line);
19760
19768
  const isSubKey = isSubKeyword(line);
19761
19769
  const isKey = isKeyword(line);
19762
- if (key === "LOCUS") {
19763
- LINETYPE = key;
19764
- } else if (key === "REFERENCE") {
19765
- LINETYPE = key;
19766
- } else if (key === "FEATURES") {
19767
- LINETYPE = key;
19768
- } else if (key === "ORIGIN") {
19769
- LINETYPE = key;
19770
- } else if (key === "//") {
19771
- LINETYPE = key;
19772
- } else if (isKey === true) {
19773
- LINETYPE = key;
19770
+ if (!isKeyRunon) {
19771
+ if (key === "LOCUS") {
19772
+ LINETYPE = key;
19773
+ } else if (key === "REFERENCE") {
19774
+ LINETYPE = key;
19775
+ } else if (key === "FEATURES") {
19776
+ LINETYPE = key;
19777
+ } else if (key === "ORIGIN") {
19778
+ LINETYPE = key;
19779
+ } else if (key === "//") {
19780
+ LINETYPE = key;
19781
+ } else if (isKey === true) {
19782
+ LINETYPE = key;
19783
+ }
19774
19784
  }
19775
19785
  if (line.trim() === "" || key === ";") {
19776
19786
  return false;
@@ -19939,7 +19949,6 @@ function genbankToJson(string, options = {}) {
19939
19949
  __name(parseOrigin, "parseOrigin");
19940
19950
  function parseLocus(line) {
19941
19951
  result = createInitialSequence(options);
19942
- let locusName;
19943
19952
  let circular;
19944
19953
  let gbDivision;
19945
19954
  let date;
@@ -19950,7 +19959,7 @@ function genbankToJson(string, options = {}) {
19950
19959
  );
19951
19960
  addMessage("Import Warning: Locus line contains no values: " + line);
19952
19961
  }
19953
- locusName = lineArr[1];
19962
+ const locusName = lineArr[1];
19954
19963
  for (let i = 1; i < lineArr.length; i++) {
19955
19964
  if (lineArr[i].match(/circular/gi)) {
19956
19965
  circular = true;
@@ -20103,10 +20112,10 @@ function genbankToJson(string, options = {}) {
20103
20112
  }
20104
20113
  __name(parseFeatureLocation, "parseFeatureLocation");
20105
20114
  function parseFeatureNote(line) {
20106
- let newLine, lineArr;
20115
+ let newLine;
20107
20116
  newLine = line.trimLeft();
20108
20117
  newLine = newLine.replace(/^\/|"$/g, "");
20109
- lineArr = newLine.split(/="|=/);
20118
+ const lineArr = newLine.split(/="|=/);
20110
20119
  let val2 = lineArr.slice(1).join("=");
20111
20120
  if (val2) {
20112
20121
  val2 = val2.replace(/\\/g, " ");
@@ -29912,13 +29921,10 @@ function geneiousXmlToJson(string, options) {
29912
29921
  });
29913
29922
  }
29914
29923
  });
29915
- const toRet = lodashExports.filter(
29916
- resultArray,
29917
- (r) => {
29918
- var _a3, _b3;
29919
- return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
29920
- }
29921
- );
29924
+ const toRet = lodashExports.filter(resultArray, (r) => {
29925
+ var _a3, _b3;
29926
+ return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
29927
+ });
29922
29928
  if (toRet.length)
29923
29929
  return toRet;
29924
29930
  return onFileParsed(resultArray);
@@ -30023,13 +30029,10 @@ function jbeiXmlToJson(string, options) {
30023
30029
  messages: ["Error while parsing JBEI format"]
30024
30030
  });
30025
30031
  }
30026
- const toRet = lodashExports.filter(
30027
- resultArray,
30028
- (r) => {
30029
- var _a3, _b3;
30030
- return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
30031
- }
30032
- );
30032
+ const toRet = lodashExports.filter(resultArray, (r) => {
30033
+ var _a3, _b3;
30034
+ return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
30035
+ });
30033
30036
  if (toRet.length)
30034
30037
  return toRet;
30035
30038
  return onFileParsed(resultArray);
@@ -32413,7 +32416,6 @@ function createGenbankLocus(serSeq, options) {
32413
32416
  if (serSeq.sequence.symbols) {
32414
32417
  serSeq.sequence = serSeq.sequence.symbols.split("");
32415
32418
  }
32416
- let tmp;
32417
32419
  let dnaType;
32418
32420
  if (serSeq.isProtein) {
32419
32421
  dnaType = "";
@@ -32430,7 +32432,7 @@ function createGenbankLocus(serSeq, options) {
32430
32432
  line += " ";
32431
32433
  line += StringUtil.lpad(String(serSeq.sequence.length), " ", 11);
32432
32434
  line += serSeq.isProtein ? " aa " : " bp ";
32433
- tmp = "";
32435
+ const tmp = "";
32434
32436
  line += StringUtil.lpad(tmp, " ", 3);
32435
32437
  line += StringUtil.rpad(dnaType, " ", 6);
32436
32438
  line += " ";