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
@@ -57,8 +57,39 @@
57
57
  * ]
58
58
  * }
59
59
  */
60
- export default function parse(s: any): {
61
- branchset: {}[];
62
- name: any;
63
- length: number;
64
- };
60
+ export default function parse(s: string) {
61
+ const ancestors = []
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+ let tree = {} as Record<string, any>
64
+ const tokens = s.split(/\s*(;|\(|\)|,|:)\s*/)
65
+ for (let i = 0; i < tokens.length; i++) {
66
+ const token = tokens[i]
67
+ const subtree = {}
68
+ switch (token) {
69
+ case '(': // new branchset
70
+ tree.branchset = [subtree]
71
+ ancestors.push(tree)
72
+ tree = subtree
73
+ break
74
+ case ',': // another branch
75
+ ancestors[ancestors.length - 1].branchset.push(subtree)
76
+ tree = subtree
77
+ break
78
+ case ')': // optional name next
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ tree = ancestors.pop() as Record<string, any>
81
+ break
82
+ case ':': // optional length next
83
+ break
84
+ default: {
85
+ const x = tokens[i - 1]
86
+ if (x === ')' || x === '(' || x === ',') {
87
+ tree.name = token
88
+ } else if (x === ':') {
89
+ tree.length = parseFloat(token)
90
+ }
91
+ }
92
+ }
93
+ }
94
+ return tree
95
+ }
@@ -0,0 +1,79 @@
1
+ import { parse } from 'clustal-js'
2
+ import { NodeWithIds } from '../util'
3
+ export default class ClustalMSA {
4
+ private MSA: ReturnType<typeof parse>
5
+
6
+ constructor(text: string) {
7
+ this.MSA = parse(text)
8
+ }
9
+
10
+ getMSA() {
11
+ return this.MSA
12
+ }
13
+
14
+ getRow(name: string) {
15
+ return this.MSA.alns.find(aln => aln.id === name)?.seq.split('')
16
+ }
17
+
18
+ getWidth() {
19
+ return this.MSA.alns[0].seq.length
20
+ }
21
+
22
+ getRowData() {
23
+ return undefined
24
+ }
25
+
26
+ getHeader() {
27
+ return this.MSA.header
28
+ }
29
+
30
+ getNames() {
31
+ return this.MSA.alns.map(aln => aln.id)
32
+ }
33
+
34
+ getStructures() {
35
+ return {}
36
+ }
37
+
38
+ get alignmentNames() {
39
+ return []
40
+ }
41
+
42
+ getTree(): NodeWithIds {
43
+ return {
44
+ id: 'root',
45
+ name: 'root',
46
+ noTree: true,
47
+ branchset: this.getNames().map(name => ({
48
+ id: name,
49
+ name,
50
+ branchset: [],
51
+ })),
52
+ }
53
+ }
54
+
55
+ get seqConsensus() {
56
+ return this.MSA.consensus
57
+ }
58
+ get secondaryStructureConsensus() {
59
+ return undefined
60
+ }
61
+
62
+ get tracks() {
63
+ return this.seqConsensus?.trim()
64
+ ? [
65
+ {
66
+ id: 'seqConsensus',
67
+ name: 'Sequence consensus',
68
+ data: this.seqConsensus,
69
+ customColorScheme: {
70
+ '*': 'white',
71
+ ':': 'grey',
72
+ '.': 'darkgrey',
73
+ ' ': 'black',
74
+ },
75
+ },
76
+ ]
77
+ : []
78
+ }
79
+ }
@@ -0,0 +1,82 @@
1
+ import { NodeWithIds } from '../util'
2
+
3
+ function parseSmallFasta(text: string) {
4
+ return text
5
+ .split('>')
6
+ .filter(t => /\S/.test(t))
7
+ .map(entryText => {
8
+ const [defLine, ...seqLines] = entryText.split('\n')
9
+ const [id, ...description] = defLine.split(' ')
10
+ const descriptionStr = description.join(' ')
11
+ const seqLinesStr = seqLines.join('')
12
+ const sequence = seqLinesStr.replace(/\s/g, '')
13
+ return { id, description: descriptionStr, sequence }
14
+ })
15
+ }
16
+ export default class FastaMSA {
17
+ private MSA: { seqdata: { [key: string]: string } }
18
+ constructor(text: string) {
19
+ this.MSA = {
20
+ seqdata: Object.fromEntries(
21
+ parseSmallFasta(text).map((m, i) => [`${m.id}-${i}`, m.sequence]),
22
+ ),
23
+ }
24
+ }
25
+
26
+ getMSA() {
27
+ return this.MSA
28
+ }
29
+
30
+ getRowData() {
31
+ return undefined
32
+ }
33
+
34
+ getNames() {
35
+ return Object.keys(this.MSA.seqdata)
36
+ }
37
+
38
+ getRow(name: string) {
39
+ return this.MSA?.seqdata[name]?.split('')
40
+ }
41
+
42
+ getWidth() {
43
+ const name = Object.keys(this.MSA?.seqdata)[0]
44
+ return this.getRow(name).length
45
+ }
46
+
47
+ getStructures() {
48
+ return {}
49
+ }
50
+
51
+ get alignmentNames() {
52
+ return []
53
+ }
54
+
55
+ getHeader() {
56
+ return {}
57
+ }
58
+
59
+ getTree(): NodeWithIds {
60
+ return {
61
+ id: 'root',
62
+ name: 'root',
63
+ noTree: true,
64
+ branchset: this.getNames().map(name => ({
65
+ id: name,
66
+ branchset: [],
67
+ name,
68
+ })),
69
+ }
70
+ }
71
+
72
+ get seqConsensus() {
73
+ return undefined
74
+ }
75
+ get secondaryStructureConsensus() {
76
+ return undefined
77
+ }
78
+
79
+ get tracks() {
80
+ return []
81
+ }
82
+ }
@@ -0,0 +1,137 @@
1
+ import Stockholm from 'stockholm-js'
2
+ import parseNewick from '../parseNewick'
3
+
4
+ import { NodeWithIds, generateNodeIds } from '../util'
5
+ type StockholmEntry = {
6
+ gf: {
7
+ DE?: string[]
8
+ NH?: string[]
9
+ }
10
+ gs: {
11
+ AC: Record<string, string>
12
+ DR: Record<string, string>
13
+ }
14
+ gc?: {
15
+ SS_cons?: string
16
+ seq_cons?: string
17
+ }
18
+ seqdata: { [key: string]: string }
19
+ }
20
+
21
+ export default class StockholmMSA {
22
+ private data: StockholmEntry[]
23
+ private MSA: StockholmEntry
24
+
25
+ constructor(text: string, currentAlignment: number) {
26
+ const res = Stockholm.parseAll(text)
27
+ this.data = res
28
+ this.MSA = res[currentAlignment]
29
+ }
30
+
31
+ getMSA() {
32
+ return this.MSA
33
+ }
34
+
35
+ getRow(name: string) {
36
+ return this.MSA?.seqdata[name]?.split('')
37
+ }
38
+
39
+ getWidth() {
40
+ const name = Object.keys(this.MSA?.seqdata)[0]
41
+ return this.getRow(name).length
42
+ }
43
+
44
+ get alignmentNames() {
45
+ return this.data.map((aln, idx) => aln.gf.DE?.[0] || `Alignment ${idx + 1}`)
46
+ }
47
+
48
+ getHeader() {
49
+ return {
50
+ General: this.MSA.gf,
51
+ Accessions: this.MSA.gs?.AC,
52
+ Dbxref: this.MSA.gs?.DR,
53
+ }
54
+ }
55
+
56
+ getRowData(rowName: string) {
57
+ return {
58
+ name: rowName,
59
+ accession: this.MSA.gs?.AC[rowName],
60
+ dbxref: this.MSA.gs?.DR[rowName],
61
+ }
62
+ }
63
+
64
+ getNames() {
65
+ return Object.keys(this.MSA.seqdata)
66
+ }
67
+
68
+ getSeqCoords() {}
69
+
70
+ getStructures() {
71
+ const pdbRegex = /PDB; +(\S+) +(\S); ([0-9]+)-([0-9]+)/
72
+ const ent = this.MSA
73
+ const args = Object.entries(ent.gs?.DR || {})
74
+ .map(([id, dr]) => [id, pdbRegex.exec(dr)] as const)
75
+ .filter((item): item is [string, RegExpExecArray] => !!item[1])
76
+ .map(([id, match]) => {
77
+ const pdb = match[1].toLowerCase()
78
+ const chain = match[2]
79
+ const startPos = +match[3]
80
+ const endPos = +match[4]
81
+ return { id, pdb, chain, startPos, endPos }
82
+ })
83
+
84
+ const ret = {} as Record<string, Omit<typeof args[0], 'id'>[]>
85
+ for (const entry of args) {
86
+ const { id, ...rest } = entry
87
+ if (!ret[id]) {
88
+ ret[id] = []
89
+ }
90
+ ret[id].push(rest)
91
+ }
92
+ return ret
93
+ }
94
+
95
+ getTree(): NodeWithIds {
96
+ const tree = this.MSA?.gf?.NH?.[0]
97
+ return tree
98
+ ? generateNodeIds(parseNewick(tree))
99
+ : {
100
+ id: 'root',
101
+ name: 'root',
102
+ noTree: true,
103
+ branchset: this.getNames().map(name => ({
104
+ id: name,
105
+ branchset: [],
106
+ name,
107
+ })),
108
+ }
109
+ }
110
+
111
+ get seqConsensus() {
112
+ return this.MSA.gc?.seq_cons
113
+ }
114
+ get secondaryStructureConsensus() {
115
+ return this.MSA.gc?.SS_cons
116
+ }
117
+
118
+ get tracks() {
119
+ return [
120
+ {
121
+ id: 'seqConsensus',
122
+ name: 'Sequence consensus',
123
+ data: this.seqConsensus,
124
+ customColorScheme: {},
125
+ },
126
+ {
127
+ id: 'secondaryStruct',
128
+ name: 'Secondary-structure',
129
+ data: this.secondaryStructureConsensus,
130
+ customColorScheme: {
131
+ '>': 'pink',
132
+ '<': 'lightblue',
133
+ },
134
+ },
135
+ ]
136
+ }
137
+ }
package/src/util.ts ADDED
@@ -0,0 +1,142 @@
1
+ import Color from 'color'
2
+ import { HierarchyNode } from 'd3-hierarchy'
3
+ import { max } from 'd3-array'
4
+ import { Theme } from '@mui/material'
5
+
6
+ export function transform<T>(
7
+ obj: Record<string, T>,
8
+ cb: (arg0: [string, T]) => [string, T],
9
+ ) {
10
+ return Object.fromEntries(Object.entries(obj).map(cb))
11
+ }
12
+
13
+ interface Node {
14
+ branchset?: Node[]
15
+ name?: string
16
+ [key: string]: unknown
17
+ }
18
+
19
+ export type NodeWithIds = {
20
+ id: string
21
+ name: string
22
+ branchset: NodeWithIds[]
23
+ length?: number
24
+ noTree?: boolean
25
+ }
26
+
27
+ export type NodeWithIdsAndLength = {
28
+ id: string
29
+ name: string
30
+ branchset: NodeWithIdsAndLength[]
31
+ noTree?: boolean
32
+ length: number
33
+ }
34
+
35
+ export function generateNodeIds(
36
+ tree: Node,
37
+ parent = 'node',
38
+ depth = 0,
39
+ ): NodeWithIds {
40
+ const id = `${parent}-${depth}`
41
+
42
+ return {
43
+ ...tree,
44
+ id,
45
+ name: tree.name || id,
46
+ branchset:
47
+ tree.branchset?.map((b, i) =>
48
+ generateNodeIds(b, `${id}-${i}`, depth + 1),
49
+ ) || [],
50
+ }
51
+ }
52
+
53
+ export function colorContrast(
54
+ colorScheme: { [key: string]: string },
55
+ theme: Theme,
56
+ ) {
57
+ return transform(colorScheme, ([letter, color]) => [
58
+ letter,
59
+ theme.palette.getContrastText(Color(color).hex()),
60
+ ])
61
+ }
62
+
63
+ export function parseGFF(str?: string) {
64
+ return str
65
+ ?.split('\n')
66
+ .map(f => f.trim())
67
+ .filter(f => !!f && !f.startsWith('#'))
68
+ .map(f => {
69
+ const [seq_id, source, type, start, end, score, strand, phase, col9] =
70
+ f.split('\t')
71
+
72
+ return {
73
+ seq_id,
74
+ source,
75
+ type,
76
+ start: +start,
77
+ end: +end,
78
+ score: +score,
79
+ strand,
80
+ phase,
81
+ ...Object.fromEntries(
82
+ col9
83
+ .split(';')
84
+ .map(f => f.trim())
85
+ .filter(f => !!f)
86
+ .map(f => f.split('='))
87
+ .map(([key, val]) => [
88
+ key.trim(),
89
+ decodeURIComponent(val).trim().split(',').join(' '),
90
+ ]),
91
+ ),
92
+ }
93
+ })
94
+ }
95
+
96
+ export function skipBlanks(blanks: number[], arg: string | string[]) {
97
+ let s = ''
98
+ let b = 0
99
+ for (let j = 0; j < arg.length; j++) {
100
+ if (j === blanks[b]) {
101
+ b++
102
+ } else {
103
+ s += arg[j]
104
+ }
105
+ }
106
+ return s
107
+ }
108
+
109
+ export function setBrLength(
110
+ d: HierarchyNode<NodeWithIds>,
111
+ y0: number,
112
+ k: number,
113
+ ) {
114
+ // @ts-expect-error
115
+ d.len = (y0 += Math.max(d.data.length || 0, 0)) * k
116
+ d.children?.forEach(d => {
117
+ setBrLength(d, y0, k)
118
+ })
119
+ }
120
+
121
+ export function maxLength(d: HierarchyNode<NodeWithIds>): number {
122
+ return (
123
+ (d.data.length || 1) + (d.children ? max(d.children, maxLength) || 0 : 0)
124
+ )
125
+ }
126
+
127
+ // Collapse the node and all it's children, from
128
+ // https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd
129
+ export function collapse(d: HierarchyNode<NodeWithIds>) {
130
+ if (d.children) {
131
+ // @ts-expect-error
132
+ d._children = d.children
133
+ // @ts-expect-error
134
+ d._children.forEach(collapse)
135
+ // @ts-expect-error
136
+ d.children = null
137
+ }
138
+ }
139
+
140
+ export function clamp(min: number, num: number, max: number) {
141
+ return Math.min(Math.max(num, min), max)
142
+ }
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const version = "2.0.0";
@@ -1,16 +0,0 @@
1
- declare const _default: {
2
- [k: string]: {
3
- [key: string]: string;
4
- };
5
- };
6
- export default _default;
7
- export declare function getClustalXColor(stats: {
8
- [key: string]: number;
9
- }, model: {
10
- columns: Record<string, string>;
11
- }, row: number, col: number): "rgb(128,179,230)" | "#d88" | "rgb(192, 72, 192)" | "rgb(204, 77, 204)" | "#8f8" | "rgb(26,204,26)" | "rgb(240, 128, 128)" | "rgb(240, 144, 72)" | "rgb(204, 204, 0)" | "rgb(26, 179, 179)" | undefined;
12
- export declare function getPercentIdentityColor(stats: {
13
- [key: string]: number;
14
- }, model: {
15
- columns: Record<string, string>;
16
- }, row: number, col: number): string | undefined;