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.
- package/bundle/index.js +283 -97265
- package/dist/StructureModel.d.ts +9 -0
- package/dist/StructureModel.js +11 -0
- package/dist/StructureModel.js.map +1 -0
- package/dist/UniprotTrack.d.ts +27 -0
- package/dist/UniprotTrack.js +52 -0
- package/dist/UniprotTrack.js.map +1 -0
- package/dist/colorSchemes.d.ts +2 -2
- package/dist/colorSchemes.js +24 -29
- package/dist/colorSchemes.js.map +1 -0
- package/dist/components/AboutDlg.d.ts +0 -1
- package/dist/components/AboutDlg.js +38 -48
- package/dist/components/AboutDlg.js.map +1 -0
- package/dist/components/AddTrackDlg.d.ts +0 -1
- package/dist/components/AddTrackDlg.js +13 -13
- package/dist/components/AddTrackDlg.js.map +1 -0
- package/dist/components/AnnotationDlg.d.ts +0 -1
- package/dist/components/AnnotationDlg.js +36 -48
- package/dist/components/AnnotationDlg.js.map +1 -0
- package/dist/components/BoxTrack.d.ts +3 -4
- package/dist/components/BoxTrack.js +51 -48
- package/dist/components/BoxTrack.js.map +1 -0
- package/dist/components/DetailsDlg.d.ts +0 -1
- package/dist/components/DetailsDlg.js +7 -7
- package/dist/components/DetailsDlg.js.map +1 -0
- package/dist/components/Header.d.ts +0 -1
- package/dist/components/Header.js +39 -34
- package/dist/components/Header.js.map +1 -0
- package/dist/components/ImportForm.d.ts +0 -1
- package/dist/components/ImportForm.js +59 -71
- package/dist/components/ImportForm.js.map +1 -0
- package/dist/components/MSACanvas.d.ts +0 -1
- package/dist/components/MSACanvas.js +71 -74
- package/dist/components/MSACanvas.js.map +1 -0
- package/dist/components/MSAView.d.ts +0 -1
- package/dist/components/MSAView.js +19 -38
- package/dist/components/MSAView.js.map +1 -0
- package/dist/components/MoreInfoDlg.d.ts +2 -3
- package/dist/components/MoreInfoDlg.js +5 -5
- package/dist/components/MoreInfoDlg.js.map +1 -0
- package/dist/components/ResizeHandles.d.ts +2 -3
- package/dist/components/ResizeHandles.js +31 -32
- package/dist/components/ResizeHandles.js.map +1 -0
- package/dist/components/Rubberband.d.ts +2 -1
- package/dist/components/Rubberband.js +42 -64
- package/dist/components/Rubberband.js.map +1 -0
- package/dist/components/Ruler.d.ts +0 -15
- package/dist/components/Ruler.js +18 -87
- package/dist/components/Ruler.js.map +1 -0
- package/dist/components/SettingsDlg.d.ts +0 -1
- package/dist/components/SettingsDlg.js +29 -22
- package/dist/components/SettingsDlg.js.map +1 -0
- package/dist/components/TextTrack.d.ts +3 -4
- package/dist/components/TextTrack.js +23 -24
- package/dist/components/TextTrack.js.map +1 -0
- package/dist/components/Track.d.ts +2 -3
- package/dist/components/Track.js +38 -38
- package/dist/components/Track.js.map +1 -0
- package/dist/components/TrackInfoDlg.d.ts +5 -3
- package/dist/components/TrackInfoDlg.js +12 -13
- package/dist/components/TrackInfoDlg.js.map +1 -0
- package/dist/components/TracklistDlg.d.ts +0 -1
- package/dist/components/TracklistDlg.js +9 -9
- package/dist/components/TracklistDlg.js.map +1 -0
- package/dist/components/TreeCanvas.d.ts +0 -1
- package/dist/components/TreeCanvas.js +135 -148
- package/dist/components/TreeCanvas.js.map +1 -0
- package/dist/components/TreeRuler.d.ts +0 -1
- package/dist/components/TreeRuler.js +3 -3
- package/dist/components/TreeRuler.js.map +1 -0
- package/dist/components/VerticalGuide.d.ts +6 -0
- package/dist/components/VerticalGuide.js +30 -0
- package/dist/components/VerticalGuide.js.map +1 -0
- package/dist/components/data/seq2.d.ts +3 -3
- package/dist/components/data/seq2.js +33 -3
- package/dist/components/data/seq2.js.map +1 -0
- package/{bundle/components/Ruler.d.ts → dist/components/util.d.ts} +1 -6
- package/dist/components/util.js +69 -0
- package/dist/components/util.js.map +1 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -0
- package/dist/layout.js +14 -20
- package/dist/layout.js.map +1 -0
- package/dist/model.d.ts +94 -74
- package/dist/model.js +232 -473
- package/dist/model.js.map +1 -0
- package/dist/parseNewick.d.ts +1 -5
- package/dist/parseNewick.js +10 -7
- package/dist/parseNewick.js.map +1 -0
- package/dist/parsers/ClustalMSA.d.ts +6 -18
- package/dist/parsers/ClustalMSA.js +55 -64
- package/dist/parsers/ClustalMSA.js.map +1 -0
- package/dist/parsers/FastaMSA.d.ts +4 -9
- package/dist/parsers/FastaMSA.js +55 -64
- package/dist/parsers/FastaMSA.js.map +1 -0
- package/dist/parsers/StockholmMSA.d.ts +8 -13
- package/dist/parsers/StockholmMSA.js +78 -107
- package/dist/parsers/StockholmMSA.js.map +1 -0
- package/dist/util.d.ts +33 -4
- package/dist/util.js +76 -24
- package/dist/util.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +30 -30
- package/src/StructureModel.ts +11 -0
- package/src/UniprotTrack.ts +60 -0
- package/src/colorSchemes.ts +520 -0
- package/src/components/AboutDlg.tsx +64 -0
- package/src/components/AddTrackDlg.tsx +74 -0
- package/src/components/AnnotationDlg.tsx +144 -0
- package/src/components/BoxTrack.tsx +225 -0
- package/src/components/DetailsDlg.tsx +28 -0
- package/src/components/Header.tsx +117 -0
- package/src/components/ImportForm.tsx +192 -0
- package/src/components/MSACanvas.tsx +297 -0
- package/src/components/MSAView.tsx +132 -0
- package/src/components/MoreInfoDlg.tsx +21 -0
- package/src/components/ResizeHandles.tsx +137 -0
- package/src/components/Rubberband.tsx +271 -0
- package/src/components/Ruler.tsx +122 -0
- package/src/components/SettingsDlg.tsx +154 -0
- package/src/components/TextTrack.tsx +120 -0
- package/src/components/Track.tsx +150 -0
- package/src/components/TrackInfoDlg.tsx +59 -0
- package/src/components/TracklistDlg.tsx +61 -0
- package/src/components/TreeCanvas.tsx +633 -0
- package/src/components/TreeRuler.tsx +12 -0
- package/src/components/VerticalGuide.tsx +50 -0
- package/src/components/data/seq2.ts +35 -0
- package/src/components/util.ts +94 -0
- package/src/declare.d.ts +2 -0
- package/src/index.ts +2 -0
- package/src/layout.ts +83 -0
- package/src/model.ts +790 -0
- package/{bundle/parseNewick.d.ts → src/parseNewick.ts} +36 -5
- package/src/parsers/ClustalMSA.ts +79 -0
- package/src/parsers/FastaMSA.ts +82 -0
- package/src/parsers/StockholmMSA.ts +137 -0
- package/src/util.ts +142 -0
- package/src/version.ts +1 -0
- package/bundle/colorSchemes.d.ts +0 -16
- package/bundle/colorSchemes.js +0 -455
- package/bundle/components/AboutDlg.d.ts +0 -5
- package/bundle/components/AboutDlg.js +0 -47
- package/bundle/components/AddTrackDlg.d.ts +0 -8
- package/bundle/components/AddTrackDlg.js +0 -26
- package/bundle/components/AnnotationDlg.d.ts +0 -11
- package/bundle/components/AnnotationDlg.js +0 -77
- package/bundle/components/BoxTrack.d.ts +0 -7
- package/bundle/components/BoxTrack.js +0 -143
- package/bundle/components/DetailsDlg.d.ts +0 -8
- package/bundle/components/DetailsDlg.js +0 -12
- package/bundle/components/Header.d.ts +0 -6
- package/bundle/components/Header.js +0 -63
- package/bundle/components/ImportForm.d.ts +0 -6
- package/bundle/components/ImportForm.js +0 -89
- package/bundle/components/MSACanvas.d.ts +0 -6
- package/bundle/components/MSACanvas.js +0 -210
- package/bundle/components/MSAView.d.ts +0 -6
- package/bundle/components/MSAView.js +0 -88
- package/bundle/components/MoreInfoDlg.d.ts +0 -6
- package/bundle/components/MoreInfoDlg.js +0 -11
- package/bundle/components/ResizeHandles.d.ts +0 -8
- package/bundle/components/ResizeHandles.js +0 -110
- package/bundle/components/Rubberband.d.ts +0 -7
- package/bundle/components/Rubberband.js +0 -196
- package/bundle/components/Ruler.js +0 -121
- package/bundle/components/SettingsDlg.d.ts +0 -8
- package/bundle/components/SettingsDlg.js +0 -40
- package/bundle/components/TextTrack.d.ts +0 -7
- package/bundle/components/TextTrack.js +0 -72
- package/bundle/components/Track.d.ts +0 -11
- package/bundle/components/Track.js +0 -81
- package/bundle/components/TrackInfoDlg.d.ts +0 -6
- package/bundle/components/TrackInfoDlg.js +0 -33
- package/bundle/components/TracklistDlg.d.ts +0 -8
- package/bundle/components/TracklistDlg.js +0 -18
- package/bundle/components/TreeCanvas.d.ts +0 -6
- package/bundle/components/TreeCanvas.js +0 -431
- package/bundle/components/TreeRuler.d.ts +0 -6
- package/bundle/components/TreeRuler.js +0 -8
- package/bundle/components/data/seq2.d.ts +0 -3
- package/bundle/components/data/seq2.js +0 -3
- package/bundle/index.d.ts +0 -4
- package/bundle/layout.d.ts +0 -23
- package/bundle/layout.js +0 -53
- package/bundle/model.d.ts +0 -364
- package/bundle/model.js +0 -894
- package/bundle/parseNewick.js +0 -94
- package/bundle/parsers/ClustalMSA.d.ts +0 -39
- package/bundle/parsers/ClustalMSA.js +0 -77
- package/bundle/parsers/FastaMSA.d.ts +0 -26
- package/bundle/parsers/FastaMSA.js +0 -78
- package/bundle/parsers/StockholmMSA.d.ts +0 -75
- package/bundle/parsers/StockholmMSA.js +0 -142
- package/bundle/util.d.ts +0 -17
- package/bundle/util.js +0 -33
- package/dist/components/package.json +0 -62
|
@@ -57,8 +57,39 @@
|
|
|
57
57
|
* ]
|
|
58
58
|
* }
|
|
59
59
|
*/
|
|
60
|
-
export default function parse(s:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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";
|
package/bundle/colorSchemes.d.ts
DELETED
|
@@ -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;
|