@teselagen/bio-parsers 0.3.8 → 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.
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");
@@ -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 += " ";
package/index.umd.js CHANGED
@@ -6285,8 +6285,8 @@ var __async = (__this, __arguments, generator) => {
6285
6285
  maxRangeLength
6286
6286
  );
6287
6287
  let overlaps = [];
6288
- normalizedRangeA.forEach(function(nonCircularRangeA, iA) {
6289
- normalizedRangeB.forEach(function(nonCircularRangeB, iB) {
6288
+ normalizedRangeA.forEach(function(nonCircularRangeA) {
6289
+ normalizedRangeB.forEach(function(nonCircularRangeB) {
6290
6290
  const overlap = getOverlapOfNonCircularRanges(
6291
6291
  nonCircularRangeA,
6292
6292
  nonCircularRangeB
@@ -6298,7 +6298,7 @@ var __async = (__this, __arguments, generator) => {
6298
6298
  });
6299
6299
  if (joinIfPossible && normalizedRangeA.length === 2 && normalizedRangeB.length === 2 && maxRangeLength) {
6300
6300
  const joinedOverlap = {};
6301
- overlaps = lodashExports.flatMap(overlaps, (o, i2) => {
6301
+ overlaps = lodashExports.flatMap(overlaps, (o) => {
6302
6302
  if (o.start === 0) {
6303
6303
  joinedOverlap.end = o.end;
6304
6304
  return [];
@@ -6396,12 +6396,14 @@ var __async = (__this, __arguments, generator) => {
6396
6396
  });
6397
6397
  splitRangesToBeTrimmed[index] = nonCircularRangeToBeTrimmed;
6398
6398
  });
6399
- const outputSplitRanges = splitRangesToBeTrimmed.filter(function(trimmedRange) {
6400
- if (trimmedRange) {
6401
- return true;
6399
+ const outputSplitRanges = splitRangesToBeTrimmed.filter(
6400
+ function(trimmedRange) {
6401
+ if (trimmedRange) {
6402
+ return true;
6403
+ }
6404
+ return false;
6402
6405
  }
6403
- return false;
6404
- });
6406
+ );
6405
6407
  let outputTrimmedRange;
6406
6408
  if (outputSplitRanges.length < 0)
6407
6409
  ;
@@ -6451,8 +6453,14 @@ var __async = (__this, __arguments, generator) => {
6451
6453
  __name(normalizePositionByRangeLength, "normalizePositionByRangeLength");
6452
6454
  function translateRange(rangeToBeAdjusted, translateBy, rangeLength) {
6453
6455
  return lodashExports.assign({}, rangeToBeAdjusted, {
6454
- start: normalizePositionByRangeLength(rangeToBeAdjusted.start + translateBy, rangeLength),
6455
- end: normalizePositionByRangeLength(rangeToBeAdjusted.end + translateBy, rangeLength)
6456
+ start: normalizePositionByRangeLength(
6457
+ rangeToBeAdjusted.start + translateBy,
6458
+ rangeLength
6459
+ ),
6460
+ end: normalizePositionByRangeLength(
6461
+ rangeToBeAdjusted.end + translateBy,
6462
+ rangeLength
6463
+ )
6456
6464
  });
6457
6465
  }
6458
6466
  __name(translateRange, "translateRange");
@@ -11393,13 +11401,13 @@ var __async = (__this, __arguments, generator) => {
11393
11401
  messages.push(
11394
11402
  "Invalid annotation start: " + location.start + " detected for " + location.name + " and set to size: " + size
11395
11403
  );
11396
- location.start = size - (isProtein ? 3 : 1);
11404
+ location.start = Math.max(0, size - (isProtein ? 3 : 1));
11397
11405
  }
11398
11406
  if (location.end < 0 || !(location.end <= size - 1) || location.end > size - 1) {
11399
11407
  messages.push(
11400
11408
  "Invalid annotation end: " + location.end + " detected for " + location.name + " and set to seq size: " + size
11401
11409
  );
11402
- location.end = size - 1;
11410
+ location.end = Math.max(0, size - 1);
11403
11411
  }
11404
11412
  if (location.start > location.end && circular === false) {
11405
11413
  messages.push(
@@ -11412,9 +11420,9 @@ var __async = (__this, __arguments, generator) => {
11412
11420
  function filterAminoAcidSequenceString(sequenceString, options) {
11413
11421
  options = options || {};
11414
11422
  if (options.includeStopCodon) {
11415
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
11423
+ return sequenceString == null ? void 0 : sequenceString.replace(/[^xtgalmfwkqespvicyhrndu.*]/gi, "");
11416
11424
  }
11417
- return sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
11425
+ return sequenceString == null ? void 0 : sequenceString.replace(/[^xtgalmfwkqespvicyhrndu]/gi, "");
11418
11426
  }
11419
11427
  __name(filterAminoAcidSequenceString, "filterAminoAcidSequenceString");
11420
11428
  function getDegenerateDnaStringFromAAString(aaString) {
@@ -11612,7 +11620,7 @@ var __async = (__this, __arguments, generator) => {
11612
11620
  calculateTemperature: function(sequence, type, A, R, C, Na) {
11613
11621
  if (typeof type === "undefined") {
11614
11622
  type = this.TABLE_BRESLAUER;
11615
- } else if (type != this.TABLE_BRESLAUER && (type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO)) {
11623
+ } else if (type != this.TABLE_BRESLAUER && type != this.TABLE_UNIFIED && type != this.TABLE_SUGIMOTO) {
11616
11624
  throw new Error("Invalid table type!");
11617
11625
  }
11618
11626
  if (!A) {
@@ -19763,18 +19771,20 @@ var __async = (__this, __arguments, generator) => {
19763
19771
  const isKeyRunon = isKeywordRunon(line);
19764
19772
  const isSubKey = isSubKeyword(line);
19765
19773
  const isKey = isKeyword(line);
19766
- if (key === "LOCUS") {
19767
- LINETYPE = key;
19768
- } else if (key === "REFERENCE") {
19769
- LINETYPE = key;
19770
- } else if (key === "FEATURES") {
19771
- LINETYPE = key;
19772
- } else if (key === "ORIGIN") {
19773
- LINETYPE = key;
19774
- } else if (key === "//") {
19775
- LINETYPE = key;
19776
- } else if (isKey === true) {
19777
- LINETYPE = key;
19774
+ if (!isKeyRunon) {
19775
+ if (key === "LOCUS") {
19776
+ LINETYPE = key;
19777
+ } else if (key === "REFERENCE") {
19778
+ LINETYPE = key;
19779
+ } else if (key === "FEATURES") {
19780
+ LINETYPE = key;
19781
+ } else if (key === "ORIGIN") {
19782
+ LINETYPE = key;
19783
+ } else if (key === "//") {
19784
+ LINETYPE = key;
19785
+ } else if (isKey === true) {
19786
+ LINETYPE = key;
19787
+ }
19778
19788
  }
19779
19789
  if (line.trim() === "" || key === ";") {
19780
19790
  return false;
@@ -19943,7 +19953,6 @@ var __async = (__this, __arguments, generator) => {
19943
19953
  __name(parseOrigin, "parseOrigin");
19944
19954
  function parseLocus(line) {
19945
19955
  result = createInitialSequence(options);
19946
- let locusName;
19947
19956
  let circular;
19948
19957
  let gbDivision;
19949
19958
  let date;
@@ -19954,7 +19963,7 @@ var __async = (__this, __arguments, generator) => {
19954
19963
  );
19955
19964
  addMessage("Import Warning: Locus line contains no values: " + line);
19956
19965
  }
19957
- locusName = lineArr[1];
19966
+ const locusName = lineArr[1];
19958
19967
  for (let i2 = 1; i2 < lineArr.length; i2++) {
19959
19968
  if (lineArr[i2].match(/circular/gi)) {
19960
19969
  circular = true;
@@ -20107,10 +20116,10 @@ var __async = (__this, __arguments, generator) => {
20107
20116
  }
20108
20117
  __name(parseFeatureLocation, "parseFeatureLocation");
20109
20118
  function parseFeatureNote(line) {
20110
- let newLine, lineArr;
20119
+ let newLine;
20111
20120
  newLine = line.trimLeft();
20112
20121
  newLine = newLine.replace(/^\/|"$/g, "");
20113
- lineArr = newLine.split(/="|=/);
20122
+ const lineArr = newLine.split(/="|=/);
20114
20123
  let val2 = lineArr.slice(1).join("=");
20115
20124
  if (val2) {
20116
20125
  val2 = val2.replace(/\\/g, " ");
@@ -29916,13 +29925,10 @@ ${seq.sequence}
29916
29925
  });
29917
29926
  }
29918
29927
  });
29919
- const toRet = lodashExports.filter(
29920
- resultArray,
29921
- (r) => {
29922
- var _a3, _b3;
29923
- return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
29924
- }
29925
- );
29928
+ const toRet = lodashExports.filter(resultArray, (r) => {
29929
+ var _a3, _b3;
29930
+ return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
29931
+ });
29926
29932
  if (toRet.length)
29927
29933
  return toRet;
29928
29934
  return onFileParsed(resultArray);
@@ -30027,13 +30033,10 @@ ${seq.sequence}
30027
30033
  messages: ["Error while parsing JBEI format"]
30028
30034
  });
30029
30035
  }
30030
- const toRet = lodashExports.filter(
30031
- resultArray,
30032
- (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
- }
30036
- );
30036
+ const toRet = lodashExports.filter(resultArray, (r) => {
30037
+ var _a3, _b3;
30038
+ return (_b3 = (_a3 = r == null ? void 0 : r.parsedSequence) == null ? void 0 : _a3.sequence) == null ? void 0 : _b3.length;
30039
+ });
30037
30040
  if (toRet.length)
30038
30041
  return toRet;
30039
30042
  return onFileParsed(resultArray);
@@ -32417,7 +32420,6 @@ ${seq.sequence}
32417
32420
  if (serSeq.sequence.symbols) {
32418
32421
  serSeq.sequence = serSeq.sequence.symbols.split("");
32419
32422
  }
32420
- let tmp;
32421
32423
  let dnaType;
32422
32424
  if (serSeq.isProtein) {
32423
32425
  dnaType = "";
@@ -32434,7 +32436,7 @@ ${seq.sequence}
32434
32436
  line += " ";
32435
32437
  line += StringUtil.lpad(String(serSeq.sequence.length), " ", 11);
32436
32438
  line += serSeq.isProtein ? " aa " : " bp ";
32437
- tmp = "";
32439
+ const tmp = "";
32438
32440
  line += StringUtil.lpad(tmp, " ", 3);
32439
32441
  line += StringUtil.rpad(dnaType, " ", 6);
32440
32442
  line += " ";
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/bio-parsers",
3
- "version": "0.3.8",
4
- "type": "commonjs",
3
+ "version": "0.3.9",
5
4
  "dependencies": {
6
5
  "@teselagen/sequence-utils": "0.3.7",
7
6
  "@teselagen/range-utils": "0.3.7",
package/src/ab1ToJson.js CHANGED
@@ -10,7 +10,7 @@ async function ab1ToJson(fileObj, options = {}) {
10
10
  returnVal.parsedSequence = {
11
11
  ...returnVal.parsedSequence,
12
12
  sequence: chromatogramData.baseCalls.join(""),
13
- chromatogramData,
13
+ chromatogramData
14
14
  };
15
15
  return [returnVal];
16
16
  }
@@ -22,7 +22,6 @@ function abConverter(inputArrayBuffer) {
22
22
  const numElements = inputArrayBuffer.getInt32(18);
23
23
  const lastEntry = dirLocation + numElements * 28;
24
24
 
25
-
26
25
  this.getNumber = (inOffset, numEntries) => {
27
26
  const retArray = [];
28
27
  for (let counter = 0; counter < numEntries; counter += 1) {
@@ -49,8 +48,7 @@ function abConverter(inputArrayBuffer) {
49
48
  return retArray;
50
49
  };
51
50
 
52
-
53
- this.getTagName = (inOffset) => {
51
+ this.getTagName = inOffset => {
54
52
  let name = "";
55
53
  for (let loopOffset = inOffset; loopOffset < inOffset + 4; loopOffset++) {
56
54
  name += String.fromCharCode(inputArrayBuffer.getInt8(loopOffset));
@@ -58,7 +56,7 @@ function abConverter(inputArrayBuffer) {
58
56
  return name;
59
57
  };
60
58
 
61
- this.getDataTag = function(inTag) {
59
+ this.getDataTag = function (inTag) {
62
60
  let output;
63
61
  let curElem = dirLocation;
64
62
  do {
@@ -75,7 +73,7 @@ function abConverter(inputArrayBuffer) {
75
73
  return output;
76
74
  };
77
75
 
78
- this.getTraceData = function() {
76
+ this.getTraceData = function () {
79
77
  const traceData = {};
80
78
  traceData.aTrace = this.getDataTag(tagDict.colorDataA);
81
79
  traceData.tTrace = this.getDataTag(tagDict.colorDataT);
@@ -84,10 +82,10 @@ function abConverter(inputArrayBuffer) {
84
82
  traceData.basePos = this.getDataTag(tagDict.peakLocations);
85
83
  traceData.baseCalls = this.getDataTag(tagDict.baseCalls2);
86
84
  traceData.qualNums = this.getDataTag(tagDict.qualNums);
87
- if (traceData.qualNums ) {
85
+ if (traceData.qualNums) {
88
86
  //tnr if we're only getting 1's and 0's as qualNums, that means that there weren't actual qual nums attached to the file
89
- if (!traceData.qualNums.filter(q => (q!==1 && q!==0)).length) {
90
- delete traceData.qualNums
87
+ if (!traceData.qualNums.filter(q => q !== 1 && q !== 0).length) {
88
+ delete traceData.qualNums;
91
89
  }
92
90
  }
93
91
  return convertBasePosTraceToPerBpTrace(traceData);
@@ -116,11 +114,10 @@ const tagDict = {
116
114
  colorDataA: { tagName: "DATA", tagNum: 10, typeToReturn: "getShort" },
117
115
  colorDataT: { tagName: "DATA", tagNum: 11, typeToReturn: "getShort" },
118
116
  colorDataG: { tagName: "DATA", tagNum: 9, typeToReturn: "getShort" },
119
- colorDataC: { tagName: "DATA", tagNum: 12, typeToReturn: "getShort" },
117
+ colorDataC: { tagName: "DATA", tagNum: 12, typeToReturn: "getShort" }
120
118
  };
121
119
 
122
-
123
- const correctionAmount = 3
120
+ const correctionAmount = 3;
124
121
  // tnr: this function takes in chromData which has 4 traces and a basePos (which describes where in the trace the base call lands)
125
122
  // It "normalizes" that data into a baseTraces array so that each base has its own set of that data (having a per-base trace makes insertion/deletion/copy/paste actions all easier)
126
123
  function convertBasePosTraceToPerBpTrace(chromData) {
@@ -152,15 +149,15 @@ function convertBasePosTraceToPerBpTrace(chromData) {
152
149
  "gTrace",
153
150
  "cTrace"
154
151
  // eslint-disable-next-line no-loop-func
155
- ].forEach((type) => {
152
+ ].forEach(type => {
156
153
  const traceForType = tracesForType[type];
157
154
  const traceData = chromData[type];
158
155
  for (let j = startPos; j < endPos + correctionAmount; j++) {
159
156
  traceForType.push(traceData[j] || 0);
160
157
  }
161
158
  });
162
- if (i !== basePos.length-1) {
163
- startPos = endPos+correctionAmount;
159
+ if (i !== basePos.length - 1) {
160
+ startPos = endPos + correctionAmount;
164
161
  nextBasePos = basePos[i + 2];
165
162
  setEndPos();
166
163
  }
@@ -172,6 +169,4 @@ function convertBasePosTraceToPerBpTrace(chromData) {
172
169
  };
173
170
  }
174
171
 
175
- export {
176
- convertBasePosTraceToPerBpTrace
177
- }
172
+ export { convertBasePosTraceToPerBpTrace };
package/src/anyToJson.js CHANGED
@@ -132,12 +132,12 @@ async function anyToJson(fileContentStringOrFileObj, options) {
132
132
 
133
133
  //try to guess the file type based on the first non-whitespace char in the filestring
134
134
  if (firstChar === ">") {
135
- parsersToTry = parsersToTry.sort((a) => {
135
+ parsersToTry = parsersToTry.sort(a => {
136
136
  if (a.name === "Fasta Parser") return -1;
137
137
  return 1;
138
138
  });
139
139
  } else if (firstChar === "L") {
140
- parsersToTry = parsersToTry.sort((a) => {
140
+ parsersToTry = parsersToTry.sort(a => {
141
141
  if (a.name === "Genbank Parser") return -1;
142
142
  return 1;
143
143
  });
@@ -188,10 +188,10 @@ function getUtf8StringFromFile(file, { emulateBrowser } = {}) {
188
188
  const reader = new window.FileReader();
189
189
  reader.readAsText(file, "UTF-8");
190
190
  return new Promise((resolve, reject) => {
191
- reader.onload = (evt) => {
191
+ reader.onload = evt => {
192
192
  resolve(evt.target.result);
193
193
  };
194
- reader.onerror = (err) => {
194
+ reader.onerror = err => {
195
195
  console.error("err:", err);
196
196
  reject(err);
197
197
  };
@@ -212,12 +212,12 @@ function getUint8ArrayFromFile(file, { emulateBrowser } = {}) {
212
212
  reader.readAsArrayBuffer(file);
213
213
 
214
214
  return new Promise((resolve, reject) => {
215
- reader.onload = (evt) => {
215
+ reader.onload = evt => {
216
216
  const arrayBuffer = evt.target.result;
217
217
  const bytes = new Uint8Array(arrayBuffer);
218
218
  resolve(bytes);
219
219
  };
220
- reader.onerror = (err) => {
220
+ reader.onerror = err => {
221
221
  console.error("err:", err);
222
222
  reject(err);
223
223
  };
@@ -66,18 +66,20 @@ function genbankToJson(string, options = {}) {
66
66
  const isKey = isKeyword(line);
67
67
 
68
68
  //only set a new LINETYPE in the case that we've encountered a key that warrants it.
69
- if (key === "LOCUS") {
70
- LINETYPE = key;
71
- } else if (key === "REFERENCE") {
72
- LINETYPE = key;
73
- } else if (key === "FEATURES") {
74
- LINETYPE = key;
75
- } else if (key === "ORIGIN") {
76
- LINETYPE = key;
77
- } else if (key === "//") {
78
- LINETYPE = key;
79
- } else if (isKey === true) {
80
- LINETYPE = key;
69
+ if (!isKeyRunon) {
70
+ if (key === "LOCUS") {
71
+ LINETYPE = key;
72
+ } else if (key === "REFERENCE") {
73
+ LINETYPE = key;
74
+ } else if (key === "FEATURES") {
75
+ LINETYPE = key;
76
+ } else if (key === "ORIGIN") {
77
+ LINETYPE = key;
78
+ } else if (key === "//") {
79
+ LINETYPE = key;
80
+ } else if (isKey === true) {
81
+ LINETYPE = key;
82
+ }
81
83
  }
82
84
 
83
85
  // IGNORE LINES: DO NOT EVEN PROCESS
@@ -237,10 +239,10 @@ function genbankToJson(string, options = {}) {
237
239
  // default sequence json has primers at the top level separate from features, e.g. parsedSequence: { primers: [ {}, {} ], features: [ {}, {} ] }
238
240
  // if options.primersAsFeatures is set to true, primers are included in features with type set to primer
239
241
 
240
- results.forEach((result) => {
242
+ results.forEach(result => {
241
243
  if (result.success) {
242
244
  const sequence = result.parsedSequence;
243
- sequence.features.forEach((feat) => {
245
+ sequence.features.forEach(feat => {
244
246
  if (feat.type === "primer") {
245
247
  feat.type = "primer_bind";
246
248
  }
@@ -248,10 +250,10 @@ function genbankToJson(string, options = {}) {
248
250
 
249
251
  if (!options.primersAsFeatures) {
250
252
  sequence.primers = sequence.features.filter(
251
- (feat) => feat.type === "primer_bind"
253
+ feat => feat.type === "primer_bind"
252
254
  );
253
255
  sequence.features = sequence.features.filter(
254
- (feat) => feat.type !== "primer_bind"
256
+ feat => feat.type !== "primer_bind"
255
257
  );
256
258
  }
257
259
  }
@@ -298,7 +300,6 @@ function genbankToJson(string, options = {}) {
298
300
 
299
301
  function parseLocus(line) {
300
302
  result = createInitialSequence(options);
301
- let locusName;
302
303
  let circular;
303
304
 
304
305
  let gbDivision;
@@ -312,7 +313,7 @@ function genbankToJson(string, options = {}) {
312
313
  // TODO
313
314
  addMessage("Import Warning: Locus line contains no values: " + line);
314
315
  }
315
- locusName = lineArr[1];
316
+ const locusName = lineArr[1];
316
317
 
317
318
  // Linear vs Circular?
318
319
  for (let i = 1; i < lineArr.length; i++) {
@@ -525,13 +526,13 @@ function genbankToJson(string, options = {}) {
525
526
  }
526
527
 
527
528
  function parseFeatureNote(line) {
528
- let newLine, lineArr;
529
+ let newLine;
529
530
 
530
531
  // only trim file formatting spaces (i.e. the left ones)
531
532
  // spaces on the right are necessary (e.g. spacing between words, etc.)
532
533
  newLine = line.trimLeft();
533
534
  newLine = newLine.replace(/^\/|"$/g, "");
534
- lineArr = newLine.split(/="|=/);
535
+ const lineArr = newLine.split(/="|=/);
535
536
 
536
537
  let val = lineArr.slice(1).join("=");
537
538