@teselagen/bio-parsers 0.4.35 → 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 CHANGED
@@ -23821,7 +23821,44 @@ function getCurrentDateString() {
23821
23821
  return day + "-" + month + "-" + year;
23822
23822
  }
23823
23823
  __name(getCurrentDateString, "getCurrentDateString");
23824
+ const standardLineLength = 79;
23824
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
+ }
23825
23862
  return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
23826
23863
  }
23827
23864
  __name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
package/index.js CHANGED
@@ -23819,7 +23819,44 @@ function getCurrentDateString() {
23819
23819
  return day + "-" + month + "-" + year;
23820
23820
  }
23821
23821
  __name(getCurrentDateString, "getCurrentDateString");
23822
+ const standardLineLength = 79;
23822
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
+ }
23823
23860
  return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
23824
23861
  }
23825
23862
  __name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
package/index.umd.cjs CHANGED
@@ -23823,7 +23823,44 @@ ${seq.sequence}
23823
23823
  return day + "-" + month + "-" + year;
23824
23824
  }
23825
23825
  __name(getCurrentDateString, "getCurrentDateString");
23826
+ const standardLineLength = 79;
23826
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
+ }
23827
23864
  return StringUtil.lpad("/", " ", 22) + name + '="' + mangleOrStripUrls(value, options) + '"';
23828
23865
  }
23829
23866
  __name(featureNoteInDataToGenbankString, "featureNoteInDataToGenbankString");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/bio-parsers",
3
- "version": "0.4.35",
3
+ "version": "0.4.36",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/TeselaGen/tg-oss",
6
6
  "dependencies": {
@@ -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 +