@teselagen/bio-parsers 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.
- package/README.md +330 -0
- package/fastaToJson.d.ts +1 -1
- package/index.js +133 -116
- package/index.mjs +133 -116
- package/index.umd.js +132 -115
- package/package.json +1 -2
- package/src/ab1ToJson.js +13 -18
- package/src/anyToJson.js +7 -7
- package/src/fastaToJson.js +12 -7
- 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 +15 -10
- package/src/utils/validateSequenceArray.js +17 -17
- package/utils/getArrayBufferFromFile.d.ts +1 -1
|
@@ -40,7 +40,7 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
40
40
|
"isSingleStrandedDNA",
|
|
41
41
|
"isDoubleStrandedRNA",
|
|
42
42
|
"isProtein"
|
|
43
|
-
].forEach(
|
|
43
|
+
].forEach(k => {
|
|
44
44
|
if (options[k] !== undefined && sequence[k] === undefined) {
|
|
45
45
|
sequence[k] = options[k];
|
|
46
46
|
}
|
|
@@ -110,11 +110,16 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
110
110
|
//todo: this logic won't catch every case of RNA, so we should probably handle RNA conversion at another level..
|
|
111
111
|
const temp = sequence.sequence;
|
|
112
112
|
if (!sequence.isOligo) {
|
|
113
|
-
sequence.sequence = sequence.sequence.replace(/u/gi,
|
|
113
|
+
sequence.sequence = sequence.sequence.replace(/u/gi, u =>
|
|
114
114
|
u === "U" ? "T" : "t"
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
temp !== sequence.sequence &&
|
|
119
|
+
!sequence.isDNA &&
|
|
120
|
+
!sequence.isProtein &&
|
|
121
|
+
sequence.isRNA !== false
|
|
122
|
+
) {
|
|
118
123
|
sequence.type = "RNA";
|
|
119
124
|
sequence.sequence = temp;
|
|
120
125
|
} else {
|
|
@@ -294,16 +299,16 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
294
299
|
}
|
|
295
300
|
if (
|
|
296
301
|
feature.notes.pragma &&
|
|
297
|
-
some(feature.notes.pragma,
|
|
302
|
+
some(feature.notes.pragma, p => p === "overlapsSelf")
|
|
298
303
|
) {
|
|
299
304
|
feature.overlapsSelf = true;
|
|
300
305
|
feature.notes.pragma = filter(
|
|
301
306
|
feature.notes.pragma,
|
|
302
|
-
|
|
307
|
+
p => p !== "overlapsSelf"
|
|
303
308
|
);
|
|
304
309
|
}
|
|
305
310
|
feature.notes.note &&
|
|
306
|
-
some(feature.notes.note,
|
|
311
|
+
some(feature.notes.note, n => {
|
|
307
312
|
if (
|
|
308
313
|
n &&
|
|
309
314
|
typeof n === "string" &&
|
|
@@ -312,7 +317,7 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
312
317
|
//remove it after we're parsed it out
|
|
313
318
|
feature.notes.note = filter(
|
|
314
319
|
feature.notes.note,
|
|
315
|
-
|
|
320
|
+
p => p && !p.toLowerCase().includes("sequence:")
|
|
316
321
|
);
|
|
317
322
|
if (feature.notes.note.length === 0) {
|
|
318
323
|
delete feature.notes.note;
|
|
@@ -328,7 +333,7 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
328
333
|
});
|
|
329
334
|
|
|
330
335
|
feature.notes.primerBindsOn &&
|
|
331
|
-
some(feature.notes.primerBindsOn,
|
|
336
|
+
some(feature.notes.primerBindsOn, n => {
|
|
332
337
|
if (n) {
|
|
333
338
|
feature.primerBindsOn = n;
|
|
334
339
|
delete feature.notes.primerBindsOn;
|
|
@@ -339,7 +344,7 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
339
344
|
if (
|
|
340
345
|
options[`accept${upperFirst(type)}`] !== false && //acceptParts, acceptWarnings,
|
|
341
346
|
feature.notes.pragma &&
|
|
342
|
-
some(feature.notes.pragma,
|
|
347
|
+
some(feature.notes.pragma, p => p === pragma)
|
|
343
348
|
) {
|
|
344
349
|
if (!sequence[type]) {
|
|
345
350
|
sequence[type] = []; //initialize an empty array if necessary
|
|
@@ -351,7 +356,7 @@ export default function validateSequence(sequence, options = {}) {
|
|
|
351
356
|
}
|
|
352
357
|
}
|
|
353
358
|
forEach(feature.notes, (noteArray, key) => {
|
|
354
|
-
feature.notes[key] = map(noteArray,
|
|
359
|
+
feature.notes[key] = map(noteArray, note => {
|
|
355
360
|
return unmangleUrls(note);
|
|
356
361
|
});
|
|
357
362
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import validateSequence from
|
|
1
|
+
import validateSequence from "./validateSequence.js";
|
|
2
2
|
|
|
3
3
|
export default function validateSequenceArray(parsingResultArray, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
//should convert the old data type to the new data type (flattened sequence)
|
|
10
|
-
parsingResultArray.forEach(function(parsingResult) {
|
|
11
|
-
if (parsingResult.success) {
|
|
12
|
-
const res = validateSequence(parsingResult.parsedSequence, options);
|
|
13
|
-
//add any validation error messages to the parsed sequence results messages
|
|
14
|
-
parsingResult.messages = parsingResult.messages.concat(res.messages);
|
|
15
|
-
parsingResult.parsedSequence = res.validatedAndCleanedSequence;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
4
|
+
if (parsingResultArray) {
|
|
5
|
+
if (!Array.isArray(parsingResultArray)) {
|
|
6
|
+
//wrap the parsingResult into an array if it isn't one already
|
|
7
|
+
parsingResultArray = [parsingResultArray];
|
|
18
8
|
}
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
//should convert the old data type to the new data type (flattened sequence)
|
|
10
|
+
parsingResultArray.forEach(function (parsingResult) {
|
|
11
|
+
if (parsingResult.success) {
|
|
12
|
+
const res = validateSequence(parsingResult.parsedSequence, options);
|
|
13
|
+
//add any validation error messages to the parsed sequence results messages
|
|
14
|
+
parsingResult.messages = parsingResult.messages.concat(res.messages);
|
|
15
|
+
parsingResult.parsedSequence = res.validatedAndCleanedSequence;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return parsingResultArray;
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getArrayBufferFromFile(file: any):
|
|
1
|
+
export default function getArrayBufferFromFile(file: any): Promise<any> | ArrayBuffer;
|