@teselagen/sequence-utils 0.1.22 → 0.1.23

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 (135) hide show
  1. package/index.js +12030 -26126
  2. package/index.mjs +12119 -26124
  3. package/index.umd.js +24056 -38154
  4. package/package.json +2 -2
  5. package/src/DNAComplementMap.js +32 -0
  6. package/src/addGapsToSeqReads.js +417 -0
  7. package/src/addGapsToSeqReads.test.js +358 -0
  8. package/src/adjustAnnotationsToInsert.js +19 -0
  9. package/src/adjustBpsToReplaceOrInsert.js +50 -0
  10. package/src/adjustBpsToReplaceOrInsert.test.js +59 -0
  11. package/src/aliasedEnzymesByName.js +7363 -0
  12. package/src/aminoAcidToDegenerateDnaMap.js +32 -0
  13. package/src/aminoAcidToDegenerateRnaMap.js +32 -0
  14. package/src/aminoAcidToDnaRna.test.js +27 -0
  15. package/src/annotateSingleSeq.js +29 -0
  16. package/src/annotateSingleSeq.test.js +64 -0
  17. package/src/annotationTypes.js +23 -0
  18. package/src/autoAnnotate.js +242 -0
  19. package/src/autoAnnotate.test.js +1039 -0
  20. package/src/bioData.js +431 -0
  21. package/src/calculateNebTa.js +34 -0
  22. package/src/calculateNebTa.test.js +57 -0
  23. package/src/calculateNebTm.js +127 -0
  24. package/src/calculateNebTm.test.js +32 -0
  25. package/src/calculatePercentGC.js +3 -0
  26. package/src/calculatePercentGC.test.js +14 -0
  27. package/src/calculateTm.js +297 -0
  28. package/src/calculateTm.test.js +7 -0
  29. package/src/computeDigestFragments.js +179 -0
  30. package/src/computeDigestFragments.test.js +73 -0
  31. package/src/condensePairwiseAlignmentDifferences.js +85 -0
  32. package/src/condensePairwiseAlignmentDifferences.test.js +66 -0
  33. package/src/convertAACaretPositionOrRangeToDna.js +24 -0
  34. package/src/convertAACaretPositionOrRangeToDna.test.js +34 -0
  35. package/src/convertDnaCaretPositionOrRangeToAA.js +24 -0
  36. package/src/convertDnaCaretPositionOrRangeToAA.test.js +37 -0
  37. package/src/cutSequenceByRestrictionEnzyme.js +301 -0
  38. package/src/cutSequenceByRestrictionEnzyme.test.js +296 -0
  39. package/src/defaultEnzymesByName.js +278 -0
  40. package/src/degenerateDnaToAminoAcidMap.js +5 -0
  41. package/src/degenerateRnaToAminoAcidMap.js +5 -0
  42. package/src/deleteSequenceDataAtRange.js +5 -0
  43. package/src/deleteSequenceDataAtRange.test.js +146 -0
  44. package/src/diffUtils.js +64 -0
  45. package/src/diffUtils.test.js +74 -0
  46. package/src/doesEnzymeChopOutsideOfRecognitionSite.js +10 -0
  47. package/src/doesEnzymeChopOutsideOfRecognitionSite.test.js +41 -0
  48. package/src/featureTypesAndColors.js +152 -0
  49. package/src/featureTypesAndColors.test.js +52 -0
  50. package/src/filterAminoAcidSequenceString.js +13 -0
  51. package/src/filterAminoAcidSequenceString.test.js +22 -0
  52. package/src/filterSequenceString.js +22 -0
  53. package/src/filterSequenceString.test.js +13 -0
  54. package/src/findNearestRangeOfSequenceOverlapToPosition.js +39 -0
  55. package/src/findNearestRangeOfSequenceOverlapToPosition.test.js +31 -0
  56. package/src/findOrfsInPlasmid.js +26 -0
  57. package/src/findSequenceMatches.js +133 -0
  58. package/src/findSequenceMatches.test.js +286 -0
  59. package/src/generateAnnotations.js +34 -0
  60. package/src/generateSequenceData.js +206 -0
  61. package/src/generateSequenceData.test.js +22 -0
  62. package/src/getAllInsertionsInSeqReads.js +83 -0
  63. package/src/getAllInsertionsInSeqReads.test.js +26 -0
  64. package/src/getAminoAcidDataForEachBaseOfDna.js +163 -0
  65. package/src/getAminoAcidDataForEachBaseOfDna.test.js +424 -0
  66. package/src/getAminoAcidFromSequenceTriplet.js +22 -0
  67. package/src/getAminoAcidStringFromSequenceString.js +18 -0
  68. package/src/getAminoAcidStringFromSequenceString.test.js +18 -0
  69. package/src/getCodonRangeForAASliver.js +63 -0
  70. package/src/getComplementAminoAcidStringFromSequenceString.js +11 -0
  71. package/src/getComplementSequenceAndAnnotations.js +20 -0
  72. package/src/getComplementSequenceString.js +19 -0
  73. package/src/getComplementSequenceString.test.js +13 -0
  74. package/src/getCutsiteType.js +10 -0
  75. package/src/getCutsitesFromSequence.js +17 -0
  76. package/src/getDegenerateDnaStringFromAAString.js +8 -0
  77. package/src/getDegenerateRnaStringFromAAString.js +8 -0
  78. package/src/getDigestFragmentsForCutsites.js +105 -0
  79. package/src/getDigestFragmentsForRestrictionEnzymes.js +27 -0
  80. package/src/getDigestFragmentsForRestrictionEnzymes.test.js +228 -0
  81. package/src/getInsertBetweenVals.js +28 -0
  82. package/src/getInsertBetweenVals.test.js +33 -0
  83. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.js +39 -0
  84. package/src/getLeftAndRightOfSequenceInRangeGivenPosition.test.js +80 -0
  85. package/src/getMassOfAaString.js +24 -0
  86. package/src/getMassofAaString.test.js +18 -0
  87. package/src/getOrfsFromSequence.js +124 -0
  88. package/src/getOrfsFromSequence.test.js +210 -0
  89. package/src/getOverlapBetweenTwoSequences.js +30 -0
  90. package/src/getOverlapBetweenTwoSequences.test.js +23 -0
  91. package/src/getPossiblePartsFromSequenceAndEnzymes.js +121 -0
  92. package/src/getPossiblePartsFromSequenceAndEnzymes.test.js +208 -0
  93. package/src/getReverseAminoAcidStringFromSequenceString.js +20 -0
  94. package/src/getReverseAminoAcidStringFromSequenceString.test.js +11 -0
  95. package/src/getReverseComplementAminoAcidStringFromSequenceString.js +7 -0
  96. package/src/getReverseComplementAnnotation.js +23 -0
  97. package/src/getReverseComplementAnnotation.test.js +44 -0
  98. package/src/getReverseComplementSequenceAndAnnotations.js +38 -0
  99. package/src/getReverseComplementSequenceAndAnnotations.test.js +105 -0
  100. package/src/getReverseComplementSequenceString.js +17 -0
  101. package/src/getReverseComplementSequenceString.test.js +11 -0
  102. package/src/getReverseSequenceString.js +12 -0
  103. package/src/getReverseSequenceString.test.js +9 -0
  104. package/src/getSequenceDataBetweenRange.js +131 -0
  105. package/src/getSequenceDataBetweenRange.test.js +474 -0
  106. package/src/getVirtualDigest.js +125 -0
  107. package/src/getVirtualDigest.test.js +134 -0
  108. package/src/guessIfSequenceIsDnaAndNotProtein.js +33 -0
  109. package/src/guessIfSequenceIsDnaAndNotProtein.test.js +34 -0
  110. package/src/index.js +106 -0
  111. package/src/index.test.js +38 -0
  112. package/src/insertGapsIntoRefSeq.js +38 -0
  113. package/src/insertGapsIntoRefSeq.test.js +20 -0
  114. package/src/insertSequenceDataAtPosition.js +2 -0
  115. package/src/insertSequenceDataAtPosition.test.js +75 -0
  116. package/src/insertSequenceDataAtPositionOrRange.js +249 -0
  117. package/src/insertSequenceDataAtPositionOrRange.test.js +547 -0
  118. package/src/isEnzymeType2S.js +3 -0
  119. package/src/mapAnnotationsToRows.js +174 -0
  120. package/src/mapAnnotationsToRows.test.js +425 -0
  121. package/src/prepareCircularViewData.js +17 -0
  122. package/src/prepareCircularViewData.test.js +196 -0
  123. package/src/prepareRowData.js +41 -0
  124. package/src/prepareRowData.test.js +36 -0
  125. package/src/prepareRowData_output1.json +391 -0
  126. package/src/proteinAlphabet.js +257 -0
  127. package/src/rotateBpsToPosition.js +13 -0
  128. package/src/rotateBpsToPosition.test.js +6 -0
  129. package/src/rotateSequenceDataToPosition.js +48 -0
  130. package/src/rotateSequenceDataToPosition.test.js +71 -0
  131. package/src/shiftAnnotationsByLen.js +17 -0
  132. package/src/threeLetterSequenceStringToAminoAcidMap.js +106 -0
  133. package/src/tidyUpAnnotation.js +182 -0
  134. package/src/tidyUpSequenceData.js +169 -0
  135. package/src/tidyUpSequenceData.test.js +332 -0
@@ -0,0 +1,1039 @@
1
+ /* eslint-disable no-unused-expressions */
2
+ import {autoAnnotate, convertApELikeRegexToRegex, convertProteinSeqToDNAIupac} from "./autoAnnotate";
3
+
4
+ import {expect} from "chai";
5
+
6
+ describe("convertApELikeRegexToRegex", () => {
7
+ it(`converts as expected`, () => {
8
+ expect(convertApELikeRegexToRegex("TnC")).to.eq("T.C");
9
+ expect(convertApELikeRegexToRegex("TNC")).to.eq("T.C");
10
+ expect(convertApELikeRegexToRegex("TBC")).to.eq("T[CGT]C");
11
+ expect(convertApELikeRegexToRegex("T#C")).to.eq("T[^T]*?C");
12
+ expect(convertApELikeRegexToRegex("T#C<A")).to.eq("(T[^T]*?C|[^T]*?C|C)?A");
13
+ expect(convertApELikeRegexToRegex("T(GGGG)GC")).to.eq("TGGGGGC");
14
+ expect(convertApELikeRegexToRegex("T(#)CC")).to.eq("T[^T]*?CC");
15
+ expect(convertApELikeRegexToRegex("CA<ATT>TTGAG")).to.eq(
16
+ "(CA|A)?ATT(TTGAG|TTGA|TTG|TT|T)?"
17
+ );
18
+ expect(convertApELikeRegexToRegex("CAA>AT")).to.eq("CAA(AT|A)?");
19
+ expect(convertApELikeRegexToRegex("CAA>ATT")).to.eq("CAA(ATT|AT|A)?");
20
+ expect(convertApELikeRegexToRegex("CAA>TBT")).to.eq(
21
+ "CAA(T[CGT]T|T[CGT]|T)?"
22
+ );
23
+ expect(convertApELikeRegexToRegex("CA<ATTT")).to.eq("(CA|A)?ATTT");
24
+ expect(convertApELikeRegexToRegex("NA<ATTT")).to.eq("(.A|A)?ATTT");
25
+ expect(convertApELikeRegexToRegex("BA<ATTT")).to.eq("([CGT]A|A)?ATTT");
26
+ expect(convertApELikeRegexToRegex("CATTT<ATTT")).to.eq(
27
+ "(CATTT|ATTT|TTT|TT|T)?ATTT"
28
+ );
29
+
30
+ });
31
+
32
+ it(`errors as expected`, () => {
33
+ try {
34
+ convertApELikeRegexToRegex("T#C<");
35
+ } catch (e) {
36
+ expect(e).to.exist;
37
+ }
38
+
39
+ });
40
+ it(`errors as expected`, () => {
41
+ try {
42
+ convertApELikeRegexToRegex("<C<");
43
+ } catch (e) {
44
+ expect(e).to.exist;
45
+ }
46
+
47
+ });
48
+ it(`errors as expected`, () => {
49
+ try {
50
+ convertApELikeRegexToRegex(">C>");
51
+ } catch (e) {
52
+ expect(e).to.exist;
53
+ }
54
+
55
+ });
56
+ it(`errors as expected`, () => {
57
+ try {
58
+ convertApELikeRegexToRegex(">C#");
59
+ } catch (e) {
60
+ expect(e).to.exist;
61
+ }
62
+
63
+ });
64
+ });
65
+ describe("autoAnnotate", () => {
66
+ // T#C
67
+ // AAAATTTTGGGGGCCCCCAAGT
68
+ // T(GGGG)GC
69
+ // AAAATTTTGGGGGCCCCCAAGT
70
+ // T(#)CC
71
+ // AAAATTTTGGGGGCCCCCAAGT
72
+ // CA<ATT>TTGAG
73
+ // AAAATTTTGGGGGCCCCCAAGT
74
+ // CA<ATTT
75
+ // AAAATTTTGGGGGCCCCCAAGT
76
+ it(`regexes work - correctly auto annotates a single seq with a regex annotation`, () => {
77
+ const results = autoAnnotate({
78
+ seqsToAnnotateById: {
79
+ 21: {
80
+ id: 21,
81
+ sequence: "AAAATTTTGGGGGCCCCCAAGT"
82
+ }
83
+ },
84
+
85
+ annotationsToCheckById: {
86
+ 31: {
87
+ id: 31,
88
+ sequence: "TTTT.*CCC",
89
+ name: "ann1",
90
+ type: "misc_feature"
91
+ }
92
+ }
93
+ });
94
+ expect(results).to.not.be.undefined;
95
+ //this should return an object keyed by the sequence id with the list of annotations to create
96
+ expect(results).to.deep.eq({
97
+ 21: [
98
+ //21 = sequenceId
99
+ //this is the list of new annotations to make
100
+ {
101
+ start: 4,
102
+ end: 17,
103
+ strand: 1,
104
+ id: 31
105
+ }
106
+ ]
107
+ });
108
+
109
+ });
110
+ it(`IUPAC # works - T#C should capture part of AAAATTTTGGGGGCCCCCAAGT`, () => {
111
+ const results = autoAnnotate({
112
+ seqsToAnnotateById: {
113
+ 21: {
114
+ id: 21,
115
+ sequence: "AAAATTTTGGGGGCCCCCAAGT"
116
+ // "ACTTGGGGGCCCCCAAAATTTT"
117
+ }
118
+ },
119
+
120
+ annotationsToCheckById: {
121
+ 31: {
122
+ id: 31,
123
+ sequence: convertApELikeRegexToRegex("T#C"),
124
+ name: "ann1",
125
+ type: "misc_feature"
126
+ }
127
+ }
128
+ });
129
+ expect(results).to.not.be.undefined;
130
+ //this should return an object keyed by the sequence id with the list of annotations to create
131
+ expect(results).to.deep.eq({
132
+ 21: [
133
+ //21 = sequenceId
134
+ //this is the list of new annotations to make
135
+ {
136
+ start: 7,
137
+ end: 13,
138
+ strand: 1,
139
+ id: 31
140
+ },
141
+ {
142
+ start: 12,
143
+ end: 18,
144
+ strand: -1,
145
+ id: 31
146
+ }
147
+ ]
148
+ });
149
+
150
+ });
151
+ it(`IUPAC # works - T#C<AAG should capture part of AAAATTTTGGGGGCCCCCAAGT`, () => {
152
+ const results = autoAnnotate({
153
+ seqsToAnnotateById: {
154
+ 21: {
155
+ id: 21,
156
+ sequence: "AAAATTTTGGGGGCCCCCAAGT"
157
+ }
158
+ },
159
+
160
+ annotationsToCheckById: {
161
+ 31: {
162
+ id: 31,
163
+ sequence: convertApELikeRegexToRegex("T#C<AAG"),
164
+ name: "ann1",
165
+ type: "misc_feature"
166
+ }
167
+ }
168
+ });
169
+ expect(results).to.not.be.undefined;
170
+ //this should return an object keyed by the sequence id with the list of annotations to create
171
+ expect(results).to.deep.eq({
172
+ 21: [
173
+ //21 = sequenceId
174
+ //this is the list of new annotations to make
175
+ {
176
+ start: 7,
177
+ end: 20,
178
+ strand: 1,
179
+ id: 31
180
+ }
181
+ ]
182
+ });
183
+
184
+ });
185
+ it(`IUPAC > works - CAA>ATT should capture all of CAAATT`, () => {
186
+ const results = autoAnnotate({
187
+ seqsToAnnotateById: {
188
+ 21: {
189
+ id: 21,
190
+ sequence: "CAAATT"
191
+ }
192
+ },
193
+
194
+ annotationsToCheckById: {
195
+ 31: {
196
+ id: 31,
197
+ sequence: convertApELikeRegexToRegex("CAA>ATT"),
198
+ name: "ann1",
199
+ type: "misc_feature"
200
+ }
201
+ }
202
+ });
203
+ expect(results).to.not.be.undefined;
204
+ //this should return an object keyed by the sequence id with the list of annotations to create
205
+ expect(results).to.deep.eq({
206
+ 21: [
207
+ //21 = sequenceId
208
+ //this is the list of new annotations to make
209
+ {
210
+ start: 0,
211
+ end: 5,
212
+ strand: 1,
213
+ id: 31
214
+ }
215
+ ]
216
+ });
217
+
218
+ });
219
+ it(`IUPAC > works - CAA>ATT should capture part of CAAATG`, () => {
220
+ const results = autoAnnotate({
221
+ seqsToAnnotateById: {
222
+ 21: {
223
+ id: 21,
224
+ sequence: "CAAATT"
225
+ }
226
+ },
227
+
228
+ annotationsToCheckById: {
229
+ 31: {
230
+ id: 31,
231
+ sequence: convertApELikeRegexToRegex("CAA>ATT"),
232
+ name: "ann1",
233
+ type: "misc_feature"
234
+ }
235
+ }
236
+ });
237
+ expect(results).to.not.be.undefined;
238
+ //this should return an object keyed by the sequence id with the list of annotations to create
239
+ expect(results).to.deep.eq({
240
+ 21: [
241
+ //21 = sequenceId
242
+ //this is the list of new annotations to make
243
+ {
244
+ start: 0,
245
+ end: 5,
246
+ strand: 1,
247
+ id: 31
248
+ }
249
+ ]
250
+ });
251
+
252
+ });
253
+ it(`complex IUPAC works - correctly auto annotates a single seq with a regex annotation`, () => {
254
+ const results = autoAnnotate({
255
+ seqsToAnnotateById: {
256
+ 21: {
257
+ id: 21,
258
+ sequence: "CGCATATTT"
259
+ }
260
+ },
261
+ annotationsToCheckById: {
262
+ 31: {
263
+ id: 31,
264
+ sequence: convertApELikeRegexToRegex("CCAT<ATTT"),
265
+ name: "ann1",
266
+ type: "misc_feature"
267
+ }
268
+ }
269
+ });
270
+ expect(results).to.not.be.undefined;
271
+ //this should return an object keyed by the sequence id with the list of annotations to create
272
+ expect(results).to.deep.eq({
273
+ 21: [
274
+ //21 = sequenceId
275
+ //this is the list of new annotations to make
276
+ {
277
+ start: 2,
278
+ end: 8,
279
+ strand: 1,
280
+ id: 31
281
+ }
282
+ ]
283
+ });
284
+
285
+ });
286
+ it(`another IUPAC works ccc<cTTT - correctly auto annotates a single seq with a regex annotation`, () => {
287
+ const results = autoAnnotate({
288
+ seqsToAnnotateById: {
289
+ 21: {
290
+ id: 21,
291
+ sequence: "ccccccTTT"
292
+ }
293
+ },
294
+
295
+ annotationsToCheckById: {
296
+ 31: {
297
+ id: 31,
298
+ sequence: convertApELikeRegexToRegex("ccc<cTTT"),
299
+ name: "ann1",
300
+ type: "misc_feature"
301
+ }
302
+ }
303
+ });
304
+ expect(results).to.not.be.undefined;
305
+ //this should return an object keyed by the sequence id with the list of annotations to create
306
+ expect(results).to.deep.eq({
307
+ 21: [
308
+ //21 = sequenceId
309
+ //this is the list of new annotations to make
310
+ {
311
+ start: 2,
312
+ end: 8,
313
+ strand: 1,
314
+ id: 31
315
+ }
316
+ ]
317
+ });
318
+
319
+ });
320
+ it(`long iupac < works - correctly auto annotates a single seq with a regex annotation`, () => {
321
+ const convertReg = convertApELikeRegexToRegex(
322
+ "gacgtcttatgacaacttgacggctacatcattcactttttcttcacaaccggcacggaactcgctcgggctggccccggtgcattttttaaatacccgcgagaaatagagttgatcgtcaaaaccaacattgcgaccgacggtggcgataggcatccgggtggtgctcaaaagcagcttcgcctggctgatacgttggtc<ctcgc"
323
+ );
324
+ const results = autoAnnotate({
325
+ seqsToAnnotateById: {
326
+ 21: {
327
+ id: 21,
328
+ sequence:
329
+ "gacgtcttatgacaacttgacggctacatcattcactttttcttcacaaccggcacggaactcgctcgggctggccccggtgcattttttaaatacccgcgagaaatagagttgatcgtcaaaaccaacattgcgaccgacggtggcgataggcatccgggtggtgctcaaaagcagcttcgcctggctgatacgttggtcctcgcgccagcttaagacgctaatccctaactgctggcggaaaagatgtgacagacgcgacggcgacaagcaaacatgctgtgcgacgctggcgatatcaaaattgctgtctgccaggtgatcgctgatgtactgacaagcctcgcgtacccgattatccatcggtggatggagcgactcgttaatcgcttccatgcgccgcagtaacaattgctcaagcagatttatcgccagcagctccgaatagcgcccttccccttgcccggcgttaatgatttgcccaaacaggtcgctgaaatgcggctggtgcgcttcatccgggcgaaagaaccccgtattggcaaatattgacggccagttaagccattcatgccagtaggcgcgcggacgaaagtaaacccactggtgataccattcgcgagcctccggatgacgaccgtagtgatgaatctctcctggcgggaacagcaaaatatcacccggtcggcaaacaaattctcgtccctgatttttcaccaccccctgaccgcgaatggtgagattgagaatataacctttcattcccagcggtcggtcgataaaaaaatcgagataaccgttggcctcaatcggcgttaaacccgccaccagatgggcattaaacgagtatcccggcagcaggggatcattttgcgcttcagccatacttttcatactcccgccattcagagaagaaaccaattgtccatattgcatcagacattgccgtcactgcgtcttttactggctcttctcgctaaccaaaccggtaaccccgcttattaaaagcattctgtaacaaagcgggaccaaagccatgacaaaaacgcgtaacaaaagtgtctataatcacggcagaaaagtccacattgattatttgcacggcgtcacactttgctatgccatagcatttttatccataagattagcggattctacctgacgctttttatcgcaactctctactgtttctccatacccgtttttttgggaatttttaagaaggagatatacatatgagtaaaggagaagaacttttcactggagttgtcccaattcttgttgaattagatggtgatgttaatgggcacaaattttctgtcagtggagagggtgaaggtgatgcaacatacggaaaacttacccttaaatttatttgcactactggaaaactacctgttccatggccaacacttgtcactactttctcttatggtgttcaatgcttttcccgttatccggatcatatgaaacggcatgactttttcaagagtgccatgcccgaaggttatgtacaggaacgcactatatctttcaaagatgacgggaactacaagacgcgtgctgaagtcaagtttgaaggtgatacccttgttaatcgtatcgagttaaaaggtattgattttaaagaagatggaaacattctcggacacaaactcgaatacaactataactcacacaatgtatacatcacggcagacaaacaaaagaatggaatcaaagctaacttcaaaattcgccacaacattgaagatggatctgttcaactagcagaccattatcaacaaaatactccaattggcgatggccctgtccttttaccagacaaccattacctgtcgacacaatctgccctttcgaaagatcccaacgaaaagcgtgaccacatggtccttcttgagtttgtaactgctgctgggattacacatggcatggatgagctcggcggcggcggcagcaaggtctacggcaaggaacagtttttgcggatgcgccagagcatgttccccgatcgctaaatcgagtaaggatctccaggcatcaaataaaacgaaaggctcagtcgaaagactgggcctttcgttttatctgttgtttgtcggtgaacgctctctactagagtcacactggctcaccttcgggtgggcctttctgcgtttatacctagggtacgggttttgctgcccgcaaacgggctgttctggtgttgctagtttgttatcagaatcgcagatccggcttcagccggtttgccggctgaaagcgctatttcttccagaattgccatgattttttccccacgggaggcgtcactggctcccgtgttgtcggcagctttgattcgataagcagcatcgcctgtttcaggctgtctatgtgtgactgttgagctgtaacaagttgtctcaggtgttcaatttcatgttctagttgctttgttttactggtttcacctgttctattaggtgttacatgctgttcatctgttacattgtcgatctgttcatggtgaacagctttgaatgcaccaaaaactcgtaaaagctctgatgtatctatcttttttacaccgttttcatctgtgcatatggacagttttccctttgatatgtaacggtgaacagttgttctacttttgtttgttagtcttgatgcttcactgatagatacaagagccataagaacctcagatccttccgtatttagccagtatgttctctagtgtggttcgttgtttttgcgtgagccatgagaacgaaccattgagatcatacttactttgcatgtcactcaaaaattttgcctcaaaactggtgagctgaatttttgcagttaaagcatcgtgtagtgtttttcttagtccgttatgtaggtaggaatctgatgtaatggttgttggtattttgtcaccattcatttttatctggttgttctcaagttcggttacgagatccatttgtctatctagttcaacttggaaaatcaacgtatcagtcgggcggcctcgcttatcaaccaccaatttcatattgctgtaagtgtttaaatctttacttattggtttcaaaacccattggttaagccttttaaactcatggtagttattttcaagcattaacatgaacttaaattcatcaaggctaatctctatatttgccttgtgagttttcttttgtgttagttcttttaataaccactcataaatcctcatagagtatttgttttcaaaagacttaacatgttccagattatattttatgaatttttttaactggaaaagataaggcaatatctcttcactaaaaactaattctaatttttcgcttgagaacttggcatagtttgtccactggaaaatctcaaagcctttaaccaaaggattcctgatttccacagttctcgtcatcagctctctggttgctttagctaatacaccataagcattttccctactgatgttcatcatctgagcgtattggttataagtgaacgataccgtccgttctttccttgtagggttttcaatcgtggggttgagtagtgccacacagcataaaattagcttggtttcatgctccgttaagtcatagcgactaatcgctagttcatttgctttgaaaacaactaattcagacatacatctcaattggtctaggtgattttaatcactataccaattgagatgggctagtcaatgataattactagtccttttcccgggtgatctgggtatctgtaaattctgctagacctttgctggaaaacttgtaaattctgctagaccctctgtaaattccgctagacctttgtgtgttttttttgtttatattcaagtggttataatttatagaataaagaaagaataaaaaaagataaaaagaatagatcccagccctgtgtataactcactactttagtcagttccgcagtattacaaaaggatgtcgcaaacgctgtttgctcctctacaaaacagaccttaaaaccctaaaggcttaagtagcaccctcgcaagctcgggcaaatcgctgaatattccttttgtctccgaccatcaggcacctgagtcgctgtctttttcgtgacattcagttcgctgcgctcacggctctggcagtgaatgggggtaaatggcactacaggcgccttttatggattcatgcaaggaaactacccataatacaagaaaagcccgtcacgggcttctcagggcgttttatggcgggtctgctatgtggtgctatctgactttttgctgttcagcagttcctgccctctgattttccagtctgaccacttcggattatcccgtgacaggtcattcagactggctaatgcacccagtaaggcagcggtatcatcaacaggcttacccgtcttactgtccctagtgcttggattctcaccaataaaaaacgcccggcggcaaccgagcgttctgaacaaatccagatggagttctgaggtcattactggatctatcaacaggagtccaagcgagctcgatatcaaattacgccccgccctgccactcatcgcagtactgttgtaattcattaagcattctgccgacatggaagccatcacaaacggcatgatgaacctgaatcgccagcggcatcagcaccttgtcgccttgcgtataatatttgcccatggtgaaaacgggggcgaagaagttgtccatattggccacgtttaaatcaaaactggtgaaactcacccagggattggctgagacgaaaaacatattctcaataaaccctttagggaaataggccaggttttcaccgtaacacgccacatcttgcgaatatatgtgtagaaactgccggaaatcgtcgtggtattcactccagagcgatgaaaacgtttcagtttgctcatggaaaacggtgtaacaagggtgaacactatcccatatcaccagctcaccgtctttcattgccatacgaaattccggatgagcattcatcaggcgggcaagaatgtgaataaaggccggataaaacttgtgcttatttttctttacggtctttaaaaaggccgtaatatccagctgaacggtctggttataggtacattgagcaactgactgaaatgcctcaaaatgttctttacgatgccattgggatatatcaacggtggtatatccagtgatttttttctccattttagcttccttagctcctgaaaatctcgataactcaaaaaatacgcccggtagtgatcttatttcattatggtgaaagttggaacctcttacgtgccgatcaacgtctcattttcgccagatatc"
330
+ }
331
+ },
332
+
333
+ annotationsToCheckById: {
334
+ 31: {
335
+ id: 31,
336
+ sequence: convertReg,
337
+ name: "ann1",
338
+ type: "misc_feature"
339
+ }
340
+ }
341
+ });
342
+ expect(results).to.not.be.undefined;
343
+ //this should return an object keyed by the sequence id with the list of annotations to create
344
+ expect(results).to.deep.eq({
345
+ 21: [
346
+ {
347
+ start: 0,
348
+ end: 205,
349
+ strand: 1,
350
+ id: 31
351
+ },
352
+ {
353
+ start: 98,
354
+ end: 102,
355
+ strand: -1,
356
+ id: 31
357
+ },
358
+ {
359
+ start: 341,
360
+ end: 346,
361
+ strand: 1,
362
+ id: 31
363
+ },
364
+ {
365
+ start: 618,
366
+ end: 622,
367
+ strand: -1,
368
+ id: 31
369
+ },
370
+ {
371
+ start: 972,
372
+ end: 976,
373
+ strand: 1,
374
+ id: 31
375
+ },
376
+ {
377
+ start: 3002,
378
+ end: 3007,
379
+ strand: 1,
380
+ id: 31
381
+ },
382
+ {
383
+ start: 4006,
384
+ end: 4011,
385
+ strand: 1,
386
+ id: 31
387
+ },
388
+ {
389
+ start: 4496,
390
+ end: 4500,
391
+ strand: -1,
392
+ id: 31
393
+ }
394
+ ]
395
+ });
396
+
397
+ });
398
+
399
+ it(`correctly auto annotates a single dna seq with a single protein annotation`, () => {
400
+ const results = autoAnnotate({
401
+ seqsToAnnotateById: {
402
+ 21: {
403
+ id: 21,
404
+ sequence:
405
+ "gatgttgattctatcatctatctggccagatagatgatagaatcgagcatcgattctatcatctatctgtactatcgattctatcatctatctga",
406
+ // "DVDSIIYLAR*MIESSIDSIIYLYYRFYHLS"
407
+ // tcagatagatgatagaatcgatagtacagatagatgatagaatcgatgctcgattctatcatctatctggccagatagatgatagaatcaacatc
408
+ annotations: [
409
+ {
410
+ start: 5,
411
+ end: 11
412
+ }
413
+ ]
414
+ }
415
+ },
416
+ annotationsToCheckById: {
417
+ 31: {
418
+ id: 31,
419
+ matchType: "protein",
420
+ sequence: convertApELikeRegexToRegex(
421
+ convertProteinSeqToDNAIupac("MIESSIDSIIYL")
422
+ ),
423
+ name: "ann1",
424
+ type: "misc_feature"
425
+ }
426
+ }
427
+ });
428
+
429
+ expect(results).to.not.be.undefined;
430
+ //this should return an object keyed by the sequence id with the list of annotations to create
431
+ expect(results).to.deep.eq({
432
+ 21: [
433
+ //21 = sequenceId
434
+ //this is the list of new annotations to make
435
+ {
436
+ start: 33,
437
+ end: 68,
438
+ strand: 1,
439
+ id: 31
440
+ }
441
+ ]
442
+ });
443
+
444
+ });
445
+ it(`correctly auto annotates a single seq with a single annotation`, () => {
446
+ const results = autoAnnotate({
447
+ seqsToAnnotateById: {
448
+ 21: {
449
+ id: 21,
450
+ sequence:
451
+ "gatgttgattctatcatctatctggccagatagatgatagaatcgagcatcgattctatcatctatctgtactatcgattctatcatctatctga",
452
+ // tcagatagatgatagaatcgatagtacagatagatgatagaatcgatgctcgattctatcatctatctggccagatagatgatagaatcaacatc
453
+ annotations: [
454
+ {
455
+ start: 5,
456
+ end: 11
457
+ }
458
+ ]
459
+ }
460
+ },
461
+
462
+ annotationsToCheckById: {
463
+ 31: {
464
+ id: 31,
465
+ sequence: "gattctatcatctatctg", //cagatagatgatagaatc <-- rev comp
466
+ name: "ann1",
467
+ type: "misc_feature"
468
+ }
469
+ }
470
+ });
471
+
472
+ expect(results).to.not.be.undefined;
473
+ //this should return an object keyed by the sequence id with the list of annotations to create
474
+ expect(results).to.deep.eq({
475
+ 21: [
476
+ //21 = sequenceId
477
+ //this is the list of new annotations to make
478
+ {
479
+ start: 6,
480
+ end: 23,
481
+ strand: 1,
482
+ id: 31
483
+ },
484
+ {
485
+ start: 26,
486
+ end: 43,
487
+ strand: -1,
488
+ id: 31
489
+ },
490
+ {
491
+ start: 51,
492
+ end: 68,
493
+ strand: 1,
494
+ id: 31
495
+ },
496
+ {
497
+ start: 76,
498
+ end: 93,
499
+ strand: 1,
500
+ id: 31
501
+ }
502
+ ]
503
+ });
504
+
505
+ });
506
+ it(`correctly auto annotates a single seq with a full spanning annotation`, () => {
507
+ const results = autoAnnotate({
508
+ seqsToAnnotateById: {
509
+ 21: {
510
+ id: 21,
511
+ sequence: "ttttttt"
512
+ }
513
+ },
514
+ annotationsToCheckById: {
515
+ 31: {
516
+ id: 31,
517
+ sequence: "ttttttt",
518
+ name: "ann1",
519
+ type: "misc_feature"
520
+ }
521
+ }
522
+ });
523
+ //this should return an object keyed by the sequence id with the list of annotations to create
524
+ expect(results).to.deep.eq({
525
+ 21: [{ id: 31, strand: 1, start: 0, end: 6 }]
526
+ });
527
+
528
+ });
529
+ it(`a "warning threshold" works as expected`, () => {
530
+ const results = autoAnnotate({
531
+ warnIfMoreThan: 5,
532
+ seqsToAnnotateById: {
533
+ 21: {
534
+ id: 21,
535
+ sequence: "ttttttt"
536
+ }
537
+ },
538
+ annotationsToCheckById: {
539
+ 31: {
540
+ id: 31,
541
+ sequence: "t",
542
+ name: "ann1",
543
+ type: "misc_feature"
544
+ }
545
+ }
546
+ });
547
+ //this should return an object keyed by the sequence id with the list of annotations to create
548
+ expect(results).to.deep.eq({
549
+ 21: [
550
+ {
551
+ start: 0,
552
+ end: 0,
553
+ strand: 1,
554
+ id: 31
555
+ },
556
+ {
557
+ start: 1,
558
+ end: 1,
559
+ strand: 1,
560
+ id: 31
561
+ },
562
+ {
563
+ start: 2,
564
+ end: 2,
565
+ strand: 1,
566
+ id: 31
567
+ },
568
+ {
569
+ start: 3,
570
+ end: 3,
571
+ strand: 1,
572
+ id: 31
573
+ },
574
+ {
575
+ start: 4,
576
+ end: 4,
577
+ strand: 1,
578
+ id: 31
579
+ },
580
+ {
581
+ start: 5,
582
+ end: 5,
583
+ strand: 1,
584
+ id: 31
585
+ },
586
+ {
587
+ start: 6,
588
+ end: 6,
589
+ strand: 1,
590
+ id: 31
591
+ }
592
+ ],
593
+ __more_than_warnings: {
594
+ 21: ["31"]
595
+ }
596
+ });
597
+
598
+ });
599
+ it(`correctly does not auto annotate two seqs when an annotation spans them`, () => {
600
+ const results = autoAnnotate({
601
+ seqsToAnnotateById: {
602
+ 21: {
603
+ id: 21,
604
+ sequence: "ttttttt"
605
+ },
606
+ 22: {
607
+ id: 22,
608
+ sequence: "aaaaaaa"
609
+ }
610
+ },
611
+
612
+ annotationsToCheckById: {
613
+ 31: {
614
+ id: 31,
615
+ sequence: "tttaaa",
616
+ name: "ann1",
617
+ type: "misc_feature"
618
+ }
619
+ }
620
+ });
621
+ //this should return an object keyed by the sequence id with the list of annotations to create
622
+ expect(results).to.deep.eq({});
623
+
624
+ });
625
+ it(`correctly auto annotates two seqs when an annotation spans the origin on the 2nd seq`, () => {
626
+ const results = autoAnnotate({
627
+ seqsToAnnotateById: {
628
+ 21: {
629
+ circular: true,
630
+ id: 21,
631
+ sequence: "ttttttt"
632
+ },
633
+ 22: {
634
+ circular: true,
635
+ id: 22,
636
+ sequence: "aaaaaaaattg"
637
+ }
638
+ },
639
+
640
+ annotationsToCheckById: {
641
+ 31: {
642
+ id: 31,
643
+ sequence: "attga",
644
+ name: "ann1",
645
+ type: "misc_feature"
646
+ }
647
+ }
648
+ });
649
+ expect(results).to.deep.eq({
650
+ 22: [
651
+ {
652
+ start: 7,
653
+ end: 0,
654
+ strand: 1,
655
+ id: 31
656
+ }
657
+ ]
658
+ });
659
+
660
+ });
661
+ it(`correctly auto annotates two seq when the casing on the annotation and seq is wonky`, () => {
662
+ const results = autoAnnotate({
663
+ seqsToAnnotateById: {
664
+ 21: {
665
+ circular: true,
666
+ id: 21,
667
+ sequence: "ttttTtt"
668
+ },
669
+ 22: {
670
+ circular: true,
671
+ id: 22,
672
+ sequence: "aAaaaaaaTtg"
673
+ }
674
+ },
675
+
676
+ annotationsToCheckById: {
677
+ 31: {
678
+ id: 31,
679
+ sequence: "atTgA",
680
+ name: "ann1",
681
+ type: "misc_feature"
682
+ }
683
+ }
684
+ });
685
+ //this should return an object keyed by the sequence id with the list of annotations to create
686
+ expect(results).to.deep.eq({
687
+ 22: [
688
+ {
689
+ id: 31,
690
+ strand: 1,
691
+ start: 7,
692
+ end: 0
693
+ }
694
+ ]
695
+ });
696
+
697
+ });
698
+
699
+ it(`correctly auto annotates a 1 bp seq`, () => {
700
+ const results = autoAnnotate({
701
+ seqsToAnnotateById: {
702
+ 21: {
703
+ circular: true,
704
+ id: 21,
705
+ sequence: "t"
706
+ }
707
+ },
708
+ annotationsToCheckById: {
709
+ 31: {
710
+ id: 31,
711
+ sequence: "t",
712
+ name: "ann1",
713
+ type: "misc_feature"
714
+ }
715
+ }
716
+ });
717
+ //this should return an object keyed by the sequence id with the list of annotations to create
718
+ expect(results).to.deep.eq({
719
+ 21: [
720
+ {
721
+ id: 31,
722
+ strand: 1,
723
+ start: 0,
724
+ end: 0
725
+ }
726
+ ]
727
+ });
728
+
729
+ });
730
+ it(`correctly does not auto annotate a 1 bp seq when a feature already spans that seq`, () => {
731
+ const results = autoAnnotate({
732
+ seqsToAnnotateById: {
733
+ 21: {
734
+ circular: true,
735
+ id: 21,
736
+ sequence: "t",
737
+ annotations: [{ start: 0, end: 0 }]
738
+ }
739
+ },
740
+ annotationsToCheckById: {
741
+ 31: {
742
+ id: 31,
743
+ sequence: "t",
744
+ name: "ann1",
745
+ type: "misc_feature"
746
+ }
747
+ }
748
+ });
749
+ //this should return an object keyed by the sequence id with the list of annotations to create
750
+ expect(results).to.deep.eq({});
751
+
752
+ });
753
+ it(`correctly auto annotates a 1 bp seq when compareName:true when a feature with a different name already spans that seq`, () => {
754
+ const results = autoAnnotate({
755
+ seqsToAnnotateById: {
756
+ 21: {
757
+ circular: true,
758
+ id: 21,
759
+ sequence: "t",
760
+ annotations: [{ start: 0, end: 0, name: "someothername" }]
761
+ }
762
+ },
763
+ annotationsToCheckById: {
764
+ 31: {
765
+ id: 31,
766
+ sequence: "t",
767
+ name: "ann1",
768
+ type: "misc_feature"
769
+ }
770
+ },
771
+ compareName: true
772
+ });
773
+ //this should return an object keyed by the sequence id with the list of annotations to create
774
+ expect(results).to.deep.eq({
775
+ 21: [
776
+ {
777
+ id: 31,
778
+ strand: 1,
779
+ start: 0,
780
+ end: 0
781
+ }
782
+ ]
783
+ });
784
+
785
+ });
786
+ it(`correctly does not auto annotate several seqs when annotations already span those seqs`, () => {
787
+ const results = autoAnnotate({
788
+ seqsToAnnotateById: {
789
+ 21: {
790
+ circular: true,
791
+ id: 21,
792
+ sequence: "t",
793
+ annotations: [{ start: 0, end: 0, strand: 1 }]
794
+ },
795
+ 22: {
796
+ circular: true,
797
+ id: 22,
798
+ sequence: "gggggt",
799
+ annotations: [
800
+ { start: 3, end: 5 },
801
+ { start: 5, end: 5 }
802
+ ]
803
+ }
804
+ },
805
+ annotationsToCheckById: {
806
+ 31: {
807
+ id: 31,
808
+ sequence: "t",
809
+ name: "ann1",
810
+ type: "misc_feature"
811
+ },
812
+ 32: {
813
+ id: 32,
814
+ sequence: "ggt",
815
+ name: "ann2",
816
+ type: "misc_feature"
817
+ }
818
+ }
819
+ });
820
+ //this should return an object keyed by the sequence id with the list of annotations to create
821
+ expect(results).to.deep.eq({});
822
+
823
+ });
824
+ it(`correctly auto annotates two seqs when a annotation spans the origin on the 2nd seq on the negative strand`, () => {
825
+ const results = autoAnnotate({
826
+ seqsToAnnotateById: {
827
+ 21: {
828
+ circular: true,
829
+ id: 21,
830
+ sequence: "ttttttt"
831
+ },
832
+ 22: {
833
+ circular: true, //
834
+ id: 22, //01234567890
835
+ //caat t
836
+ sequence: "aaaaaaaattg" //caatttttttt
837
+ //aaaaaaaattg
838
+ //a attg
839
+ }
840
+ },
841
+
842
+ annotationsToCheckById: {
843
+ 31: {
844
+ id: 31,
845
+ sequence: "tcaat",
846
+ name: "ann1",
847
+ type: "misc_feature"
848
+ }
849
+ }
850
+ });
851
+ //this should return an object keyed by the sequence id with the list of annotations to create
852
+ expect(results).to.deep.eq({
853
+ 22: [
854
+ {
855
+ id: 31,
856
+ strand: -1,
857
+ start: 7,
858
+ end: 0
859
+ }
860
+ ]
861
+ });
862
+
863
+ });
864
+ it(`correctly auto annotates a seq when an annotation matches multiple times overlapping`, () => {
865
+ const results = autoAnnotate({
866
+ seqsToAnnotateById: {
867
+ 22: {
868
+ id: 22,
869
+ sequence: "aaaaa"
870
+ }
871
+ },
872
+ annotationsToCheckById: {
873
+ 31: {
874
+ id: 31,
875
+ sequence: "aaaa",
876
+ name: "ann1",
877
+ type: "misc_feature"
878
+ }
879
+ }
880
+ });
881
+ expect(results).to.deep.eq({
882
+ 22: [
883
+ {
884
+ id: 31,
885
+ strand: 1,
886
+ start: 0,
887
+ end: 3
888
+ },
889
+ {
890
+ id: 31,
891
+ strand: 1,
892
+ start: 1,
893
+ end: 4
894
+ }
895
+ ]
896
+ });
897
+
898
+ });
899
+ it(`correctly auto annotates two seqs when an annotation matches multiple times overlapping on the 2nd seq`, () => {
900
+ const results = autoAnnotate({
901
+ seqsToAnnotateById: {
902
+ 20: {
903
+ id: 20,
904
+ sequence: "aaaagg"
905
+ },
906
+ 22: {
907
+ id: 22,
908
+ sequence: "aaaaa"
909
+ }
910
+ },
911
+
912
+ annotationsToCheckById: {
913
+ 31: {
914
+ id: 31,
915
+ sequence: "aaaa",
916
+ name: "ann1",
917
+ type: "misc_feature"
918
+ }
919
+ }
920
+ });
921
+ expect(results).to.deep.eq({
922
+ 20: [
923
+ {
924
+ id: 31,
925
+ strand: 1,
926
+ start: 0,
927
+ end: 3
928
+ }
929
+ ],
930
+ 22: [
931
+ {
932
+ id: 31,
933
+ strand: 1,
934
+ start: 0,
935
+ end: 3
936
+ },
937
+ {
938
+ id: 31,
939
+ strand: 1,
940
+ start: 1,
941
+ end: 4
942
+ }
943
+ ]
944
+ });
945
+
946
+ });
947
+ it(`correctly auto annotates multiple sequences and multiple annotations`, () => {
948
+ const results = autoAnnotate({
949
+ seqsToAnnotateById: {
950
+ 21: {
951
+ id: 21,
952
+ sequence: "gatgttgattctatcatctatctggcgagcatctactatca",
953
+ annotations: [
954
+ {
955
+ strand: -1, //this annotation should not be matched cause it is on the reverse strand!
956
+ start: 5,
957
+ end: 11
958
+ }
959
+ ]
960
+ },
961
+ 45: {
962
+ id: 45,
963
+ circular: true,
964
+ sequence:
965
+ "gatgttgattctatcgtttttttttttaaaaaaagatgttgattctatcgtttttttttttaaaaaaactggcgagcatctactatca"
966
+ }
967
+ },
968
+ annotationsToCheckById: {
969
+ 31: {
970
+ id: 31,
971
+ sequence: "ttttttttttaaaaa" //tttttaaaaaaaaaa
972
+ },
973
+ 84: {
974
+ id: 84,
975
+ sequence: "tgattct", //agaatca
976
+ name: "zoink1"
977
+ },
978
+ 90: {
979
+ id: 90,
980
+ sequence: "ctatcagatgttg" //crosses the origin on seq45 //caacatctgatag
981
+ },
982
+ 91: {
983
+ id: 91,
984
+ sequence: "ctcgccagatagatga" //tcatctatctggcgag revcomp on 21
985
+ }
986
+ }
987
+ });
988
+ expect(results).to.not.be.undefined;
989
+ expect(results).to.deep.eq({
990
+ 21: [
991
+ {
992
+ strand: 1,
993
+ start: 5,
994
+ end: 11,
995
+ id: 84
996
+ },
997
+ {
998
+ strand: -1,
999
+ start: 13,
1000
+ end: 28,
1001
+ id: 91
1002
+ }
1003
+ ],
1004
+ 45: [
1005
+ {
1006
+ strand: 1,
1007
+ start: 5,
1008
+ end: 11,
1009
+ id: 84
1010
+ },
1011
+ {
1012
+ strand: 1,
1013
+ start: 17,
1014
+ end: 31,
1015
+ id: 31
1016
+ },
1017
+ {
1018
+ strand: 1,
1019
+ start: 39,
1020
+ end: 45,
1021
+ id: 84
1022
+ },
1023
+ {
1024
+ strand: 1,
1025
+ start: 51,
1026
+ end: 65,
1027
+ id: 31
1028
+ },
1029
+ {
1030
+ strand: 1,
1031
+ start: 82,
1032
+ end: 6,
1033
+ id: 90
1034
+ }
1035
+ ]
1036
+ });
1037
+
1038
+ });
1039
+ });