jbrowse-plugin-protein3d 0.0.2
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/README.md +3 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.d.ts +6 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +24 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +1 -0
- package/dist/AddHighlightModel/Highlight.d.ts +10 -0
- package/dist/AddHighlightModel/Highlight.js +24 -0
- package/dist/AddHighlightModel/Highlight.js.map +1 -0
- package/dist/AddHighlightModel/HighlightComponents.d.ts +7 -0
- package/dist/AddHighlightModel/HighlightComponents.js +14 -0
- package/dist/AddHighlightModel/HighlightComponents.js.map +1 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.d.ts +7 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js +13 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js.map +1 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.d.ts +7 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js +13 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js.map +1 -0
- package/dist/AddHighlightModel/index.d.ts +2 -0
- package/dist/AddHighlightModel/index.js +14 -0
- package/dist/AddHighlightModel/index.js.map +1 -0
- package/dist/AddHighlightModel/util.d.ts +9 -0
- package/dist/AddHighlightModel/util.js +17 -0
- package/dist/AddHighlightModel/util.js.map +1 -0
- package/dist/LaunchProteinView/calculateProteinSequence.d.ts +28 -0
- package/dist/LaunchProteinView/calculateProteinSequence.js +77 -0
- package/dist/LaunchProteinView/calculateProteinSequence.js.map +1 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.d.ts +8 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js +71 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js.map +1 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.d.ts +8 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js +19 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js.map +1 -0
- package/dist/LaunchProteinView/components/HelpButton.d.ts +2 -0
- package/dist/LaunchProteinView/components/HelpButton.js +15 -0
- package/dist/LaunchProteinView/components/HelpButton.js.map +1 -0
- package/dist/LaunchProteinView/components/HelpDialog.d.ts +4 -0
- package/dist/LaunchProteinView/components/HelpDialog.js +16 -0
- package/dist/LaunchProteinView/components/HelpDialog.js.map +1 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.d.ts +7 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js +23 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js.map +1 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.d.ts +8 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js +72 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js.map +1 -0
- package/dist/LaunchProteinView/components/TabPanel.d.ts +6 -0
- package/dist/LaunchProteinView/components/TabPanel.js +6 -0
- package/dist/LaunchProteinView/components/TabPanel.js.map +1 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.d.ts +9 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.js +28 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.js.map +1 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.d.ts +8 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.js +118 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.js.map +1 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.d.ts +7 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js +26 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js.map +1 -0
- package/dist/LaunchProteinView/index.d.ts +2 -0
- package/dist/LaunchProteinView/index.js +45 -0
- package/dist/LaunchProteinView/index.js.map +1 -0
- package/dist/LaunchProteinView/useMyGeneInfo.d.ts +7 -0
- package/dist/LaunchProteinView/useMyGeneInfo.js +29 -0
- package/dist/LaunchProteinView/useMyGeneInfo.js.map +1 -0
- package/dist/LaunchProteinView/useProteinSequences.d.ts +10 -0
- package/dist/LaunchProteinView/useProteinSequences.js +30 -0
- package/dist/LaunchProteinView/useProteinSequences.js.map +1 -0
- package/dist/LaunchProteinView/util.d.ts +18 -0
- package/dist/LaunchProteinView/util.js +54 -0
- package/dist/LaunchProteinView/util.js.map +1 -0
- package/dist/ProteinModelSessionExtension.d.ts +11 -0
- package/dist/ProteinModelSessionExtension.js +53 -0
- package/dist/ProteinModelSessionExtension.js.map +1 -0
- package/dist/ProteinView/clearSelection.d.ts +4 -0
- package/dist/ProteinView/clearSelection.js +4 -0
- package/dist/ProteinView/clearSelection.js.map +1 -0
- package/dist/ProteinView/components/Header.d.ts +6 -0
- package/dist/ProteinView/components/Header.js +49 -0
- package/dist/ProteinView/components/Header.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignment.d.ts +6 -0
- package/dist/ProteinView/components/ProteinAlignment.js +62 -0
- package/dist/ProteinView/components/ProteinAlignment.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.d.ts +5 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.js +14 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.d.ts +4 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js +20 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js.map +1 -0
- package/dist/ProteinView/components/ProteinView.d.ts +6 -0
- package/dist/ProteinView/components/ProteinView.js +79 -0
- package/dist/ProteinView/components/ProteinView.js.map +1 -0
- package/dist/ProteinView/components/SplitString.d.ts +9 -0
- package/dist/ProteinView/components/SplitString.js +11 -0
- package/dist/ProteinView/components/SplitString.js.map +1 -0
- package/dist/ProteinView/css/molstar.d.ts +2 -0
- package/dist/ProteinView/css/molstar.js +3137 -0
- package/dist/ProteinView/css/molstar.js.map +1 -0
- package/dist/ProteinView/genomeToProtein.d.ts +4 -0
- package/dist/ProteinView/genomeToProtein.js +13 -0
- package/dist/ProteinView/genomeToProtein.js.map +1 -0
- package/dist/ProteinView/highlightResidue.d.ts +7 -0
- package/dist/ProteinView/highlightResidue.js +14 -0
- package/dist/ProteinView/highlightResidue.js.map +1 -0
- package/dist/ProteinView/index.d.ts +2 -0
- package/dist/ProteinView/index.js +15 -0
- package/dist/ProteinView/index.js.map +1 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.d.ts +14 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.js +72 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.js.map +1 -0
- package/dist/ProteinView/loadStructureFromData.d.ts +17 -0
- package/dist/ProteinView/loadStructureFromData.js +20 -0
- package/dist/ProteinView/loadStructureFromData.js.map +1 -0
- package/dist/ProteinView/loadStructureFromURL.d.ts +17 -0
- package/dist/ProteinView/loadStructureFromURL.js +17 -0
- package/dist/ProteinView/loadStructureFromURL.js.map +1 -0
- package/dist/ProteinView/model.d.ts +226 -0
- package/dist/ProteinView/model.js +324 -0
- package/dist/ProteinView/model.js.map +1 -0
- package/dist/ProteinView/proteinAbbreviationMapping.d.ts +7 -0
- package/dist/ProteinView/proteinAbbreviationMapping.js +23 -0
- package/dist/ProteinView/proteinAbbreviationMapping.js.map +1 -0
- package/dist/ProteinView/proteinToGenomeMapping.d.ts +13 -0
- package/dist/ProteinView/proteinToGenomeMapping.js +69 -0
- package/dist/ProteinView/proteinToGenomeMapping.js.map +1 -0
- package/dist/ProteinView/selectResidue.d.ts +7 -0
- package/dist/ProteinView/selectResidue.js +10 -0
- package/dist/ProteinView/selectResidue.js.map +1 -0
- package/dist/ProteinView/useProteinView.d.ts +11 -0
- package/dist/ProteinView/useProteinView.js +57 -0
- package/dist/ProteinView/useProteinView.js.map +1 -0
- package/dist/ProteinView/useProteinViewClickBehavior.d.ts +8 -0
- package/dist/ProteinView/useProteinViewClickBehavior.js +34 -0
- package/dist/ProteinView/useProteinViewClickBehavior.js.map +1 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.d.ts +6 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.js +31 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.js.map +1 -0
- package/dist/ProteinView/util.d.ts +19 -0
- package/dist/ProteinView/util.js +32 -0
- package/dist/ProteinView/util.js.map +1 -0
- package/dist/fetchUtils.d.ts +5 -0
- package/dist/fetchUtils.js +23 -0
- package/dist/fetchUtils.js.map +1 -0
- package/dist/genomeToTranscriptMapping.d.ts +7 -0
- package/dist/genomeToTranscriptMapping.js +36 -0
- package/dist/genomeToTranscriptMapping.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js +9298 -0
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +7 -0
- package/dist/mappings.d.ts +19 -0
- package/dist/mappings.js +67 -0
- package/dist/mappings.js.map +1 -0
- package/dist/mappings.test.d.ts +1 -0
- package/dist/mappings.test.js +27 -0
- package/dist/mappings.test.js.map +1 -0
- package/dist/test_data/gene.d.ts +67 -0
- package/dist/test_data/gene.js +603 -0
- package/dist/test_data/gene.js.map +1 -0
- package/package.json +70 -0
- package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +45 -0
- package/src/AddHighlightModel/Highlight.tsx +46 -0
- package/src/AddHighlightModel/HighlightComponents.tsx +26 -0
- package/src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx +39 -0
- package/src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx +39 -0
- package/src/AddHighlightModel/index.tsx +25 -0
- package/src/AddHighlightModel/util.ts +17 -0
- package/src/LaunchProteinView/calculateProteinSequence.ts +127 -0
- package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +141 -0
- package/src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx +44 -0
- package/src/LaunchProteinView/components/HelpButton.tsx +23 -0
- package/src/LaunchProteinView/components/HelpDialog.tsx +43 -0
- package/src/LaunchProteinView/components/LaunchProteinViewDialog.tsx +57 -0
- package/src/LaunchProteinView/components/PreLoadedStructureMapping.tsx +153 -0
- package/src/LaunchProteinView/components/TabPanel.tsx +19 -0
- package/src/LaunchProteinView/components/TranscriptSelector.tsx +54 -0
- package/src/LaunchProteinView/components/UserProvidedStructure.tsx +226 -0
- package/src/LaunchProteinView/components/useCheckAlphaFoldDBExistence.ts +31 -0
- package/src/LaunchProteinView/index.ts +56 -0
- package/src/LaunchProteinView/useMyGeneInfo.ts +37 -0
- package/src/LaunchProteinView/useProteinSequences.ts +36 -0
- package/src/LaunchProteinView/util.ts +74 -0
- package/src/ProteinModelSessionExtension.ts +71 -0
- package/src/ProteinView/clearSelection.ts +5 -0
- package/src/ProteinView/components/Header.tsx +84 -0
- package/src/ProteinView/components/ProteinAlignment.tsx +119 -0
- package/src/ProteinView/components/ProteinAlignmentHelpButton.tsx +33 -0
- package/src/ProteinView/components/ProteinAlignmentHelpDialog.tsx +59 -0
- package/src/ProteinView/components/ProteinView.tsx +131 -0
- package/src/ProteinView/components/SplitString.tsx +35 -0
- package/src/ProteinView/css/molstar.ts +3136 -0
- package/src/ProteinView/genomeToProtein.ts +21 -0
- package/src/ProteinView/highlightResidue.ts +23 -0
- package/src/ProteinView/index.ts +18 -0
- package/src/ProteinView/launchRemotePairwiseAlignment.ts +113 -0
- package/src/ProteinView/loadStructureFromData.ts +48 -0
- package/src/ProteinView/loadStructureFromURL.ts +50 -0
- package/src/ProteinView/model.ts +384 -0
- package/src/ProteinView/proteinAbbreviationMapping.ts +24 -0
- package/src/ProteinView/proteinToGenomeMapping.ts +99 -0
- package/src/ProteinView/selectResidue.ts +19 -0
- package/src/ProteinView/useProteinView.ts +70 -0
- package/src/ProteinView/useProteinViewClickBehavior.ts +48 -0
- package/src/ProteinView/useProteinViewHoverBehavior.ts +44 -0
- package/src/ProteinView/util.ts +56 -0
- package/src/__snapshots__/mappings.test.ts.snap +1351 -0
- package/src/declare.d.ts +1 -0
- package/src/fetchUtils.ts +30 -0
- package/src/genomeToTranscriptMapping.ts +46 -0
- package/src/index.ts +32 -0
- package/src/mappings.test.ts +32 -0
- package/src/mappings.ts +89 -0
- package/src/test_data/gene.ts +604 -0
package/src/declare.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.json'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export async function myfetch(url: string, args?: RequestInit) {
|
|
2
|
+
const response = await fetch(url, args)
|
|
3
|
+
|
|
4
|
+
if (!response.ok) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
`HTTP ${response.status} fetching ${url} ${await response.text()}`,
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return response
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function textfetch(url: string, args?: RequestInit) {
|
|
14
|
+
const response = await myfetch(url, args)
|
|
15
|
+
return response.text()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function jsonfetch(url: string, args?: RequestInit) {
|
|
19
|
+
const response = await myfetch(url, args)
|
|
20
|
+
return response.json()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function abfetch(url: string) {
|
|
24
|
+
const res = await myfetch(url)
|
|
25
|
+
return res.arrayBuffer()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function timeout(time: number) {
|
|
29
|
+
return new Promise(res => setTimeout(res, time))
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Feature } from '@jbrowse/core/util'
|
|
2
|
+
|
|
3
|
+
// see similar function in msaview plugin
|
|
4
|
+
export function genomeToTranscriptMapping(feature: Feature) {
|
|
5
|
+
const strand = feature.get('strand') as number
|
|
6
|
+
const refName = feature.get('refName')
|
|
7
|
+
const subs = feature.children() ?? []
|
|
8
|
+
const cds = subs
|
|
9
|
+
.filter(f => f.get('type') === 'CDS')
|
|
10
|
+
.sort((a, b) => strand * (a.get('start') - b.get('start')))
|
|
11
|
+
const g2p = {} as Record<number, number | undefined>
|
|
12
|
+
const p2g = {} as Record<number, number | undefined>
|
|
13
|
+
|
|
14
|
+
let proteinCounter = 0
|
|
15
|
+
if (strand !== -1) {
|
|
16
|
+
for (const f of cds) {
|
|
17
|
+
for (
|
|
18
|
+
let genomePos = f.get('start');
|
|
19
|
+
genomePos < f.get('end');
|
|
20
|
+
genomePos++
|
|
21
|
+
) {
|
|
22
|
+
const proteinPos = Math.floor(proteinCounter++ / 3)
|
|
23
|
+
g2p[genomePos] = proteinPos
|
|
24
|
+
if (!p2g[proteinPos]) {
|
|
25
|
+
p2g[proteinPos] = genomePos
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
for (const f of cds) {
|
|
31
|
+
for (
|
|
32
|
+
let genomePos = f.get('end');
|
|
33
|
+
genomePos > f.get('start');
|
|
34
|
+
genomePos--
|
|
35
|
+
) {
|
|
36
|
+
const proteinPos = Math.floor(proteinCounter++ / 3)
|
|
37
|
+
g2p[genomePos] = proteinPos
|
|
38
|
+
if (!p2g[proteinPos]) {
|
|
39
|
+
p2g[proteinPos] = genomePos
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { g2p, p2g, refName, strand }
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Plugin from '@jbrowse/core/Plugin'
|
|
2
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
3
|
+
import { types } from 'mobx-state-tree'
|
|
4
|
+
// locals
|
|
5
|
+
import { version } from '../package.json'
|
|
6
|
+
import ProteinViewF from './ProteinView'
|
|
7
|
+
import LaunchProteinViewF from './LaunchProteinView'
|
|
8
|
+
import AddHighlightModelF from './AddHighlightModel'
|
|
9
|
+
import ProteinModelSessionExtension from './ProteinModelSessionExtension'
|
|
10
|
+
|
|
11
|
+
export default class ProteinViewer extends Plugin {
|
|
12
|
+
name = 'ProteinViewer'
|
|
13
|
+
version = version
|
|
14
|
+
|
|
15
|
+
install(pluginManager: PluginManager) {
|
|
16
|
+
ProteinViewF(pluginManager)
|
|
17
|
+
LaunchProteinViewF(pluginManager)
|
|
18
|
+
AddHighlightModelF(pluginManager)
|
|
19
|
+
|
|
20
|
+
pluginManager.addToExtensionPoint('Core-extendSession', session => {
|
|
21
|
+
return types.compose(
|
|
22
|
+
types.model({
|
|
23
|
+
proteinModel: types.optional(ProteinModelSessionExtension, {}),
|
|
24
|
+
}),
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
session,
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
configure(_pluginManager: PluginManager) {}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
genomeToTranscriptSeqMapping,
|
|
3
|
+
structureSeqVsTranscriptSeqMap,
|
|
4
|
+
} from './mappings'
|
|
5
|
+
import { SimpleFeature } from '@jbrowse/core/util'
|
|
6
|
+
import { feature, alignment } from './test_data/gene'
|
|
7
|
+
|
|
8
|
+
test('test', () => {
|
|
9
|
+
const ret = structureSeqVsTranscriptSeqMap(alignment)
|
|
10
|
+
expect(ret).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('mapping', () => {
|
|
14
|
+
const res = genomeToTranscriptSeqMapping(new SimpleFeature(feature))
|
|
15
|
+
const { p2g } = res
|
|
16
|
+
const aln = structureSeqVsTranscriptSeqMap(alignment)
|
|
17
|
+
|
|
18
|
+
// expected position in sequence
|
|
19
|
+
const s2 = alignment.alns[1].seq
|
|
20
|
+
expect(s2[392]).toBe('M')
|
|
21
|
+
expect(s2[393]).toBe('K')
|
|
22
|
+
expect(s2[394]).toBe('A')
|
|
23
|
+
expect(s2[395]).toBe('A')
|
|
24
|
+
// maps the 392 position in the "pdb version of the protein" to the 0th
|
|
25
|
+
// position in the genome version of the protein, and then maps that back to
|
|
26
|
+
// the genome
|
|
27
|
+
const p0 = aln.structureSeqToTranscriptSeqPosition[392]!
|
|
28
|
+
const g0 = p2g[p0]
|
|
29
|
+
expect(p0).toBe(0)
|
|
30
|
+
expect(g0).toBe(51_296_155)
|
|
31
|
+
expect(res).toMatchSnapshot()
|
|
32
|
+
})
|
package/src/mappings.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Feature } from '@jbrowse/core/util'
|
|
2
|
+
import { genomeToTranscriptSeqMapping as g2p } from 'g2p_mapper'
|
|
3
|
+
|
|
4
|
+
export interface Alignment {
|
|
5
|
+
alns: {
|
|
6
|
+
id: string
|
|
7
|
+
seq: string
|
|
8
|
+
}[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function structureSeqVsTranscriptSeqMap(alignment: Alignment) {
|
|
12
|
+
const structureSeq = alignment.alns[0].seq
|
|
13
|
+
const transcriptSeq = alignment.alns[1].seq
|
|
14
|
+
if (structureSeq.length !== transcriptSeq.length) {
|
|
15
|
+
throw new Error('mismatched length')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let j = 0
|
|
19
|
+
let k = 0
|
|
20
|
+
const structureSeqToTranscriptSeqPosition = {} as Record<
|
|
21
|
+
string,
|
|
22
|
+
number | undefined
|
|
23
|
+
>
|
|
24
|
+
const transcriptSeqToStructureSeqPosition = {} as Record<
|
|
25
|
+
string,
|
|
26
|
+
number | undefined
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line unicorn/no-for-loop
|
|
30
|
+
for (let i = 0; i < structureSeq.length; i++) {
|
|
31
|
+
const c1 = structureSeq[i]
|
|
32
|
+
const c2 = transcriptSeq[i]
|
|
33
|
+
|
|
34
|
+
if (c1 === c2) {
|
|
35
|
+
structureSeqToTranscriptSeqPosition[j] = k
|
|
36
|
+
transcriptSeqToStructureSeqPosition[k] = j
|
|
37
|
+
k++
|
|
38
|
+
j++
|
|
39
|
+
} else if (c2 === '-') {
|
|
40
|
+
j++
|
|
41
|
+
} else if (c1 === '-') {
|
|
42
|
+
k++
|
|
43
|
+
} else {
|
|
44
|
+
structureSeqToTranscriptSeqPosition[j] = k
|
|
45
|
+
transcriptSeqToStructureSeqPosition[k] = j
|
|
46
|
+
|
|
47
|
+
k++
|
|
48
|
+
j++
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
structureSeqToTranscriptSeqPosition,
|
|
53
|
+
transcriptSeqToStructureSeqPosition,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function structurePositionToAlignmentMap(alignment: Alignment) {
|
|
58
|
+
const structureSeq = alignment.alns[0].seq
|
|
59
|
+
const structurePositionToAlignment = {} as Record<string, number | undefined>
|
|
60
|
+
|
|
61
|
+
for (let i = 0, j = 0; i < structureSeq.length; i++) {
|
|
62
|
+
if (structureSeq[i] !== '-') {
|
|
63
|
+
structurePositionToAlignment[j] = i
|
|
64
|
+
j++
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return structurePositionToAlignment
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function transcriptPositionToAlignmentMap(alignment: Alignment) {
|
|
72
|
+
const transcriptSeq = alignment.alns[1].seq
|
|
73
|
+
const transcriptPositionToAlignment = {} as Record<string, number | undefined>
|
|
74
|
+
|
|
75
|
+
for (let i = 0, j = 0; i < transcriptSeq.length; i++) {
|
|
76
|
+
if (transcriptSeq[i] !== '-') {
|
|
77
|
+
transcriptPositionToAlignment[j] = i
|
|
78
|
+
j++
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return transcriptPositionToAlignment
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// see similar function in msaview plugin
|
|
86
|
+
export function genomeToTranscriptSeqMapping(feature: Feature) {
|
|
87
|
+
// @ts-expect-error
|
|
88
|
+
return g2p(feature.toJSON())
|
|
89
|
+
}
|