@teselagen/sequence-utils 0.3.7 → 0.3.8

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.
Files changed (104) hide show
  1. package/README.md +89 -0
  2. package/bioData.d.ts +0 -339
  3. package/index.d.ts +7 -7
  4. package/index.js +238 -384
  5. package/index.mjs +238 -384
  6. package/index.umd.js +238 -384
  7. package/package.json +1 -2
  8. package/src/addGapsToSeqReads.js +2 -2
  9. package/src/adjustAnnotationsToInsert.js +3 -3
  10. package/src/adjustBpsToReplaceOrInsert.js +3 -3
  11. package/src/adjustBpsToReplaceOrInsert.test.js +0 -1
  12. package/src/aminoAcidToDnaRna.test.js +1 -1
  13. package/src/annotateSingleSeq.js +1 -1
  14. package/src/annotateSingleSeq.test.js +1 -4
  15. package/src/autoAnnotate.js +5 -2
  16. package/src/autoAnnotate.test.js +6 -30
  17. package/src/bioData.js +0 -365
  18. package/src/calculateNebTa.js +1 -1
  19. package/src/calculateNebTm.js +1 -1
  20. package/src/calculatePercentGC.js +2 -2
  21. package/src/calculateTm.js +19 -102
  22. package/src/computeDigestFragments.js +7 -4
  23. package/src/computeDigestFragments.test.js +1 -1
  24. package/src/condensePairwiseAlignmentDifferences.js +1 -1
  25. package/src/convertAACaretPositionOrRangeToDna.js +1 -1
  26. package/src/convertDnaCaretPositionOrRangeToAA.js +1 -1
  27. package/src/cutSequenceByRestrictionEnzyme.js +3 -3
  28. package/src/cutSequenceByRestrictionEnzyme.test.js +0 -1
  29. package/src/degenerateDnaToAminoAcidMap.js +1 -1
  30. package/src/degenerateRnaToAminoAcidMap.js +1 -1
  31. package/src/deleteSequenceDataAtRange.js +1 -1
  32. package/src/deleteSequenceDataAtRange.test.js +23 -9
  33. package/src/diffUtils.js +4 -4
  34. package/src/diffUtils.test.js +2 -2
  35. package/src/doesEnzymeChopOutsideOfRecognitionSite.js +1 -1
  36. package/src/doesEnzymeChopOutsideOfRecognitionSite.test.js +0 -2
  37. package/src/featureTypesAndColors.js +5 -5
  38. package/src/featureTypesAndColors.test.js +1 -1
  39. package/src/filterAminoAcidSequenceString.js +4 -7
  40. package/src/filterAminoAcidSequenceString.test.js +3 -1
  41. package/src/filterSequenceString.js +5 -3
  42. package/src/findNearestRangeOfSequenceOverlapToPosition.js +1 -1
  43. package/src/findOrfsInPlasmid.js +1 -1
  44. package/src/findSequenceMatches.js +9 -10
  45. package/src/generateAnnotations.js +1 -1
  46. package/src/generateSequenceData.js +1 -1
  47. package/src/generateSequenceData.test.js +1 -1
  48. package/src/getAllInsertionsInSeqReads.js +1 -1
  49. package/src/getAminoAcidDataForEachBaseOfDna.js +2 -2
  50. package/src/getAminoAcidDataForEachBaseOfDna.test.js +0 -2
  51. package/src/getAminoAcidFromSequenceTriplet.js +1 -1
  52. package/src/getAminoAcidStringFromSequenceString.js +1 -1
  53. package/src/getCodonRangeForAASliver.js +1 -1
  54. package/src/getComplementAminoAcidStringFromSequenceString.js +2 -5
  55. package/src/getComplementSequenceAndAnnotations.js +1 -2
  56. package/src/getComplementSequenceString.js +5 -3
  57. package/src/getComplementSequenceString.test.js +6 -6
  58. package/src/getCutsiteType.js +1 -1
  59. package/src/getCutsitesFromSequence.js +1 -1
  60. package/src/getDegenerateDnaStringFromAAString.js +1 -1
  61. package/src/getDegenerateRnaStringFromAAString.js +1 -1
  62. package/src/getDigestFragmentsForCutsites.js +5 -2
  63. package/src/getDigestFragmentsForRestrictionEnzymes.js +2 -2
  64. package/src/getInsertBetweenVals.js +2 -2
  65. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.js +2 -2
  66. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.test.js +0 -2
  67. package/src/getMassOfAaString.js +4 -1
  68. package/src/getMassofAaString.test.js +9 -8
  69. package/src/getOrfsFromSequence.js +1 -2
  70. package/src/getOrfsFromSequence.test.js +1 -3
  71. package/src/getOverlapBetweenTwoSequences.js +3 -3
  72. package/src/getOverlapBetweenTwoSequences.test.js +1 -1
  73. package/src/getPossiblePartsFromSequenceAndEnzymes.js +2 -2
  74. package/src/getReverseAminoAcidStringFromSequenceString.js +1 -1
  75. package/src/getReverseComplementAminoAcidStringFromSequenceString.js +9 -6
  76. package/src/getReverseComplementAnnotation.js +1 -1
  77. package/src/getReverseComplementSequenceAndAnnotations.js +2 -3
  78. package/src/getReverseComplementSequenceString.js +1 -2
  79. package/src/getReverseSequenceString.js +1 -1
  80. package/src/getSequenceDataBetweenRange.js +7 -4
  81. package/src/getSequenceDataBetweenRange.test.js +0 -1
  82. package/src/getVirtualDigest.js +6 -3
  83. package/src/guessIfSequenceIsDnaAndNotProtein.js +2 -2
  84. package/src/index.js +80 -80
  85. package/src/index.test.js +5 -4
  86. package/src/insertGapsIntoRefSeq.js +1 -1
  87. package/src/insertSequenceDataAtPosition.test.js +4 -2
  88. package/src/insertSequenceDataAtPositionOrRange.js +5 -5
  89. package/src/insertSequenceDataAtPositionOrRange.test.js +3 -17
  90. package/src/isEnzymeType2S.js +1 -1
  91. package/src/mapAnnotationsToRows.js +3 -3
  92. package/src/mapAnnotationsToRows.test.js +1 -3
  93. package/src/prepareCircularViewData.js +5 -5
  94. package/src/prepareCircularViewData.test.js +1 -1
  95. package/src/prepareRowData.js +1 -2
  96. package/src/prepareRowData.test.js +1 -3
  97. package/src/prepareRowData_output1.json +381 -381
  98. package/src/proteinAlphabet.js +34 -26
  99. package/src/rotateBpsToPosition.js +7 -11
  100. package/src/rotateBpsToPosition.test.js +6 -6
  101. package/src/rotateSequenceDataToPosition.js +4 -4
  102. package/src/shiftAnnotationsByLen.js +2 -2
  103. package/src/tidyUpAnnotation.js +8 -7
  104. package/src/tidyUpSequenceData.js +3 -3
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/sequence-utils",
3
- "version": "0.3.7",
4
- "type": "commonjs",
3
+ "version": "0.3.8",
5
4
  "dependencies": {
6
5
  "@teselagen/range-utils": "0.3.7",
7
6
  "bson-objectid": "^2.0.4",
@@ -1,6 +1,6 @@
1
1
  import insertGapsIntoRefSeq from "./insertGapsIntoRefSeq.js";
2
2
 
3
- import {cloneDeep} from "lodash";
3
+ import { cloneDeep } from "lodash";
4
4
 
5
5
  // bam.seq: NTGTAAGTCGTGAAAAAANCNNNCATATTNCGGAGGTAAAAATGAAAA...
6
6
  // bam.pos: 43
@@ -414,4 +414,4 @@ export default function addGapsToSeqReads(refSeq, seqReads) {
414
414
  // seqReadsWithGaps is an array of objects containing the ref seq with gaps first and then all seq reads with gaps
415
415
  // e.g. [{ name: "ref seq", sequence: "GG---GA--GA-C--A---CC---"}, { name: "r1", sequence: "-----GATTGA-C-----------"}...]
416
416
  return seqReadsWithGaps;
417
- };
417
+ }
@@ -1,5 +1,5 @@
1
- import {adjustRangeToInsert} from "@teselagen/range-utils";
2
- import {map} from "lodash";
1
+ import { adjustRangeToInsert } from "@teselagen/range-utils";
2
+ import { map } from "lodash";
3
3
 
4
4
  export default function adjustAnnotationsToInsert(
5
5
  annotationsToBeAdjusted,
@@ -16,4 +16,4 @@ export default function adjustAnnotationsToInsert(
16
16
  })
17
17
  };
18
18
  });
19
- };
19
+ }
@@ -3,7 +3,7 @@ import {
3
3
  getSequenceWithinRange,
4
4
  getRangeLength,
5
5
  invertRange,
6
- isPositionWithinRange,
6
+ isPositionWithinRange
7
7
  } from "@teselagen/range-utils";
8
8
 
9
9
  import spliceString from "string-splice";
@@ -11,7 +11,7 @@ import spliceString from "string-splice";
11
11
  export default function adjustBpsToReplaceOrInsert(
12
12
  bpString,
13
13
  insertString = "",
14
- caretPositionOrRange,
14
+ caretPositionOrRange
15
15
  ) {
16
16
  let stringToReturn = bpString;
17
17
 
@@ -47,4 +47,4 @@ export default function adjustBpsToReplaceOrInsert(
47
47
  );
48
48
  }
49
49
  return stringToReturn;
50
- };
50
+ }
@@ -1,6 +1,5 @@
1
1
  //tnr: half finished test.
2
2
 
3
-
4
3
  import chai from "chai";
5
4
  import chaiSubset from "chai-subset";
6
5
 
@@ -1,4 +1,4 @@
1
- import {expect} from "chai";
1
+ import { expect } from "chai";
2
2
  import getDegenerateDnaStringFromAAString from "./getDegenerateDnaStringFromAAString";
3
3
  import getDegenerateRnaStringFromAAString from "./getDegenerateRnaStringFromAAString";
4
4
 
@@ -1,4 +1,4 @@
1
- import {autoAnnotate} from "./autoAnnotate";
1
+ import { autoAnnotate } from "./autoAnnotate";
2
2
 
3
3
  function annotateSingleSeq({ fullSeq, searchSeq }) {
4
4
  const fullSeqId = fullSeq.id || "fullSeqId";
@@ -1,5 +1,5 @@
1
1
  import annotateSingleSeq from "./annotateSingleSeq";
2
- import {expect} from "chai";
2
+ import { expect } from "chai";
3
3
 
4
4
  describe("annotateSingleSeq", () => {
5
5
  it(`regexes work - correctly annotates a single seq with a regex annotation`, () => {
@@ -20,7 +20,6 @@ describe("annotateSingleSeq", () => {
20
20
  }
21
21
  ]
22
22
  });
23
-
24
23
  });
25
24
  it(`correctly annotates a single seq with multiple matches`, () => {
26
25
  const results = annotateSingleSeq({
@@ -46,7 +45,6 @@ describe("annotateSingleSeq", () => {
46
45
  }
47
46
  ]
48
47
  });
49
-
50
48
  });
51
49
  it(`correctly finds no matches when there are none`, () => {
52
50
  const results = annotateSingleSeq({
@@ -59,6 +57,5 @@ describe("annotateSingleSeq", () => {
59
57
  expect(results).to.deep.eq({
60
58
  matches: []
61
59
  });
62
-
63
60
  });
64
61
  });
@@ -1,8 +1,11 @@
1
1
  /* Copyright (C) 2018 TeselaGen Biotechnology, Inc. */
2
- import {forEach, omitBy} from "lodash";
2
+ import { forEach, omitBy } from "lodash";
3
3
  import { ambiguous_dna_values } from "./bioData";
4
4
  import aminoAcidToDegenerateDnaMap from "./aminoAcidToDegenerateDnaMap";
5
- import {normalizePositionByRangeLength, reversePositionInRange} from "@teselagen/range-utils";
5
+ import {
6
+ normalizePositionByRangeLength,
7
+ reversePositionInRange
8
+ } from "@teselagen/range-utils";
6
9
  import getReverseComplementSequenceString from "./getReverseComplementSequenceString";
7
10
 
8
11
  //seqsToAnnotateById must not be length = 0
@@ -1,7 +1,11 @@
1
1
  /* eslint-disable no-unused-expressions */
2
- import {autoAnnotate, convertApELikeRegexToRegex, convertProteinSeqToDNAIupac} from "./autoAnnotate";
2
+ import {
3
+ autoAnnotate,
4
+ convertApELikeRegexToRegex,
5
+ convertProteinSeqToDNAIupac
6
+ } from "./autoAnnotate";
3
7
 
4
- import {expect} from "chai";
8
+ import { expect } from "chai";
5
9
 
6
10
  describe("convertApELikeRegexToRegex", () => {
7
11
  it(`converts as expected`, () => {
@@ -26,7 +30,6 @@ describe("convertApELikeRegexToRegex", () => {
26
30
  expect(convertApELikeRegexToRegex("CATTT<ATTT")).to.eq(
27
31
  "(CATTT|ATTT|TTT|TT|T)?ATTT"
28
32
  );
29
-
30
33
  });
31
34
 
32
35
  it(`errors as expected`, () => {
@@ -35,7 +38,6 @@ describe("convertApELikeRegexToRegex", () => {
35
38
  } catch (e) {
36
39
  expect(e).to.exist;
37
40
  }
38
-
39
41
  });
40
42
  it(`errors as expected`, () => {
41
43
  try {
@@ -43,7 +45,6 @@ describe("convertApELikeRegexToRegex", () => {
43
45
  } catch (e) {
44
46
  expect(e).to.exist;
45
47
  }
46
-
47
48
  });
48
49
  it(`errors as expected`, () => {
49
50
  try {
@@ -51,7 +52,6 @@ describe("convertApELikeRegexToRegex", () => {
51
52
  } catch (e) {
52
53
  expect(e).to.exist;
53
54
  }
54
-
55
55
  });
56
56
  it(`errors as expected`, () => {
57
57
  try {
@@ -59,7 +59,6 @@ describe("convertApELikeRegexToRegex", () => {
59
59
  } catch (e) {
60
60
  expect(e).to.exist;
61
61
  }
62
-
63
62
  });
64
63
  });
65
64
  describe("autoAnnotate", () => {
@@ -105,7 +104,6 @@ describe("autoAnnotate", () => {
105
104
  }
106
105
  ]
107
106
  });
108
-
109
107
  });
110
108
  it(`IUPAC # works - T#C should capture part of AAAATTTTGGGGGCCCCCAAGT`, () => {
111
109
  const results = autoAnnotate({
@@ -146,7 +144,6 @@ describe("autoAnnotate", () => {
146
144
  }
147
145
  ]
148
146
  });
149
-
150
147
  });
151
148
  it(`IUPAC # works - T#C<AAG should capture part of AAAATTTTGGGGGCCCCCAAGT`, () => {
152
149
  const results = autoAnnotate({
@@ -180,7 +177,6 @@ describe("autoAnnotate", () => {
180
177
  }
181
178
  ]
182
179
  });
183
-
184
180
  });
185
181
  it(`IUPAC > works - CAA>ATT should capture all of CAAATT`, () => {
186
182
  const results = autoAnnotate({
@@ -214,7 +210,6 @@ describe("autoAnnotate", () => {
214
210
  }
215
211
  ]
216
212
  });
217
-
218
213
  });
219
214
  it(`IUPAC > works - CAA>ATT should capture part of CAAATG`, () => {
220
215
  const results = autoAnnotate({
@@ -248,7 +243,6 @@ describe("autoAnnotate", () => {
248
243
  }
249
244
  ]
250
245
  });
251
-
252
246
  });
253
247
  it(`complex IUPAC works - correctly auto annotates a single seq with a regex annotation`, () => {
254
248
  const results = autoAnnotate({
@@ -281,7 +275,6 @@ describe("autoAnnotate", () => {
281
275
  }
282
276
  ]
283
277
  });
284
-
285
278
  });
286
279
  it(`another IUPAC works ccc<cTTT - correctly auto annotates a single seq with a regex annotation`, () => {
287
280
  const results = autoAnnotate({
@@ -315,7 +308,6 @@ describe("autoAnnotate", () => {
315
308
  }
316
309
  ]
317
310
  });
318
-
319
311
  });
320
312
  it(`long iupac < works - correctly auto annotates a single seq with a regex annotation`, () => {
321
313
  const convertReg = convertApELikeRegexToRegex(
@@ -393,7 +385,6 @@ describe("autoAnnotate", () => {
393
385
  }
394
386
  ]
395
387
  });
396
-
397
388
  });
398
389
 
399
390
  it(`correctly auto annotates a single dna seq with a single protein annotation`, () => {
@@ -440,7 +431,6 @@ describe("autoAnnotate", () => {
440
431
  }
441
432
  ]
442
433
  });
443
-
444
434
  });
445
435
  it(`correctly auto annotates a single seq with a single annotation`, () => {
446
436
  const results = autoAnnotate({
@@ -501,7 +491,6 @@ describe("autoAnnotate", () => {
501
491
  }
502
492
  ]
503
493
  });
504
-
505
494
  });
506
495
  it(`correctly auto annotates a single seq with a full spanning annotation`, () => {
507
496
  const results = autoAnnotate({
@@ -524,7 +513,6 @@ describe("autoAnnotate", () => {
524
513
  expect(results).to.deep.eq({
525
514
  21: [{ id: 31, strand: 1, start: 0, end: 6 }]
526
515
  });
527
-
528
516
  });
529
517
  it(`a "warning threshold" works as expected`, () => {
530
518
  const results = autoAnnotate({
@@ -594,7 +582,6 @@ describe("autoAnnotate", () => {
594
582
  21: ["31"]
595
583
  }
596
584
  });
597
-
598
585
  });
599
586
  it(`correctly does not auto annotate two seqs when an annotation spans them`, () => {
600
587
  const results = autoAnnotate({
@@ -620,7 +607,6 @@ describe("autoAnnotate", () => {
620
607
  });
621
608
  //this should return an object keyed by the sequence id with the list of annotations to create
622
609
  expect(results).to.deep.eq({});
623
-
624
610
  });
625
611
  it(`correctly auto annotates two seqs when an annotation spans the origin on the 2nd seq`, () => {
626
612
  const results = autoAnnotate({
@@ -656,7 +642,6 @@ describe("autoAnnotate", () => {
656
642
  }
657
643
  ]
658
644
  });
659
-
660
645
  });
661
646
  it(`correctly auto annotates two seq when the casing on the annotation and seq is wonky`, () => {
662
647
  const results = autoAnnotate({
@@ -693,7 +678,6 @@ describe("autoAnnotate", () => {
693
678
  }
694
679
  ]
695
680
  });
696
-
697
681
  });
698
682
 
699
683
  it(`correctly auto annotates a 1 bp seq`, () => {
@@ -725,7 +709,6 @@ describe("autoAnnotate", () => {
725
709
  }
726
710
  ]
727
711
  });
728
-
729
712
  });
730
713
  it(`correctly does not auto annotate a 1 bp seq when a feature already spans that seq`, () => {
731
714
  const results = autoAnnotate({
@@ -748,7 +731,6 @@ describe("autoAnnotate", () => {
748
731
  });
749
732
  //this should return an object keyed by the sequence id with the list of annotations to create
750
733
  expect(results).to.deep.eq({});
751
-
752
734
  });
753
735
  it(`correctly auto annotates a 1 bp seq when compareName:true when a feature with a different name already spans that seq`, () => {
754
736
  const results = autoAnnotate({
@@ -781,7 +763,6 @@ describe("autoAnnotate", () => {
781
763
  }
782
764
  ]
783
765
  });
784
-
785
766
  });
786
767
  it(`correctly does not auto annotate several seqs when annotations already span those seqs`, () => {
787
768
  const results = autoAnnotate({
@@ -819,7 +800,6 @@ describe("autoAnnotate", () => {
819
800
  });
820
801
  //this should return an object keyed by the sequence id with the list of annotations to create
821
802
  expect(results).to.deep.eq({});
822
-
823
803
  });
824
804
  it(`correctly auto annotates two seqs when a annotation spans the origin on the 2nd seq on the negative strand`, () => {
825
805
  const results = autoAnnotate({
@@ -859,7 +839,6 @@ describe("autoAnnotate", () => {
859
839
  }
860
840
  ]
861
841
  });
862
-
863
842
  });
864
843
  it(`correctly auto annotates a seq when an annotation matches multiple times overlapping`, () => {
865
844
  const results = autoAnnotate({
@@ -894,7 +873,6 @@ describe("autoAnnotate", () => {
894
873
  }
895
874
  ]
896
875
  });
897
-
898
876
  });
899
877
  it(`correctly auto annotates two seqs when an annotation matches multiple times overlapping on the 2nd seq`, () => {
900
878
  const results = autoAnnotate({
@@ -942,7 +920,6 @@ describe("autoAnnotate", () => {
942
920
  }
943
921
  ]
944
922
  });
945
-
946
923
  });
947
924
  it(`correctly auto annotates multiple sequences and multiple annotations`, () => {
948
925
  const results = autoAnnotate({
@@ -1034,6 +1011,5 @@ describe("autoAnnotate", () => {
1034
1011
  }
1035
1012
  ]
1036
1013
  });
1037
-
1038
1014
  });
1039
1015
  });