react-msaview 1.3.1 → 2.0.0

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 (200) hide show
  1. package/bundle/index.js +283 -97265
  2. package/dist/StructureModel.d.ts +9 -0
  3. package/dist/StructureModel.js +11 -0
  4. package/dist/StructureModel.js.map +1 -0
  5. package/dist/UniprotTrack.d.ts +27 -0
  6. package/dist/UniprotTrack.js +52 -0
  7. package/dist/UniprotTrack.js.map +1 -0
  8. package/dist/colorSchemes.d.ts +2 -2
  9. package/dist/colorSchemes.js +24 -29
  10. package/dist/colorSchemes.js.map +1 -0
  11. package/dist/components/AboutDlg.d.ts +0 -1
  12. package/dist/components/AboutDlg.js +38 -48
  13. package/dist/components/AboutDlg.js.map +1 -0
  14. package/dist/components/AddTrackDlg.d.ts +0 -1
  15. package/dist/components/AddTrackDlg.js +13 -13
  16. package/dist/components/AddTrackDlg.js.map +1 -0
  17. package/dist/components/AnnotationDlg.d.ts +0 -1
  18. package/dist/components/AnnotationDlg.js +36 -48
  19. package/dist/components/AnnotationDlg.js.map +1 -0
  20. package/dist/components/BoxTrack.d.ts +3 -4
  21. package/dist/components/BoxTrack.js +51 -48
  22. package/dist/components/BoxTrack.js.map +1 -0
  23. package/dist/components/DetailsDlg.d.ts +0 -1
  24. package/dist/components/DetailsDlg.js +7 -7
  25. package/dist/components/DetailsDlg.js.map +1 -0
  26. package/dist/components/Header.d.ts +0 -1
  27. package/dist/components/Header.js +39 -34
  28. package/dist/components/Header.js.map +1 -0
  29. package/dist/components/ImportForm.d.ts +0 -1
  30. package/dist/components/ImportForm.js +59 -71
  31. package/dist/components/ImportForm.js.map +1 -0
  32. package/dist/components/MSACanvas.d.ts +0 -1
  33. package/dist/components/MSACanvas.js +71 -74
  34. package/dist/components/MSACanvas.js.map +1 -0
  35. package/dist/components/MSAView.d.ts +0 -1
  36. package/dist/components/MSAView.js +19 -38
  37. package/dist/components/MSAView.js.map +1 -0
  38. package/dist/components/MoreInfoDlg.d.ts +2 -3
  39. package/dist/components/MoreInfoDlg.js +5 -5
  40. package/dist/components/MoreInfoDlg.js.map +1 -0
  41. package/dist/components/ResizeHandles.d.ts +2 -3
  42. package/dist/components/ResizeHandles.js +31 -32
  43. package/dist/components/ResizeHandles.js.map +1 -0
  44. package/dist/components/Rubberband.d.ts +2 -1
  45. package/dist/components/Rubberband.js +42 -64
  46. package/dist/components/Rubberband.js.map +1 -0
  47. package/dist/components/Ruler.d.ts +0 -15
  48. package/dist/components/Ruler.js +18 -87
  49. package/dist/components/Ruler.js.map +1 -0
  50. package/dist/components/SettingsDlg.d.ts +0 -1
  51. package/dist/components/SettingsDlg.js +29 -22
  52. package/dist/components/SettingsDlg.js.map +1 -0
  53. package/dist/components/TextTrack.d.ts +3 -4
  54. package/dist/components/TextTrack.js +23 -24
  55. package/dist/components/TextTrack.js.map +1 -0
  56. package/dist/components/Track.d.ts +2 -3
  57. package/dist/components/Track.js +38 -38
  58. package/dist/components/Track.js.map +1 -0
  59. package/dist/components/TrackInfoDlg.d.ts +5 -3
  60. package/dist/components/TrackInfoDlg.js +12 -13
  61. package/dist/components/TrackInfoDlg.js.map +1 -0
  62. package/dist/components/TracklistDlg.d.ts +0 -1
  63. package/dist/components/TracklistDlg.js +9 -9
  64. package/dist/components/TracklistDlg.js.map +1 -0
  65. package/dist/components/TreeCanvas.d.ts +0 -1
  66. package/dist/components/TreeCanvas.js +135 -148
  67. package/dist/components/TreeCanvas.js.map +1 -0
  68. package/dist/components/TreeRuler.d.ts +0 -1
  69. package/dist/components/TreeRuler.js +3 -3
  70. package/dist/components/TreeRuler.js.map +1 -0
  71. package/dist/components/VerticalGuide.d.ts +6 -0
  72. package/dist/components/VerticalGuide.js +30 -0
  73. package/dist/components/VerticalGuide.js.map +1 -0
  74. package/dist/components/data/seq2.d.ts +3 -3
  75. package/dist/components/data/seq2.js +33 -3
  76. package/dist/components/data/seq2.js.map +1 -0
  77. package/{bundle/components/Ruler.d.ts → dist/components/util.d.ts} +1 -6
  78. package/dist/components/util.js +69 -0
  79. package/dist/components/util.js.map +1 -0
  80. package/dist/index.d.ts +2 -4
  81. package/dist/index.js +3 -3
  82. package/dist/index.js.map +1 -0
  83. package/dist/layout.js +14 -20
  84. package/dist/layout.js.map +1 -0
  85. package/dist/model.d.ts +94 -74
  86. package/dist/model.js +232 -473
  87. package/dist/model.js.map +1 -0
  88. package/dist/parseNewick.d.ts +1 -5
  89. package/dist/parseNewick.js +10 -7
  90. package/dist/parseNewick.js.map +1 -0
  91. package/dist/parsers/ClustalMSA.d.ts +6 -18
  92. package/dist/parsers/ClustalMSA.js +55 -64
  93. package/dist/parsers/ClustalMSA.js.map +1 -0
  94. package/dist/parsers/FastaMSA.d.ts +4 -9
  95. package/dist/parsers/FastaMSA.js +55 -64
  96. package/dist/parsers/FastaMSA.js.map +1 -0
  97. package/dist/parsers/StockholmMSA.d.ts +8 -13
  98. package/dist/parsers/StockholmMSA.js +78 -107
  99. package/dist/parsers/StockholmMSA.js.map +1 -0
  100. package/dist/util.d.ts +33 -4
  101. package/dist/util.js +76 -24
  102. package/dist/util.js.map +1 -0
  103. package/dist/version.d.ts +1 -0
  104. package/dist/version.js +2 -0
  105. package/dist/version.js.map +1 -0
  106. package/package.json +30 -30
  107. package/src/StructureModel.ts +11 -0
  108. package/src/UniprotTrack.ts +60 -0
  109. package/src/colorSchemes.ts +520 -0
  110. package/src/components/AboutDlg.tsx +64 -0
  111. package/src/components/AddTrackDlg.tsx +74 -0
  112. package/src/components/AnnotationDlg.tsx +144 -0
  113. package/src/components/BoxTrack.tsx +225 -0
  114. package/src/components/DetailsDlg.tsx +28 -0
  115. package/src/components/Header.tsx +117 -0
  116. package/src/components/ImportForm.tsx +192 -0
  117. package/src/components/MSACanvas.tsx +297 -0
  118. package/src/components/MSAView.tsx +132 -0
  119. package/src/components/MoreInfoDlg.tsx +21 -0
  120. package/src/components/ResizeHandles.tsx +137 -0
  121. package/src/components/Rubberband.tsx +271 -0
  122. package/src/components/Ruler.tsx +122 -0
  123. package/src/components/SettingsDlg.tsx +154 -0
  124. package/src/components/TextTrack.tsx +120 -0
  125. package/src/components/Track.tsx +150 -0
  126. package/src/components/TrackInfoDlg.tsx +59 -0
  127. package/src/components/TracklistDlg.tsx +61 -0
  128. package/src/components/TreeCanvas.tsx +633 -0
  129. package/src/components/TreeRuler.tsx +12 -0
  130. package/src/components/VerticalGuide.tsx +50 -0
  131. package/src/components/data/seq2.ts +35 -0
  132. package/src/components/util.ts +94 -0
  133. package/src/declare.d.ts +2 -0
  134. package/src/index.ts +2 -0
  135. package/src/layout.ts +83 -0
  136. package/src/model.ts +790 -0
  137. package/{bundle/parseNewick.d.ts → src/parseNewick.ts} +36 -5
  138. package/src/parsers/ClustalMSA.ts +79 -0
  139. package/src/parsers/FastaMSA.ts +82 -0
  140. package/src/parsers/StockholmMSA.ts +137 -0
  141. package/src/util.ts +142 -0
  142. package/src/version.ts +1 -0
  143. package/bundle/colorSchemes.d.ts +0 -16
  144. package/bundle/colorSchemes.js +0 -455
  145. package/bundle/components/AboutDlg.d.ts +0 -5
  146. package/bundle/components/AboutDlg.js +0 -47
  147. package/bundle/components/AddTrackDlg.d.ts +0 -8
  148. package/bundle/components/AddTrackDlg.js +0 -26
  149. package/bundle/components/AnnotationDlg.d.ts +0 -11
  150. package/bundle/components/AnnotationDlg.js +0 -77
  151. package/bundle/components/BoxTrack.d.ts +0 -7
  152. package/bundle/components/BoxTrack.js +0 -143
  153. package/bundle/components/DetailsDlg.d.ts +0 -8
  154. package/bundle/components/DetailsDlg.js +0 -12
  155. package/bundle/components/Header.d.ts +0 -6
  156. package/bundle/components/Header.js +0 -63
  157. package/bundle/components/ImportForm.d.ts +0 -6
  158. package/bundle/components/ImportForm.js +0 -89
  159. package/bundle/components/MSACanvas.d.ts +0 -6
  160. package/bundle/components/MSACanvas.js +0 -210
  161. package/bundle/components/MSAView.d.ts +0 -6
  162. package/bundle/components/MSAView.js +0 -88
  163. package/bundle/components/MoreInfoDlg.d.ts +0 -6
  164. package/bundle/components/MoreInfoDlg.js +0 -11
  165. package/bundle/components/ResizeHandles.d.ts +0 -8
  166. package/bundle/components/ResizeHandles.js +0 -110
  167. package/bundle/components/Rubberband.d.ts +0 -7
  168. package/bundle/components/Rubberband.js +0 -196
  169. package/bundle/components/Ruler.js +0 -121
  170. package/bundle/components/SettingsDlg.d.ts +0 -8
  171. package/bundle/components/SettingsDlg.js +0 -40
  172. package/bundle/components/TextTrack.d.ts +0 -7
  173. package/bundle/components/TextTrack.js +0 -72
  174. package/bundle/components/Track.d.ts +0 -11
  175. package/bundle/components/Track.js +0 -81
  176. package/bundle/components/TrackInfoDlg.d.ts +0 -6
  177. package/bundle/components/TrackInfoDlg.js +0 -33
  178. package/bundle/components/TracklistDlg.d.ts +0 -8
  179. package/bundle/components/TracklistDlg.js +0 -18
  180. package/bundle/components/TreeCanvas.d.ts +0 -6
  181. package/bundle/components/TreeCanvas.js +0 -431
  182. package/bundle/components/TreeRuler.d.ts +0 -6
  183. package/bundle/components/TreeRuler.js +0 -8
  184. package/bundle/components/data/seq2.d.ts +0 -3
  185. package/bundle/components/data/seq2.js +0 -3
  186. package/bundle/index.d.ts +0 -4
  187. package/bundle/layout.d.ts +0 -23
  188. package/bundle/layout.js +0 -53
  189. package/bundle/model.d.ts +0 -364
  190. package/bundle/model.js +0 -894
  191. package/bundle/parseNewick.js +0 -94
  192. package/bundle/parsers/ClustalMSA.d.ts +0 -39
  193. package/bundle/parsers/ClustalMSA.js +0 -77
  194. package/bundle/parsers/FastaMSA.d.ts +0 -26
  195. package/bundle/parsers/FastaMSA.js +0 -78
  196. package/bundle/parsers/StockholmMSA.d.ts +0 -75
  197. package/bundle/parsers/StockholmMSA.js +0 -142
  198. package/bundle/util.d.ts +0 -17
  199. package/bundle/util.js +0 -33
  200. package/dist/components/package.json +0 -62
@@ -0,0 +1,35 @@
1
+ export const smallMSA = `CLUSTAL O(1.2.3) multiple sequence alignment
2
+ UniProt/Swiss-Prot|P26898|IL2RA_SHEEP MEPSLLMWRFFVFIVVPGCVTEACHDDPPSLRNA----------MFKVLRYE----VGTM
3
+ UniProt/Swiss-Prot|P01590|IL2RA_MOUSE MEPRLLMLGFLSLTIVPSCRAELCLYDPPEVPNA----------TFKALSYK----NGTI
4
+ UniProt/Swiss-Prot|P41690|IL2RA_FELCA MEPSLLLWGILTFVVVHGHVTELCDENPPDIQHA----------TFKALTYK----TGTM
5
+ UniProt/Swiss-Prot|P01589|IL2RA_HUMAN MDSYLLMWGLLTFIMVPGCQAELCDDDPPEIPHA----------TFKAMAYK----EGTM
6
+ UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU MDPYLLMWGLLTFITVPGCQAELCDDDPPKITHA----------TFKAVAYK----EGTM
7
+ UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN -----------------------------------LLMWGLLT-----------------
8
+ UniProt/Swiss-Prot|P40321|IL2RG_CANFA MLKPPLPLRSLLFLQLSLLGVGLNSTVPMPNGNEDIT------PDFFLTATPSETLSVSS
9
+ UniProt/Swiss-Prot|P26896|IL2RB_RAT MATVDLSWRLPLYILLLLLATT--------------------------------WVSAAV
10
+ UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE PLPLRSLLFLQLPLLGVGLNP------------------PLPLRSLLFLQLPLLGVGLNP
11
+ UniProt/Swiss-Prot|P36835|IL2_CAPHI -----------LLGVGLNPKFLTP------------------------------------
12
+ UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO MLKPPLPLRSLLFLQLPLLGVGLNPKFLTPSGNEDIGGKPGTGGDFFLTSTPAGTLDVST
13
+ UniProt/Swiss-Prot|Q29416|IL2_CANFA --------------LFLQLSLLG-------------------------------------
14
+ `
15
+
16
+ export const smallMSAOnly = `CLUSTAL O(1.2.4) multiple sequence alignment
17
+
18
+
19
+ sp|P69905|HBA_HUMAN MVLSPADKTNVKAAWGKVGAHAGEYGAEALERMFLSFPTTKTYFPHFDLSHGSAQVKGHG 60
20
+ sp|P01942|HBA_MOUSE MVLSGEDKSNIKAAWGKIGGHGAEYGAEALERMFASFPTTKTYFPHFDVSHGSAQVKGHG 60
21
+ sp|P13786|HBAZ_CAPHI MSLTRTERTIILSLWSKISTQADVIGTETLERLFSCYPQAKTYFPHFDLHSGSAQLRAHG 60
22
+ * *: ::: : : *.*:. :. *:*:***:* .:* :********: ****::.**
23
+
24
+ sp|P69905|HBA_HUMAN KKVADALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKLLSHCLLVTLAAHLPAEFTP 120
25
+ sp|P01942|HBA_MOUSE KKVADALASAAGHLDDLPGALSALSDLHAHKLRVDPVNFKLLSHCLLVTLASHHPADFTP 120
26
+ sp|P13786|HBAZ_CAPHI SKVVAAVGDAVKSIDNVTSALSKLSELHAYVLRVDPVNFKFLSHCLLVTLASHFPADFTA 120
27
+ .**. *: .*. :*:: .*** **:***: *********:**********:* **:**
28
+
29
+ sp|P69905|HBA_HUMAN AVHASLDKFLASVSTVLTSKYR 142
30
+ sp|P01942|HBA_MOUSE AVHASLDKFLASVSTVLTSKYR 142
31
+ sp|P13786|HBAZ_CAPHI DAHAAWDKFLSIVSGVLTEKYR 142
32
+ .**: ****: ** ***.***`
33
+
34
+ export const smallTree =
35
+ '(((UniProt/Swiss-Prot|P26898|IL2RA_SHEEP:0.24036,(UniProt/Swiss-Prot|P41690|IL2RA_FELCA:0.17737,(UniProt/Swiss-Prot|P01589|IL2RA_HUMAN:0.03906,UniProt/Swiss-Prot|Q5MNY4|IL2RA_MACMU:0.03787):0.13033):0.04964):0.02189,UniProt/Swiss-Prot|P01590|IL2RA_MOUSE:0.23072):0.06814,(((UniProt/Swiss-Prot|Q95118|IL2RG_BOVIN:0.09600,UniProt/Swiss-Prot|P40321|IL2RG_CANFA:0.09845):0.25333,UniProt/Swiss-Prot|Q29416|IL2_CANFA:-0.35055):0.10231,(UniProt/Swiss-Prot|P26896|IL2RB_RAT:0.33631,UniProt/Swiss-Prot|Q7JFM4|IL2_AOTVO:-0.33631):0.10166):0.01607,(UniProt/Swiss-Prot|Q8BZM1|GLMN_MOUSE:0.32378,UniProt/Swiss-Prot|P36835|IL2_CAPHI:-0.32378):0.09999)'
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Given a scale ( bp/px ) and minimum distances (px) between major and minor
3
+ * gridlines, return an object like `{ majorPitch: bp, minorPitch: bp }` giving
4
+ * the gridline pitches to use.
5
+ */
6
+ export function chooseGridPitch(
7
+ scale: number,
8
+ minMajorPitchPx: number,
9
+ minMinorPitchPx: number,
10
+ ) {
11
+ scale = Math.abs(scale)
12
+ const minMajorPitchBp = minMajorPitchPx * scale
13
+ const majorMagnitude = parseInt(
14
+ Number(minMajorPitchBp).toExponential().split(/e/i)[1],
15
+ 10,
16
+ )
17
+
18
+ let majorPitch = 10 ** majorMagnitude
19
+ while (majorPitch < minMajorPitchBp) {
20
+ majorPitch *= 2
21
+ if (majorPitch >= minMajorPitchBp) {
22
+ break
23
+ }
24
+ majorPitch *= 2.5
25
+ }
26
+
27
+ majorPitch = Math.max(majorPitch, 5)
28
+
29
+ const majorPitchPx = majorPitch / scale
30
+
31
+ let minorPitch = 0
32
+ if (!(majorPitch % 10) && majorPitchPx / 10 >= minMinorPitchPx) {
33
+ minorPitch = majorPitch / 10
34
+ } else if (!(majorPitch % 5) && majorPitchPx / 5 >= minMinorPitchPx) {
35
+ minorPitch = majorPitch / 5
36
+ } else if (!(majorPitch % 2) && majorPitchPx / 2 >= minMinorPitchPx) {
37
+ minorPitch = majorPitch / 2
38
+ }
39
+
40
+ return { majorPitch, minorPitch }
41
+ }
42
+ export function makeTicks(
43
+ start: number,
44
+ end: number,
45
+ bpPerPx: number,
46
+ emitMajor = true,
47
+ emitMinor = true,
48
+ ) {
49
+ const gridPitch = chooseGridPitch(bpPerPx, 60, 15)
50
+
51
+ let minBase = start
52
+ let maxBase = end
53
+ if (minBase === null || maxBase === null) {
54
+ return []
55
+ }
56
+
57
+ if (bpPerPx < 0) {
58
+ // eslint-disable-next-line @typescript-eslint/no-extra-semi
59
+ ;[minBase, maxBase] = [maxBase, minBase]
60
+ }
61
+
62
+ // add 20px additional on the right and left to allow us to draw the ends of
63
+ // labels that lie a little outside our region
64
+ minBase -= Math.abs(20 * bpPerPx)
65
+ maxBase += Math.abs(20 * bpPerPx) + 1
66
+
67
+ const iterPitch = gridPitch.minorPitch || gridPitch.majorPitch
68
+ let index = 0
69
+ const ticks = []
70
+ for (
71
+ let base = Math.ceil(minBase / iterPitch) * iterPitch;
72
+ base < maxBase;
73
+ base += iterPitch
74
+ ) {
75
+ if (emitMinor && base % (gridPitch.majorPitch * 2)) {
76
+ ticks.push({ type: 'minor', base: base - 1, index })
77
+ index += 1
78
+ } else if (emitMajor && !(base % (gridPitch.majorPitch * 2))) {
79
+ ticks.push({ type: 'major', base: base - 1, index })
80
+ index += 1
81
+ }
82
+ }
83
+ return ticks
84
+ }
85
+
86
+ export function mathPower(num: number): string {
87
+ if (num < 999) {
88
+ return String(num)
89
+ }
90
+ return `${mathPower(~~(num / 1000))},${`00${~~(num % 1000)}`.slice(
91
+ -3,
92
+ -3 + 3,
93
+ )}`
94
+ }
@@ -0,0 +1,2 @@
1
+ declare module 'stockholm-js'
2
+ declare module 'normalize-wheel'
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as MSAView } from './components/MSAView'
2
+ export { default as MSAModel, type MsaViewModel } from './model'
package/src/layout.ts ADDED
@@ -0,0 +1,83 @@
1
+ import RBush from 'rbush'
2
+
3
+ export default class Layout {
4
+ public rectangles: Map<
5
+ string,
6
+ {
7
+ minY: number
8
+ maxY: number
9
+ minX: number
10
+ maxX: number
11
+ id: string
12
+ data: unknown
13
+ }
14
+ >
15
+
16
+ public maxHeightReached: boolean
17
+
18
+ private maxHeight: number
19
+
20
+ private rbush: RBush<{ id: string }>
21
+
22
+ private pTotalHeight: number
23
+
24
+ constructor({
25
+ maxHeight = 10000,
26
+ }: {
27
+ maxHeight?: number
28
+ } = {}) {
29
+ this.maxHeightReached = false
30
+ this.rbush = new RBush()
31
+ this.rectangles = new Map()
32
+ this.maxHeight = Math.ceil(maxHeight)
33
+ this.pTotalHeight = 0 // total height, in units of bitmap squares (px/pitchY)
34
+ }
35
+
36
+ /**
37
+ * @returns top position for the rect, or Null if laying
38
+ * out the rect would exceed maxHeighe
39
+ */
40
+ addRect(
41
+ id: string,
42
+ left: number,
43
+ right: number,
44
+ height: number,
45
+ data: unknown,
46
+ ): number | null {
47
+ // add to rbush
48
+ const existingRecord = this.rectangles.get(id)
49
+ if (existingRecord) {
50
+ return existingRecord.minY
51
+ }
52
+
53
+ let currHeight = 0
54
+ while (
55
+ this.rbush.collides({
56
+ minX: left,
57
+ minY: currHeight,
58
+ maxX: right,
59
+ maxY: currHeight + height,
60
+ }) &&
61
+ currHeight <= this.maxHeight
62
+ ) {
63
+ currHeight += 1
64
+ }
65
+
66
+ const record = {
67
+ minX: left,
68
+ minY: currHeight,
69
+ maxX: right,
70
+ maxY: currHeight + height,
71
+ id,
72
+ data,
73
+ }
74
+ this.rbush.insert(record)
75
+ this.rectangles.set(id, record)
76
+ this.pTotalHeight = Math.max(this.pTotalHeight, currHeight)
77
+ return currHeight
78
+ }
79
+
80
+ get totalHeight() {
81
+ return this.pTotalHeight
82
+ }
83
+ }