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