Skip to content

Commit

Permalink
Clear selection
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 18, 2024
1 parent ad83306 commit 6b45c21
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 160 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@mui/icons-material": "^5.15.10",
"clustal-js": "^2.0.1",
"g2p_mapper": "^1.0.3",
"molstar": "^4.0.0",
"pako": "^2.1.0"
},
Expand Down
44 changes: 3 additions & 41 deletions src/mappings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Feature } from '@jbrowse/core/util'
import { genomeToTranscriptSeqMapping as g2p } from 'g2p_mapper'

export interface Alignment {
alns: {
Expand Down Expand Up @@ -83,45 +84,6 @@ export function transcriptPositionToAlignmentMap(alignment: Alignment) {

// see similar function in msaview plugin
export function genomeToTranscriptSeqMapping(feature: Feature) {
const strand = feature.get('strand') as number
const refName = feature.get('refName')
const subs = feature.children() ?? []
const cds = subs
.filter(f => f.get('type') === 'CDS')
.sort((a, b) => strand * (a.get('start') - b.get('start')))
const g2p = {} as Record<number, number | undefined>
const p2g = {} as Record<number, number | undefined>

let proteinCounter = 0
if (strand !== -1) {
for (const f of cds) {
for (
let genomePos = f.get('start');
genomePos < f.get('end');
genomePos++
) {
const proteinPos = Math.floor(proteinCounter++ / 3)
g2p[genomePos] = proteinPos
if (!p2g[proteinPos]) {
p2g[proteinPos] = genomePos
}
}
}
} else {
for (const f of cds) {
for (
let genomePos = f.get('end');
genomePos > f.get('start');
genomePos--
) {
const proteinPos = Math.floor(proteinCounter++ / 3)
g2p[genomePos] = proteinPos
if (!p2g[proteinPos]) {
p2g[proteinPos] = genomePos
}
}
}
}

return { g2p, p2g, refName, strand }
// @ts-expect-error
return g2p(feature.toJSON())
}
Loading

0 comments on commit 6b45c21

Please sign in to comment.