@teselagen/bio-parsers 0.4.34 → 0.4.36
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.cjs +41 -0
- package/index.js +41 -0
- package/index.umd.cjs +41 -0
- package/package.json +1 -1
- package/src/genbankToJson.js +4 -0
- package/src/jsonToGenbank.js +52 -2
package/index.cjs
CHANGED
|
@@ -12866,6 +12866,10 @@ function genbankToJson(string, options = {}) {
|
|
|
12866
12866
|
feat.name = feat.notes.ApEinfo_label[0];
|
|
12867
12867
|
} else if (feat.notes.name) {
|
|
12868
12868
|
feat.name = feat.notes.name[0];
|
|
12869
|
+
} else if (feat.notes.product) {
|
|
12870
|
+
feat.name = feat.notes.product[0];
|
|
12871
|
+
} else if (feat.notes.region_name) {
|
|
12872
|
+
feat.name = feat.notes.region_name[0];
|
|
12869
12873
|
} else if (feat.notes.organism) {
|
|
12870
12874
|
feat.name = feat.notes.organism[0];
|
|
12871
12875
|
} else if (feat.notes.locus_tag) {
|
|
@@ -23817,7 +23821,44 @@ function getCurrentDateString() {
|
|
|
23817
23821
|
return day + "-" + month + "-" + year;
|
|
23818
23822
|
}
|
|
23819
23823
|
__name(getCurrentDateString, "getCurrentDateString");
|
|
23824
|
+
const standardLineLength = 79;
|
|
23820
23825
|
function featureNoteInDataToGenbankString(name, value, options) {
|
|
23826
|
+
const valueString = mangleOrStripUrls(value, options);
|
|
23827
|
+
if (valueString.length > standardLineLength - 25 - name.length) {
|
|
23828
|
+
const lines = [];
|
|
23829
|
+
let currentIndex = 0;
|
|
23830
|
+
while (currentIndex < valueString.length) {
|
|
23831
|
+
if (currentIndex === 0) {
|
|
23832
|
+
const chunk = valueString.substring(
|
|
23833
|
+
currentIndex,
|
|
23834
|
+
currentIndex + standardLineLength - name.length - 24
|
|
23835
|
+
);
|
|
23836
|
+
lines.push(
|
|
23837
|
+
StringUtil.lpad("/", " ", 22) + name + '="' + chunk + (currentIndex + standardLineLength - 22 - name.length >= valueString.length ? '"' : "")
|
|
23838
|
+
);
|
|
23839
|
+
currentIndex += standardLineLength - name.length - 24;
|
|
23840
|
+
} else {
|
|
23841
|
+
const chunk = valueString.substring(
|
|
23842
|
+
currentIndex,
|
|
23843
|
+
currentIndex + standardLineLength - 21
|
|
23844
|
+
);
|
|
23845
|
+
if (currentIndex + standardLineLength - 21 >= valueString.length) {
|
|
23846
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23847
|
+
if (lineString.length === standardLineLength) {
|
|
23848
|
+
lines.push(lineString);
|
|
23849
|
+
lines.push(" ".repeat(21) + '"');
|
|
23850
|
+
} else {
|
|
23851
|
+
lines.push(lineString + '"');
|
|
23852
|
+
}
|
|
23853
|
+
} else {
|
|
23854
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23855
|
+
lines.push(lineString);
|
|
23856
|
+
}
|
|
23857
|
+
currentIndex += standardLineLength - 21;
|
|
23858
|
+
}
|
|
23859
|
+
}
|
|
23860
|
+
return lines.join("\r\n");
|
|
23861
|
+
}
|
|
23821
23862
|
return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
|
|
23822
23863
|
}
|
|
23823
23864
|
__name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
|
package/index.js
CHANGED
|
@@ -12864,6 +12864,10 @@ function genbankToJson(string, options = {}) {
|
|
|
12864
12864
|
feat.name = feat.notes.ApEinfo_label[0];
|
|
12865
12865
|
} else if (feat.notes.name) {
|
|
12866
12866
|
feat.name = feat.notes.name[0];
|
|
12867
|
+
} else if (feat.notes.product) {
|
|
12868
|
+
feat.name = feat.notes.product[0];
|
|
12869
|
+
} else if (feat.notes.region_name) {
|
|
12870
|
+
feat.name = feat.notes.region_name[0];
|
|
12867
12871
|
} else if (feat.notes.organism) {
|
|
12868
12872
|
feat.name = feat.notes.organism[0];
|
|
12869
12873
|
} else if (feat.notes.locus_tag) {
|
|
@@ -23815,7 +23819,44 @@ function getCurrentDateString() {
|
|
|
23815
23819
|
return day + "-" + month + "-" + year;
|
|
23816
23820
|
}
|
|
23817
23821
|
__name(getCurrentDateString, "getCurrentDateString");
|
|
23822
|
+
const standardLineLength = 79;
|
|
23818
23823
|
function featureNoteInDataToGenbankString(name, value, options) {
|
|
23824
|
+
const valueString = mangleOrStripUrls(value, options);
|
|
23825
|
+
if (valueString.length > standardLineLength - 25 - name.length) {
|
|
23826
|
+
const lines = [];
|
|
23827
|
+
let currentIndex = 0;
|
|
23828
|
+
while (currentIndex < valueString.length) {
|
|
23829
|
+
if (currentIndex === 0) {
|
|
23830
|
+
const chunk = valueString.substring(
|
|
23831
|
+
currentIndex,
|
|
23832
|
+
currentIndex + standardLineLength - name.length - 24
|
|
23833
|
+
);
|
|
23834
|
+
lines.push(
|
|
23835
|
+
StringUtil.lpad("/", " ", 22) + name + '="' + chunk + (currentIndex + standardLineLength - 22 - name.length >= valueString.length ? '"' : "")
|
|
23836
|
+
);
|
|
23837
|
+
currentIndex += standardLineLength - name.length - 24;
|
|
23838
|
+
} else {
|
|
23839
|
+
const chunk = valueString.substring(
|
|
23840
|
+
currentIndex,
|
|
23841
|
+
currentIndex + standardLineLength - 21
|
|
23842
|
+
);
|
|
23843
|
+
if (currentIndex + standardLineLength - 21 >= valueString.length) {
|
|
23844
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23845
|
+
if (lineString.length === standardLineLength) {
|
|
23846
|
+
lines.push(lineString);
|
|
23847
|
+
lines.push(" ".repeat(21) + '"');
|
|
23848
|
+
} else {
|
|
23849
|
+
lines.push(lineString + '"');
|
|
23850
|
+
}
|
|
23851
|
+
} else {
|
|
23852
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23853
|
+
lines.push(lineString);
|
|
23854
|
+
}
|
|
23855
|
+
currentIndex += standardLineLength - 21;
|
|
23856
|
+
}
|
|
23857
|
+
}
|
|
23858
|
+
return lines.join("\r\n");
|
|
23859
|
+
}
|
|
23819
23860
|
return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
|
|
23820
23861
|
}
|
|
23821
23862
|
__name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
|
package/index.umd.cjs
CHANGED
|
@@ -12868,6 +12868,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
12868
12868
|
feat.name = feat.notes.ApEinfo_label[0];
|
|
12869
12869
|
} else if (feat.notes.name) {
|
|
12870
12870
|
feat.name = feat.notes.name[0];
|
|
12871
|
+
} else if (feat.notes.product) {
|
|
12872
|
+
feat.name = feat.notes.product[0];
|
|
12873
|
+
} else if (feat.notes.region_name) {
|
|
12874
|
+
feat.name = feat.notes.region_name[0];
|
|
12871
12875
|
} else if (feat.notes.organism) {
|
|
12872
12876
|
feat.name = feat.notes.organism[0];
|
|
12873
12877
|
} else if (feat.notes.locus_tag) {
|
|
@@ -23819,7 +23823,44 @@ ${seq.sequence}
|
|
|
23819
23823
|
return day + "-" + month + "-" + year;
|
|
23820
23824
|
}
|
|
23821
23825
|
__name(getCurrentDateString, "getCurrentDateString");
|
|
23826
|
+
const standardLineLength = 79;
|
|
23822
23827
|
function featureNoteInDataToGenbankString(name, value, options) {
|
|
23828
|
+
const valueString = mangleOrStripUrls(value, options);
|
|
23829
|
+
if (valueString.length > standardLineLength - 25 - name.length) {
|
|
23830
|
+
const lines = [];
|
|
23831
|
+
let currentIndex = 0;
|
|
23832
|
+
while (currentIndex < valueString.length) {
|
|
23833
|
+
if (currentIndex === 0) {
|
|
23834
|
+
const chunk = valueString.substring(
|
|
23835
|
+
currentIndex,
|
|
23836
|
+
currentIndex + standardLineLength - name.length - 24
|
|
23837
|
+
);
|
|
23838
|
+
lines.push(
|
|
23839
|
+
StringUtil.lpad("/", " ", 22) + name + '="' + chunk + (currentIndex + standardLineLength - 22 - name.length >= valueString.length ? '"' : "")
|
|
23840
|
+
);
|
|
23841
|
+
currentIndex += standardLineLength - name.length - 24;
|
|
23842
|
+
} else {
|
|
23843
|
+
const chunk = valueString.substring(
|
|
23844
|
+
currentIndex,
|
|
23845
|
+
currentIndex + standardLineLength - 21
|
|
23846
|
+
);
|
|
23847
|
+
if (currentIndex + standardLineLength - 21 >= valueString.length) {
|
|
23848
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23849
|
+
if (lineString.length === standardLineLength) {
|
|
23850
|
+
lines.push(lineString);
|
|
23851
|
+
lines.push(" ".repeat(21) + '"');
|
|
23852
|
+
} else {
|
|
23853
|
+
lines.push(lineString + '"');
|
|
23854
|
+
}
|
|
23855
|
+
} else {
|
|
23856
|
+
const lineString = " ".repeat(21) + chunk;
|
|
23857
|
+
lines.push(lineString);
|
|
23858
|
+
}
|
|
23859
|
+
currentIndex += standardLineLength - 21;
|
|
23860
|
+
}
|
|
23861
|
+
}
|
|
23862
|
+
return lines.join("\r\n");
|
|
23863
|
+
}
|
|
23823
23864
|
return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
|
|
23824
23865
|
}
|
|
23825
23866
|
__name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
|
package/package.json
CHANGED
package/src/genbankToJson.js
CHANGED
|
@@ -708,6 +708,10 @@ function genbankToJson(string, options = {}) {
|
|
|
708
708
|
feat.name = feat.notes.ApEinfo_label[0];
|
|
709
709
|
} else if (feat.notes.name) {
|
|
710
710
|
feat.name = feat.notes.name[0];
|
|
711
|
+
} else if (feat.notes.product) {
|
|
712
|
+
feat.name = feat.notes.product[0];
|
|
713
|
+
} else if (feat.notes.region_name) {
|
|
714
|
+
feat.name = feat.notes.region_name[0];
|
|
711
715
|
} else if (feat.notes.organism) {
|
|
712
716
|
feat.name = feat.notes.organism[0];
|
|
713
717
|
} else if (feat.notes.locus_tag) {
|
package/src/jsonToGenbank.js
CHANGED
|
@@ -6,6 +6,7 @@ import pragmasAndTypes from "./utils/pragmasAndTypes.js";
|
|
|
6
6
|
import { mangleOrStripUrls } from "./utils/unmangleUrls.js";
|
|
7
7
|
import { reformatName } from "./utils/NameUtils.js";
|
|
8
8
|
import { getFeatureToColorMap } from "@teselagen/sequence-utils";
|
|
9
|
+
|
|
9
10
|
const StringUtil = {
|
|
10
11
|
/** Trims white space at beginning and end of string
|
|
11
12
|
* @param {string} line
|
|
@@ -206,11 +207,11 @@ function createGenbankLocus(serSeq, options) {
|
|
|
206
207
|
} else if (serSeq.type === "RNA") {
|
|
207
208
|
dnaType = serSeq?.doubleStranded
|
|
208
209
|
? "RNA"
|
|
209
|
-
: serSeq?.sequenceTypeFromLocus ?? "ss-RNA";
|
|
210
|
+
: (serSeq?.sequenceTypeFromLocus ?? "ss-RNA");
|
|
210
211
|
} else {
|
|
211
212
|
dnaType = serSeq?.doubleStranded
|
|
212
213
|
? "DNA"
|
|
213
|
-
: serSeq?.sequenceTypeFromLocus ?? "DNA";
|
|
214
|
+
: (serSeq?.sequenceTypeFromLocus ?? "DNA");
|
|
214
215
|
}
|
|
215
216
|
const date = getCurrentDateString();
|
|
216
217
|
|
|
@@ -257,7 +258,56 @@ function getCurrentDateString() {
|
|
|
257
258
|
return day + "-" + month + "-" + year;
|
|
258
259
|
}
|
|
259
260
|
|
|
261
|
+
const standardLineLength = 79;
|
|
260
262
|
function featureNoteInDataToGenbankString(name, value, options) {
|
|
263
|
+
const valueString = mangleOrStripUrls(value, options);
|
|
264
|
+
// if valueString.length is larger than standardLineLength - 25 - name.length,
|
|
265
|
+
// we need to split it up into multiple lines, to make sure each line has 21 spaces
|
|
266
|
+
// a maximum of 59 additional characters
|
|
267
|
+
// 25 is the length of '/', '=', two '"' and the 21 spaces.
|
|
268
|
+
if (valueString.length > standardLineLength - 25 - name.length) {
|
|
269
|
+
const lines = [];
|
|
270
|
+
let currentIndex = 0;
|
|
271
|
+
while (currentIndex < valueString.length) {
|
|
272
|
+
if (currentIndex === 0) {
|
|
273
|
+
const chunk = valueString.substring(
|
|
274
|
+
currentIndex,
|
|
275
|
+
currentIndex + standardLineLength - name.length - 24
|
|
276
|
+
);
|
|
277
|
+
lines.push(
|
|
278
|
+
StringUtil.lpad("/", " ", 22) +
|
|
279
|
+
name +
|
|
280
|
+
'="' +
|
|
281
|
+
chunk +
|
|
282
|
+
(currentIndex + standardLineLength - 22 - name.length >=
|
|
283
|
+
valueString.length
|
|
284
|
+
? '"'
|
|
285
|
+
: "")
|
|
286
|
+
);
|
|
287
|
+
currentIndex += standardLineLength - name.length - 24;
|
|
288
|
+
} else {
|
|
289
|
+
const chunk = valueString.substring(
|
|
290
|
+
currentIndex,
|
|
291
|
+
currentIndex + standardLineLength - 21
|
|
292
|
+
);
|
|
293
|
+
if (currentIndex + standardLineLength - 21 >= valueString.length) {
|
|
294
|
+
const lineString = " ".repeat(21) + chunk;
|
|
295
|
+
if (lineString.length === standardLineLength) {
|
|
296
|
+
lines.push(lineString);
|
|
297
|
+
lines.push(" ".repeat(21) + '"');
|
|
298
|
+
} else {
|
|
299
|
+
lines.push(lineString + '"');
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
const lineString = " ".repeat(21) + chunk;
|
|
303
|
+
lines.push(lineString);
|
|
304
|
+
}
|
|
305
|
+
currentIndex += standardLineLength - 21;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return lines.join("\r\n");
|
|
309
|
+
}
|
|
310
|
+
|
|
261
311
|
return (
|
|
262
312
|
StringUtil.lpad("/", " ", 22) +
|
|
263
313
|
name +
|