Skip to content

Commit

Permalink
Fix mouseover at 0
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 23, 2024
1 parent 82bc2b9 commit a660be2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/ProteinView/components/ProteinAlignment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const ProteinAlignment = observer(function ({
model: JBrowsePluginProteinStructureModel
}) {
const {
structureSeqHoverPos,
alignment,
structurePositionToAlignmentMap,
alignmentToStructurePosition,
structurePositionToAlignmentMap,
structureSeqHoverPos,
showHighlight,
} = model
if (!alignment) {
Expand Down
8 changes: 0 additions & 8 deletions src/ProteinView/components/ProteinView.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import React, { useEffect } from 'react'
import { observer } from 'mobx-react'
import { ErrorMessage, ResizeHandle } from '@jbrowse/core/ui'
import { PluginContext } from 'molstar/lib/mol-plugin/context'

// locals
import { JBrowsePluginProteinViewModel } from '../model'
import ProteinViewHeader from './ProteinViewHeader'

// hooks
import useProteinView from '../useProteinView'
import useProteinViewClickBehavior from '../useProteinViewClickBehavior'
import useProteinViewHoverBehavior from '../useProteinViewHoverBehavior'

// utils
import selectResidue from '../selectResidue'
import highlightResidue from '../highlightResidue'
import clearSelection from '../clearSelection'

// css
import css from '../css/molstar'
Expand Down
5 changes: 0 additions & 5 deletions src/ProteinView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import { addStructureFromData } from './addStructureFromData'
import { addStructureFromURL } from './addStructureFromURL'
import Structure from './structureModel'
import highlightResidue from './highlightResidue'
import {
StructureElement,
StructureProperties,
} from 'molstar/lib/mol-model/structure'
import { clickProteinToGenome } from './proteinToGenomeMapping'

/**
* #stateModel Protein3dViewPlugin
Expand Down
31 changes: 13 additions & 18 deletions src/ProteinView/proteinToGenomeMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,19 @@ export function hoverProteinToGenome({
structureSeqPos: number
model: JBrowsePluginProteinStructureModel
}) {
const session = getSession(model)
const result = proteinToGenomeMapping({ structureSeqPos, model })
const mappedGenomeCoordinate = proteinToGenomeMapping({
structureSeqPos,
model,
})
const { genomeToTranscriptSeqMapping } = model
if (!genomeToTranscriptSeqMapping) {
return
}
if (!result) {
session.notify('Genome position not found')
return
if (genomeToTranscriptSeqMapping && mappedGenomeCoordinate) {
model.setHoverGenomeHighlights([
{
assemblyName: 'hg38',
refName: genomeToTranscriptSeqMapping.refName,
start: mappedGenomeCoordinate[0],
end: mappedGenomeCoordinate[1],
},
])
}
const [s1, s2] = result
const { refName } = genomeToTranscriptSeqMapping
model.setHoverGenomeHighlights([
{
assemblyName: 'hg38',
refName,
start: s1,
end: s2,
},
])
}
8 changes: 5 additions & 3 deletions src/ProteinView/structureModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,11 @@ const Structure = types
) {
const { hoverPosition } = hovered
const pos = genomeToTranscriptSeqMapping.g2p[hoverPosition.coord]
const c0 = pos
? transcriptSeqToStructureSeqPosition?.[pos]
: undefined
const c0 =
pos === undefined
? undefined
: transcriptSeqToStructureSeqPosition?.[pos]

if (c0 !== undefined) {
self.setHoveredPosition({
structureSeqPos: c0,
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ browserslist@^4.23.1, browserslist@^4.23.3:
node-releases "^2.0.18"
update-browserslist-db "^1.1.0"

bs-logger@0.x:
bs-logger@^0.2.6:
version "0.2.6"
resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8"
integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==
Expand Down Expand Up @@ -4207,7 +4207,7 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash.memoize@4.x:
lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==
Expand Down Expand Up @@ -4253,7 +4253,7 @@ make-dir@^4.0.0:
dependencies:
semver "^7.5.3"

make-error@1.x, make-error@^1.1.1:
make-error@^1.1.1, make-error@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
Expand Down Expand Up @@ -5493,7 +5493,7 @@ semver@^6.3.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.1:
semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.1, semver@^7.6.3:
version "7.6.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
Expand Down Expand Up @@ -5969,19 +5969,19 @@ ts-api-utils@^1.3.0:
integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==

ts-jest@^29.1.2:
version "29.2.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.4.tgz#38ccf487407d7a63054a72689f6f99b075e296e5"
integrity sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==
version "29.2.5"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.5.tgz#591a3c108e1f5ebd013d3152142cb5472b399d63"
integrity sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==
dependencies:
bs-logger "0.x"
bs-logger "^0.2.6"
ejs "^3.1.10"
fast-json-stable-stringify "2.x"
fast-json-stable-stringify "^2.1.0"
jest-util "^29.0.0"
json5 "^2.2.3"
lodash.memoize "4.x"
make-error "1.x"
semver "^7.5.3"
yargs-parser "^21.0.1"
lodash.memoize "^4.1.2"
make-error "^1.3.6"
semver "^7.6.3"
yargs-parser "^21.1.1"

ts-node@^10.3.0:
version "10.9.2"
Expand Down Expand Up @@ -6429,7 +6429,7 @@ yaml@^1.10.0:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==

yargs-parser@^21.0.1, yargs-parser@^21.1.1:
yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
Expand Down

0 comments on commit a660be2

Please sign in to comment.