From a660be26ec1bd60f7b723aa322e1dbba543b9a6c Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 23 Aug 2024 10:42:02 -0400 Subject: [PATCH] Fix mouseover at 0 --- .../components/ProteinAlignment.tsx | 4 +-- src/ProteinView/components/ProteinView.tsx | 8 ----- src/ProteinView/model.ts | 5 --- src/ProteinView/proteinToGenomeMapping.ts | 31 ++++++++----------- src/ProteinView/structureModel.ts | 8 +++-- yarn.lock | 28 ++++++++--------- 6 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/ProteinView/components/ProteinAlignment.tsx b/src/ProteinView/components/ProteinAlignment.tsx index e8fed6d..6ffc463 100644 --- a/src/ProteinView/components/ProteinAlignment.tsx +++ b/src/ProteinView/components/ProteinAlignment.tsx @@ -17,10 +17,10 @@ const ProteinAlignment = observer(function ({ model: JBrowsePluginProteinStructureModel }) { const { - structureSeqHoverPos, alignment, - structurePositionToAlignmentMap, alignmentToStructurePosition, + structurePositionToAlignmentMap, + structureSeqHoverPos, showHighlight, } = model if (!alignment) { diff --git a/src/ProteinView/components/ProteinView.tsx b/src/ProteinView/components/ProteinView.tsx index ac93536..1411253 100644 --- a/src/ProteinView/components/ProteinView.tsx +++ b/src/ProteinView/components/ProteinView.tsx @@ -1,7 +1,6 @@ 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' @@ -9,13 +8,6 @@ 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' diff --git a/src/ProteinView/model.ts b/src/ProteinView/model.ts index 1264109..647f130 100644 --- a/src/ProteinView/model.ts +++ b/src/ProteinView/model.ts @@ -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 diff --git a/src/ProteinView/proteinToGenomeMapping.ts b/src/ProteinView/proteinToGenomeMapping.ts index a18a810..312045d 100644 --- a/src/ProteinView/proteinToGenomeMapping.ts +++ b/src/ProteinView/proteinToGenomeMapping.ts @@ -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, - }, - ]) } diff --git a/src/ProteinView/structureModel.ts b/src/ProteinView/structureModel.ts index 814382c..8313f34 100644 --- a/src/ProteinView/structureModel.ts +++ b/src/ProteinView/structureModel.ts @@ -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, diff --git a/yarn.lock b/yarn.lock index c8d79f6..9bd1a33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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== @@ -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== @@ -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== @@ -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== @@ -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" @@ -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==