@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/README.md +330 -0
- package/index.js +70 -68
- package/index.mjs +70 -68
- package/index.umd.js +70 -68
- package/package.json +2 -3
- package/src/ab1ToJson.js +13 -18
- package/src/anyToJson.js +6 -6
- package/src/genbankToJson.js +21 -20
- package/src/geneiousXmlToJson.js +3 -6
- package/src/gffToJson.js +5 -5
- package/src/jbeiXmlToJson.js +10 -13
- package/src/jsonToBed.js +4 -3
- package/src/jsonToFasta.js +4 -2
- package/src/jsonToGenbank.js +13 -12
- package/src/jsonToJsonString.js +1 -1
- package/src/sbolXmlToJson.js +9 -9
- package/src/snapgeneToJson.js +14 -12
- package/src/utils/NameUtils.js +1 -1
- package/src/utils/ParserUtil.js +81 -83
- package/src/utils/cleanUpTeselagenJsonForExport.js +8 -9
- package/src/utils/constants.js +22 -22
- package/src/utils/convertOldSequenceDataToNewDataType.js +5 -6
- package/src/utils/createInitialSequence.js +13 -11
- package/src/utils/extractFileExtension.js +11 -13
- package/src/utils/flattenSequenceArray.js +14 -14
- package/src/utils/getArrayBufferFromFile.js +5 -5
- package/src/utils/isBrowser.js +2 -1
- package/src/utils/parseUracilFeatures.js +2 -2
- package/src/utils/pragmasAndTypes.js +3 -2
- package/src/utils/searchWholeObjByName.js +3 -3
- package/src/utils/splitStringIntoLines.js +13 -12
- package/src/utils/validateSequence.js +9 -9
- package/src/utils/validateSequenceArray.js +17 -17
- package/utils/getArrayBufferFromFile.d.ts +1 -1
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
|
|
6289
|
-
normalizedRangeB.forEach(function(nonCircularRangeB
|
|
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
|
|
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(
|
|
6400
|
-
|
|
6401
|
-
|
|
6399
|
+
const outputSplitRanges = splitRangesToBeTrimmed.filter(
|
|
6400
|
+
function(trimmedRange) {
|
|
6401
|
+
if (trimmedRange) {
|
|
6402
|
+
return true;
|
|
6403
|
+
}
|
|
6404
|
+
return false;
|
|
6402
6405
|
}
|
|
6403
|
-
|
|
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(
|
|
6455
|
-
|
|
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");
|
|
@@ -10769,7 +10777,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10769
10777
|
hydrophobicity: 1.8,
|
|
10770
10778
|
colorByFamily: "#00FFFF",
|
|
10771
10779
|
color: "hsl(327.3, 100%, 69%)",
|
|
10772
|
-
mass:
|
|
10780
|
+
mass: 71.0779
|
|
10773
10781
|
},
|
|
10774
10782
|
R: {
|
|
10775
10783
|
value: "R",
|
|
@@ -10778,7 +10786,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10778
10786
|
hydrophobicity: -4.5,
|
|
10779
10787
|
colorByFamily: "#FFC0CB",
|
|
10780
10788
|
color: "hsl(258.1, 100%, 69%)",
|
|
10781
|
-
mass:
|
|
10789
|
+
mass: 156.18568
|
|
10782
10790
|
},
|
|
10783
10791
|
N: {
|
|
10784
10792
|
value: "N",
|
|
@@ -10787,7 +10795,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10787
10795
|
hydrophobicity: -3.5,
|
|
10788
10796
|
colorByFamily: "#D3D3D3",
|
|
10789
10797
|
color: "hsl(268.9, 100%, 69%)",
|
|
10790
|
-
mass:
|
|
10798
|
+
mass: 114.10264
|
|
10791
10799
|
},
|
|
10792
10800
|
D: {
|
|
10793
10801
|
value: "D",
|
|
@@ -10796,7 +10804,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10796
10804
|
hydrophobicity: -3.5,
|
|
10797
10805
|
colorByFamily: "#EE82EE",
|
|
10798
10806
|
color: "hsl(268.9, 100%, 69%)",
|
|
10799
|
-
mass:
|
|
10807
|
+
mass: 115.0874
|
|
10800
10808
|
},
|
|
10801
10809
|
C: {
|
|
10802
10810
|
value: "C",
|
|
@@ -10805,7 +10813,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10805
10813
|
hydrophobicity: 2.5,
|
|
10806
10814
|
colorByFamily: "#FFFF00",
|
|
10807
10815
|
color: "hsl(335.1, 100%, 69%)",
|
|
10808
|
-
mass:
|
|
10816
|
+
mass: 103.1429
|
|
10809
10817
|
},
|
|
10810
10818
|
E: {
|
|
10811
10819
|
value: "E",
|
|
@@ -10814,7 +10822,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10814
10822
|
hydrophobicity: -3.5,
|
|
10815
10823
|
colorByFamily: "#EE82EE",
|
|
10816
10824
|
color: "hsl(268.9, 100%, 69%)",
|
|
10817
|
-
mass:
|
|
10825
|
+
mass: 129.11398
|
|
10818
10826
|
},
|
|
10819
10827
|
Q: {
|
|
10820
10828
|
value: "Q",
|
|
@@ -10823,7 +10831,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10823
10831
|
hydrophobicity: -3.5,
|
|
10824
10832
|
colorByFamily: "#D3D3D3",
|
|
10825
10833
|
color: "hsl(268.9, 100%, 69%)",
|
|
10826
|
-
mass:
|
|
10834
|
+
mass: 128.12922
|
|
10827
10835
|
},
|
|
10828
10836
|
G: {
|
|
10829
10837
|
value: "G",
|
|
@@ -10832,7 +10840,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10832
10840
|
hydrophobicity: -0.4,
|
|
10833
10841
|
colorByFamily: "#00FFFF",
|
|
10834
10842
|
color: "hsl(303.1, 100%, 69%)",
|
|
10835
|
-
mass:
|
|
10843
|
+
mass: 57.05132
|
|
10836
10844
|
},
|
|
10837
10845
|
H: {
|
|
10838
10846
|
value: "H",
|
|
@@ -10841,7 +10849,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10841
10849
|
hydrophobicity: -3.2,
|
|
10842
10850
|
colorByFamily: "#FFC0CB",
|
|
10843
10851
|
color: "hsl(272.2, 100%, 69%)",
|
|
10844
|
-
mass:
|
|
10852
|
+
mass: 137.13928
|
|
10845
10853
|
},
|
|
10846
10854
|
I: {
|
|
10847
10855
|
value: "I",
|
|
@@ -10850,7 +10858,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10850
10858
|
hydrophobicity: 4.5,
|
|
10851
10859
|
colorByFamily: "#00FFFF",
|
|
10852
10860
|
color: "hsl(356.9, 100%, 69%)",
|
|
10853
|
-
mass:
|
|
10861
|
+
mass: 113.15764
|
|
10854
10862
|
},
|
|
10855
10863
|
L: {
|
|
10856
10864
|
value: "L",
|
|
@@ -10859,7 +10867,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10859
10867
|
hydrophobicity: 3.8,
|
|
10860
10868
|
colorByFamily: "#00FFFF",
|
|
10861
10869
|
color: "hsl(349.4, 100%, 69%)",
|
|
10862
|
-
mass:
|
|
10870
|
+
mass: 113.15764
|
|
10863
10871
|
},
|
|
10864
10872
|
K: {
|
|
10865
10873
|
value: "K",
|
|
@@ -10868,7 +10876,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10868
10876
|
hydrophobicity: -3.9,
|
|
10869
10877
|
colorByFamily: "#FFC0CB",
|
|
10870
10878
|
color: "hsl(264.7, 100%, 69%)",
|
|
10871
|
-
mass:
|
|
10879
|
+
mass: 128.17228
|
|
10872
10880
|
},
|
|
10873
10881
|
M: {
|
|
10874
10882
|
value: "M",
|
|
@@ -10877,7 +10885,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10877
10885
|
hydrophobicity: 1.9,
|
|
10878
10886
|
colorByFamily: "#FFFF00",
|
|
10879
10887
|
color: "hsl(328.5, 100%, 69%)",
|
|
10880
|
-
mass:
|
|
10888
|
+
mass: 131.19606
|
|
10881
10889
|
},
|
|
10882
10890
|
F: {
|
|
10883
10891
|
value: "F",
|
|
@@ -10886,7 +10894,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10886
10894
|
hydrophobicity: 2.8,
|
|
10887
10895
|
colorByFamily: "#FFA500",
|
|
10888
10896
|
color: "hsl(338.4, 100%, 69%)",
|
|
10889
|
-
mass:
|
|
10897
|
+
mass: 147.17386
|
|
10890
10898
|
},
|
|
10891
10899
|
P: {
|
|
10892
10900
|
value: "P",
|
|
@@ -10895,7 +10903,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10895
10903
|
hydrophobicity: -1.6,
|
|
10896
10904
|
colorByFamily: "#00FFFF",
|
|
10897
10905
|
color: "hsl(289.9, 100%, 69%)",
|
|
10898
|
-
mass:
|
|
10906
|
+
mass: 97.11518
|
|
10899
10907
|
},
|
|
10900
10908
|
S: {
|
|
10901
10909
|
value: "S",
|
|
@@ -10904,7 +10912,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10904
10912
|
hydrophobicity: -0.8,
|
|
10905
10913
|
colorByFamily: "#90EE90",
|
|
10906
10914
|
color: "hsl(298.6, 100%, 69%)",
|
|
10907
|
-
mass:
|
|
10915
|
+
mass: 87.0773
|
|
10908
10916
|
},
|
|
10909
10917
|
T: {
|
|
10910
10918
|
value: "T",
|
|
@@ -10913,7 +10921,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10913
10921
|
hydrophobicity: -0.7,
|
|
10914
10922
|
colorByFamily: "#90EE90",
|
|
10915
10923
|
color: "hsl(299.8, 100%, 69%)",
|
|
10916
|
-
mass:
|
|
10924
|
+
mass: 101.10388
|
|
10917
10925
|
},
|
|
10918
10926
|
U: {
|
|
10919
10927
|
value: "U",
|
|
@@ -10921,7 +10929,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10921
10929
|
threeLettersName: "Sec",
|
|
10922
10930
|
colorByFamily: "#FF0000",
|
|
10923
10931
|
color: "hsl(0, 100%, 69%)",
|
|
10924
|
-
mass:
|
|
10932
|
+
mass: 150.3079
|
|
10925
10933
|
},
|
|
10926
10934
|
W: {
|
|
10927
10935
|
value: "W",
|
|
@@ -10930,7 +10938,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10930
10938
|
hydrophobicity: -0.9,
|
|
10931
10939
|
colorByFamily: "#FFA500",
|
|
10932
10940
|
color: "hsl(297.6, 100%, 69%)",
|
|
10933
|
-
mass:
|
|
10941
|
+
mass: 186.2099
|
|
10934
10942
|
},
|
|
10935
10943
|
Y: {
|
|
10936
10944
|
value: "Y",
|
|
@@ -10939,7 +10947,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10939
10947
|
hydrophobicity: -1.3,
|
|
10940
10948
|
colorByFamily: "#FFA500",
|
|
10941
10949
|
color: "hsl(293.2, 100%, 69%)",
|
|
10942
|
-
mass:
|
|
10950
|
+
mass: 163.17326
|
|
10943
10951
|
},
|
|
10944
10952
|
V: {
|
|
10945
10953
|
value: "V",
|
|
@@ -10948,7 +10956,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
10948
10956
|
hydrophobicity: 4.2,
|
|
10949
10957
|
colorByFamily: "#00FFFF",
|
|
10950
10958
|
color: "hsl(353.6, 100%, 69%)",
|
|
10951
|
-
mass:
|
|
10959
|
+
mass: 99.13106
|
|
10952
10960
|
},
|
|
10953
10961
|
"*": {
|
|
10954
10962
|
value: "*",
|
|
@@ -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 &&
|
|
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 (
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
|
|
19775
|
-
|
|
19776
|
-
|
|
19777
|
-
|
|
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
|
|
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
|
-
|
|
29921
|
-
(r)
|
|
29922
|
-
|
|
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
|
-
|
|
30032
|
-
(r)
|
|
30033
|
-
|
|
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,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/bio-parsers",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"type": "commonjs",
|
|
3
|
+
"version": "0.3.10",
|
|
5
4
|
"dependencies": {
|
|
6
|
-
"@teselagen/sequence-utils": "0.3.
|
|
5
|
+
"@teselagen/sequence-utils": "0.3.8",
|
|
7
6
|
"@teselagen/range-utils": "0.3.7",
|
|
8
7
|
"@gmod/gff": "^1.2.1",
|
|
9
8
|
"buffer": "^6.0.3",
|
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 =>
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
191
|
+
reader.onload = evt => {
|
|
192
192
|
resolve(evt.target.result);
|
|
193
193
|
};
|
|
194
|
-
reader.onerror =
|
|
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 =
|
|
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 =
|
|
220
|
+
reader.onerror = err => {
|
|
221
221
|
console.error("err:", err);
|
|
222
222
|
reject(err);
|
|
223
223
|
};
|
package/src/genbankToJson.js
CHANGED
|
@@ -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 (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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(
|
|
242
|
+
results.forEach(result => {
|
|
241
243
|
if (result.success) {
|
|
242
244
|
const sequence = result.parsedSequence;
|
|
243
|
-
sequence.features.forEach(
|
|
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
|
-
|
|
253
|
+
feat => feat.type === "primer_bind"
|
|
252
254
|
);
|
|
253
255
|
sequence.features = sequence.features.filter(
|
|
254
|
-
|
|
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
|
|
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
|
|
package/src/geneiousXmlToJson.js
CHANGED
|
@@ -40,7 +40,7 @@ async function geneiousXmlToJson(string, options) {
|
|
|
40
40
|
messages: ["Error: XML is not valid geneious format"]
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
forEach(geneiousJsonMatches,
|
|
43
|
+
forEach(geneiousJsonMatches, geneiousJson => {
|
|
44
44
|
const response = {
|
|
45
45
|
parsedSequence: null,
|
|
46
46
|
messages: [],
|
|
@@ -58,10 +58,7 @@ async function geneiousXmlToJson(string, options) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
const toRet = filter(
|
|
62
|
-
resultArray,
|
|
63
|
-
(r) => r?.parsedSequence?.sequence?.length
|
|
64
|
-
);
|
|
61
|
+
const toRet = filter(resultArray, r => r?.parsedSequence?.sequence?.length);
|
|
65
62
|
if (toRet.length) return toRet;
|
|
66
63
|
return onFileParsed(resultArray);
|
|
67
64
|
} catch (e) {
|
|
@@ -105,7 +102,7 @@ function parseGeneiousJson(geneiousJson) {
|
|
|
105
102
|
searchWholeObjByNameSimple("maximumIndex", lastInterval) - 1;
|
|
106
103
|
let locations;
|
|
107
104
|
if (intervals.length > 1) {
|
|
108
|
-
locations = intervals.map(
|
|
105
|
+
locations = intervals.map(i => {
|
|
109
106
|
const start = searchWholeObjByNameSimple("minimumIndex", i) - 1;
|
|
110
107
|
const end = searchWholeObjByNameSimple("maximumIndex", i) - 1;
|
|
111
108
|
return {
|