Skip to content

Commit c9bd68f

Browse files
committed
More blast stuff
1 parent 1e0987c commit c9bd68f

13 files changed

Lines changed: 411 additions & 47 deletions

config.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@
3232
}
3333
],
3434
"tracks": [
35+
{
36+
"type": "FeatureTrack",
37+
"trackId": "hg38-ncbiRefSeq",
38+
"name": "NCBI RefSeq - RefSeq All",
39+
"assemblyNames": ["hg38"],
40+
"description": "NCBI RefSeq genes, curated and predicted (NM_*, XM_*, NR_*, XR_*, NP_*, YP_*)",
41+
"category": ["Genes and Gene Predictions"],
42+
"metadata": {
43+
"ucsc": {
44+
"baseColorDefault": "genomicCodons",
45+
"baseColorUseCds": "given",
46+
"color": "12,12,120",
47+
"idXref": "ncbiRefSeqLink mrnaAcc name",
48+
"longLabel": "NCBI RefSeq genes, curated and predicted (NM_*, XM_*, NR_*, XR_*, NP_*, YP_*)",
49+
"parent": "refSeqComposite off",
50+
"priority": "1",
51+
"shortLabel": "RefSeq All",
52+
"track": "ncbiRefSeq",
53+
"html": ""
54+
}
55+
},
56+
"adapter": {
57+
"type": "Gff3TabixAdapter",
58+
"gffGzLocation": {
59+
"locationType": "UriLocation",
60+
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeq.gff.gz"
61+
},
62+
"index": {
63+
"indexType": "CSI",
64+
"location": {
65+
"locationType": "UriLocation",
66+
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeq.gff.gz.csi"
67+
}
68+
}
69+
}
70+
},
3571
{
3672
"type": "FeatureTrack",
3773
"trackId": "hg38-knownGene",

src/LaunchMsaView/components/NCBIBlastQuery/CachedBlastResults.tsx

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useEffect, useMemo, useState } from 'react'
22

33
import { Feature, getContainingView } from '@jbrowse/core/util'
44
import DeleteIcon from '@mui/icons-material/Delete'
@@ -24,6 +24,31 @@ import type { CachedBlastResult } from '../../../utils/blastCache'
2424
import type { AbstractTrackModel } from '@jbrowse/core/util'
2525
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
2626

27+
function getGeneIdentifiers(feature: Feature): string[] {
28+
const ids = [
29+
feature.id(),
30+
feature.get('id'),
31+
feature.get('name'),
32+
feature.get('gene_id'),
33+
feature.get('gene_name'),
34+
].filter((id): id is string => !!id)
35+
return [...new Set(ids)]
36+
}
37+
38+
function getResultDisplayName(result: CachedBlastResult): string {
39+
const parts = []
40+
if (result.geneName) {
41+
parts.push(result.geneName)
42+
}
43+
if (result.transcriptName && result.transcriptName !== result.geneName) {
44+
parts.push(result.transcriptName)
45+
}
46+
if (parts.length === 0) {
47+
parts.push(result.geneId ?? result.transcriptId ?? 'Unknown')
48+
}
49+
return parts.join(' - ')
50+
}
51+
2752
const CachedBlastResults = observer(function ({
2853
model,
2954
handleClose,
@@ -37,19 +62,20 @@ const CachedBlastResults = observer(function ({
3762
const [loading, setLoading] = useState(true)
3863
const view = getContainingView(model) as LinearGenomeViewModel
3964

40-
const geneId = feature.get('id')
65+
const geneIds = useMemo(() => getGeneIdentifiers(feature), [feature])
66+
4167
useEffect(() => {
4268
// eslint-disable-next-line @typescript-eslint/no-floating-promises
4369
;(async () => {
4470
try {
4571
const cached = await getAllCachedResults()
46-
setResults(cached.filter(r => r.geneId === geneId))
72+
setResults(cached.filter(r => r.geneId && geneIds.includes(r.geneId)))
4773
setLoading(false)
4874
} catch (e) {
4975
console.error(e)
5076
}
5177
})()
52-
}, [geneId])
78+
}, [geneIds])
5379

5480
const handleDelete = async (id: string) => {
5581
await deleteCachedResult(id)
@@ -65,7 +91,7 @@ const CachedBlastResults = observer(function ({
6591
blastLaunchViewFromCache({
6692
view,
6793
cached,
68-
newViewTitle: `BLAST - ${cached.geneId ?? cached.transcriptId ?? 'Unknown gene'}`,
94+
newViewTitle: `BLAST - ${getResultDisplayName(cached)}`,
6995
})
7096
handleClose()
7197
}
@@ -132,7 +158,7 @@ const CachedBlastResults = observer(function ({
132158
}}
133159
>
134160
<ListItemText
135-
primary={`${result.geneId ?? result.transcriptId ?? 'Unknown'} - ${result.blastDatabase}/${result.blastProgram} (${result.msaAlgorithm})`}
161+
primary={`${getResultDisplayName(result)} - ${result.blastDatabase}/${result.blastProgram} (${result.msaAlgorithm})`}
136162
secondary={`${new Date(result.timestamp).toLocaleString()} - Seq: ${result.proteinSequence.slice(0, 30)}...`}
137163
/>
138164
</ListItemButton>

src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastAutomaticPanel.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useEffect, useMemo, useState } from 'react'
22

33
import { ErrorMessage } from '@jbrowse/core/ui'
44
import {
@@ -30,6 +30,17 @@ import { useTranscriptSelection } from '../useTranscriptSelection'
3030

3131
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
3232

33+
function getGeneIdentifiers(feature: Feature): string[] {
34+
const ids = [
35+
feature.id(),
36+
feature.get('id'),
37+
feature.get('name'),
38+
feature.get('gene_id'),
39+
feature.get('gene_name'),
40+
].filter((id): id is string => !!id)
41+
return [...new Set(ids)]
42+
}
43+
3344
const useStyles = makeStyles()({
3445
dialogContent: {
3546
width: '80em',
@@ -72,19 +83,21 @@ const NCBIBlastAutomaticPanel = observer(function ({
7283
const [hasCachedResults, setHasCachedResults] = useState(false)
7384
const [error, setError] = useState<unknown>()
7485

75-
const geneId = feature.get('id')
86+
const geneIds = useMemo(() => getGeneIdentifiers(feature), [feature])
7687
useEffect(() => {
7788
// eslint-disable-next-line @typescript-eslint/no-floating-promises
7889
;(async () => {
7990
try {
8091
const results = await getAllCachedResults()
81-
setHasCachedResults(results.some(r => r.geneId === geneId))
92+
setHasCachedResults(
93+
results.some(r => r.geneId && geneIds.includes(r.geneId)),
94+
)
8295
} catch (e) {
8396
console.error(e)
8497
setError(e)
8598
}
8699
})()
87-
}, [geneId])
100+
}, [geneIds])
88101

89102
const {
90103
options,

src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastMethodSelector.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ export default function NCBIBlastMethodSelector({
2121
<FormControlLabel
2222
value="automatic"
2323
control={<Radio />}
24-
label="Run NCBI BLAST and load results automatically"
24+
label="Automatic"
2525
/>
2626
<FormControlLabel
27-
value="manual"
27+
value="rid"
2828
control={<Radio />}
29-
label="Link to NCBI BLAST and import results manually"
29+
label="Load from RID"
3030
/>
31+
<FormControlLabel value="manual" control={<Radio />} label="Manual" />
3132
</RadioGroup>
3233
</FormControl>
3334
)

src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastPanel.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ import { IconButton } from '@mui/material'
77
import NCBIBlastAutomaticPanel from './NCBIBlastAutomaticPanel'
88
import NCBIBlastManualPanel from './NCBIBlastManualPanel'
99
import NCBIBlastMethodSelector from './NCBIBlastMethodSelector'
10+
import NCBIBlastRIDPanel from './NCBIBlastRIDPanel'
1011
import NCBISettingsDialog from './NCBISettingsDialog'
1112
import { BASE_BLAST_URL } from './consts'
1213

1314
import type { AbstractTrackModel, Feature } from '@jbrowse/core/util'
1415

16+
const panelMap = {
17+
automatic: NCBIBlastAutomaticPanel,
18+
rid: NCBIBlastRIDPanel,
19+
manual: NCBIBlastManualPanel,
20+
} as const
21+
1522
export default function NCBIBlastPanel({
1623
handleClose,
1724
model,
@@ -28,10 +35,7 @@ export default function NCBIBlastPanel({
2835
)
2936
const [settingsOpen, setSettingsOpen] = useState(false)
3037

31-
const Panel =
32-
lookupMethod === 'automatic'
33-
? NCBIBlastAutomaticPanel
34-
: NCBIBlastManualPanel
38+
const Panel = panelMap[lookupMethod as keyof typeof panelMap]
3539

3640
return (
3741
<>

0 commit comments

Comments
 (0)