jbrowse-plugin-protein3d 0.5.3 → 0.5.5
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/dist/Protein1DViewRegistry/index.js +4 -9
- package/dist/ProteinView/components/ProteinAlignment.js +18 -4
- package/dist/ProteinView/components/ProteinViewHeader.js +1 -1
- package/dist/ProteinView/model.js +1 -1
- package/dist/ProteinView/proteinToGenomeMapping.d.ts +1 -1
- package/dist/ProteinView/proteinToGenomeMapping.js +10 -7
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js +13 -13
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +4 -4
- package/dist/mappings.d.ts +1 -0
- package/dist/mappings.js +14 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/Protein1DViewRegistry/index.test.ts +55 -0
- package/src/Protein1DViewRegistry/index.ts +5 -11
- package/src/ProteinView/components/ProteinAlignment.tsx +17 -5
- package/src/ProteinView/components/ProteinViewHeader.tsx +1 -1
- package/src/ProteinView/geneExplorerLinkage.test.ts +214 -0
- package/src/ProteinView/model.ts +1 -1
- package/src/ProteinView/proteinToGenomeMapping.ts +12 -9
- package/src/mappings.ts +18 -1
- package/src/version.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SimpleFeature } from '@jbrowse/core/util';
|
|
2
|
-
import { getCodonRange } from 'g2p_mapper';
|
|
3
2
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
4
|
-
import { genomeToTranscriptSeqMapping } from '../mappings';
|
|
3
|
+
import { codonGenomeSpan, genomeToTranscriptSeqMapping } from '../mappings';
|
|
5
4
|
class Protein1DViewRegistry {
|
|
6
5
|
views = observable.map();
|
|
7
6
|
constructor() {
|
|
@@ -53,13 +52,9 @@ class Protein1DViewRegistry {
|
|
|
53
52
|
if (!mapping) {
|
|
54
53
|
return undefined;
|
|
55
54
|
}
|
|
56
|
-
const {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const [start, end] = result;
|
|
62
|
-
return { refName, start, end };
|
|
55
|
+
const { p2gCodon, refName } = mapping;
|
|
56
|
+
const span = codonGenomeSpan(p2gCodon, proteinPos);
|
|
57
|
+
return span ? { refName, start: span[0], end: span[1] } : undefined;
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
export const protein1DViewRegistry = new Protein1DViewRegistry();
|
|
@@ -29,16 +29,30 @@ const ProteinAlignment = observer(function ProteinAlignment({ model, }) {
|
|
|
29
29
|
const containerRef = useRef(null);
|
|
30
30
|
const scrolledToSelectionRef = useRef(false);
|
|
31
31
|
const { data: featureData, isLoading: featureLoading, error: featureError, } = useProteinFeatureTrackData(model, uniprotId);
|
|
32
|
+
// Follow the hovered column, but only when it has scrolled off-screen, and
|
|
33
|
+
// then only far enough to bring it back to the nearest edge. Re-centering on
|
|
34
|
+
// every hover (the old behavior) made the panel drift continuously as the
|
|
35
|
+
// cursor moved; scroll-into-view keeps it still whenever the column is
|
|
36
|
+
// already visible.
|
|
32
37
|
useEffect(() => autorun(() => {
|
|
33
38
|
const container = containerRef.current;
|
|
34
39
|
if (model.autoScrollAlignment &&
|
|
35
40
|
!model.isMouseInAlignment &&
|
|
36
41
|
model.alignmentHoverPos !== undefined &&
|
|
37
42
|
container) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
const x = model.alignmentHoverPos * CHAR_WIDTH;
|
|
44
|
+
const margin = CHAR_WIDTH * 4;
|
|
45
|
+
const viewStart = container.scrollLeft;
|
|
46
|
+
const viewEnd = viewStart + container.clientWidth;
|
|
47
|
+
if (x < viewStart + margin) {
|
|
48
|
+
container.scrollTo({ left: x - margin, behavior: 'smooth' });
|
|
49
|
+
}
|
|
50
|
+
else if (x > viewEnd - margin) {
|
|
51
|
+
container.scrollTo({
|
|
52
|
+
left: x - container.clientWidth + margin,
|
|
53
|
+
behavior: 'smooth',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
}), [model]);
|
|
44
58
|
// Scroll the persistent selection into view once it first resolves, so a
|
|
@@ -2,7 +2,7 @@ import type { PairwiseAlignment } from '../mappings';
|
|
|
2
2
|
import type { IAnyStateTreeNode } from '@jbrowse/mobx-state-tree';
|
|
3
3
|
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
|
|
4
4
|
interface GenomeToTranscriptSeqMapping {
|
|
5
|
-
|
|
5
|
+
p2gCodon: Record<number, number[]>;
|
|
6
6
|
strand: number;
|
|
7
7
|
refName: string;
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util';
|
|
2
|
-
import {
|
|
2
|
+
import { codonGenomeSpan } from '../mappings';
|
|
3
3
|
/**
|
|
4
4
|
* Maps a protein structure position to genome coordinates
|
|
5
5
|
* @returns [start, end] tuple of genome coordinates, or undefined if mapping fails
|
|
@@ -9,12 +9,11 @@ export function proteinToGenomeMapping({ model, structureSeqPos, }) {
|
|
|
9
9
|
if (!genomeToTranscriptSeqMapping || !pairwiseAlignment) {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
|
-
const {
|
|
12
|
+
const { p2gCodon } = genomeToTranscriptSeqMapping;
|
|
13
13
|
const transcriptPos = structureSeqToTranscriptSeqPosition?.[structureSeqPos];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return getCodonRange(p2g, transcriptPos, strand);
|
|
14
|
+
return transcriptPos === undefined
|
|
15
|
+
? undefined
|
|
16
|
+
: codonGenomeSpan(p2gCodon, transcriptPos);
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
19
|
* Maps a protein structure range to genome coordinates
|
|
@@ -63,7 +62,11 @@ export async function navigateToProteinPosition({ model, structureSeqPos, struct
|
|
|
63
62
|
}
|
|
64
63
|
const [start, end] = result;
|
|
65
64
|
if (zoomToBaseLevel) {
|
|
66
|
-
|
|
65
|
+
// start/end are 0-based half-open (from getCodonRanges). navToLocString
|
|
66
|
+
// parses a 1-based locString (parseLocString does start -= 1), so the start
|
|
67
|
+
// must be shifted to 1-based; the half-open end already equals the 1-based
|
|
68
|
+
// inclusive end. Passing the raw 0-based start landed the view 1bp 5'.
|
|
69
|
+
await connectedView.navToLocString(`${refName}:${start + 1}-${end}${strand === -1 ? '[rev]' : ''}`, undefined, 0.2);
|
|
67
70
|
}
|
|
68
71
|
else {
|
|
69
72
|
const { assemblyManager } = session;
|