import React, { useState, useEffect } from 'react'
import { observer } from 'mobx-react'
import {
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Chip,
Tooltip,
Link,
} from '@mui/material'
import { makeStyles } from 'tss-react/mui'
import AddIcon from '@mui/icons-material/Add'
import RemoveIcon from '@mui/icons-material/Remove'
import BaseCard from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/BaseCard'
import { getGeneProjectsAsync, getMutationProjectsAsync } from './Utility'
const useStyles = makeStyles()({
table: {
padding: 0,
},
link: {
color: 'rgb(0, 0, 238)',
},
})
function Consequence(props: { feature: any }) {
const { classes } = useStyles()
const { feature } = props
if (!feature.consequence) {
return null
}
const consequences = feature.consequence.hits.edges
return (
Gene
AA Change
Consequence
Coding DNA Change
Impact
Gene Strand
Transcript
{consequences.map((value: any, i: number) =>
value ? (
{value.node.transcript.gene.symbol}
{value.node.transcript.aa_change}
{value.node.transcript.consequence_type}
{value.node.transcript.annotation.hgvsc}
{value.node.transcript.annotation.vep_impact ? (
) : null}
{value.node.transcript.annotation.sift_impact ? (
) : null}
{value.node.transcript.annotation.polyphen_impact ? (
) : null}
{value.node.transcript.gene.gene_strand === 1 ? (
) : (
)}
{value.node.transcript.transcript_id}
{value.node.transcript.is_canonical ? (
) : null}
) : null,
)}
)
}
const ExternalLink = observer(function ExternalLink({
id,
name,
link,
}: {
id: string
name: string
link: string
}) {
const { classes } = useStyles()
return (
{name}
{id}
)
})
function GeneExternalLinks(props: { feature: any }) {
const { classes } = useStyles()
const { feature } = props
const externalLinkArray = [
{
id: feature.geneId,
name: 'GDC',
link: 'https://portal.gdc.cancer.gov/genes/',
},
{
id: feature.geneId,
name: 'ENSEMBL',
link: 'http://www.ensembl.org/id/',
},
{
id: feature.canonicalTranscriptId,
name: 'Canonical Transcript ID',
link: 'http://www.ensembl.org/id/',
},
{
id: feature.externalDbIds.hgnc[0],
name: 'HGNC',
link: 'https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/',
},
{
id: feature.externalDbIds.uniprotkbSwissprot[0],
name: 'UniProtKB Swiss-Prot',
link: 'http://www.uniprot.org/uniprot/',
},
{
id: feature.externalDbIds.entrezGene[0],
name: 'NCBI',
link: 'http://www.ncbi.nlm.nih.gov/gene/',
},
{
id: feature.externalDbIds.omimGene[0],
name: 'OMIM',
link: 'https://www.omim.org/entry/',
},
]
return (
{externalLinkArray.map((externalLink, key) => (
))}
)
}
function removeCosmicPrefix(cosmicId: string) {
return cosmicId.replace('COSM', '').replace('COSN', '')
}
const CosmicLinks = observer(function CosmicLinks({
cosmicId,
}: {
cosmicId: string[]
}) {
const { classes } = useStyles()
return (
Cosmic
{cosmicId?.map(value => (
{value}
))}
)
})
function SSMExternalLinks(props: { feature: any }) {
const { classes } = useStyles()
const { feature } = props
const externalLinkArray = [
{
id: feature.ssmId,
name: 'GDC',
link: 'https://portal.gdc.cancer.gov/ssms/',
},
]
return (
{externalLinkArray.map((externalLink, key) => (
))}
{feature.cosmicId ? (
) : null}
)
}
function SSMProject(props: Record) {
const { classes } = useStyles()
const { projectId, docCount, projectsInformation, gdcProjectsCounts } = props
const projectInfo = projectsInformation.find(
(x: any) => x.node.project_id === projectId,
)
const gdcProjectCount = gdcProjectsCounts.find(
(x: any) => x.projectId === projectId,
)
return (
{projectId}
{projectInfo.node.disease_type.join(', ')}
{projectInfo.node.primary_site.join(', ')}
{docCount} / {gdcProjectCount.docCount}
)
}
function SSMProjects(props: Record) {
const { classes } = useStyles()
const { featureId } = props
const [mutationProjectsCounts, setMutationProjectsCounts] = useState(
[],
)
const [projectsInformation, setProjectsInformation] = useState([])
const [gdcProjectsCounts, setGdcProjectsCounts] = useState([])
useEffect(() => {
getMutationProjectsAsync(featureId)
.then(data => {
setProjectsInformation(data.data.projects.hits.edges)
setGdcProjectsCounts(
data.data.viewer.explore.cases.total.project__project_id.buckets,
)
setMutationProjectsCounts(
data.data.viewer.explore.cases.filtered.project__project_id.buckets,
)
})
.catch((e: unknown) => {
console.error(e)
})
}, [featureId])
return (
Project
Disease Type
Site
# Mutation Affected Cases
{mutationProjectsCounts.map((project, key) => (
))}
)
}
function GeneProject(props: Record) {
const { classes } = useStyles()
const { projectId, docCount, projectsInformation, cases } = props
const projectInfo = projectsInformation.find(
(x: any) => x.node.project_id === projectId,
)
const totalProjectCaseCount = cases.total.project__project_id.buckets.find(
(x: any) => x.projectId === projectId,
)
const cnvGainCaseCount = cases.gain.project__project_id.buckets.find(
(x: any) => x.projectId === projectId,
)
const cnvLossCaseCount = cases.loss.project__project_id.buckets.find(
(x: any) => x.projectId === projectId,
)
const cnvTotalCaseCount = cases.cnvTotal.project__project_id.buckets.find(
(x: any) => x.projectId === projectId,
)
return (
{projectId}
{projectInfo.node.disease_type.join(', ')}
{projectInfo.node.primary_site.join(', ')}
{docCount} / {totalProjectCaseCount.docCount}
{cnvGainCaseCount ? cnvGainCaseCount.docCount : '0'} /{' '}
{cnvTotalCaseCount ? cnvTotalCaseCount.docCount : '0'}
{cnvLossCaseCount ? cnvLossCaseCount.docCount : '0'} /{' '}
{cnvTotalCaseCount ? cnvTotalCaseCount.docCount : '0'}
)
}
function GeneProjects(props: Record) {
const { classes } = useStyles()
const { featureId } = props
const [projectsInformation, setProjectsInformation] = useState([])
const [geneProjectsCounts, setGeneProjectsCounts] = useState([])
const [cases, setCases] = useState([])
useEffect(() => {
getGeneProjectsAsync(featureId)
.then(data => {
setProjectsInformation(data.data.projects.hits.edges)
setCases(data.data.viewer.explore.cases)
setGeneProjectsCounts(
data.data.viewer.explore.cases.filtered.project__project_id.buckets,
)
})
.catch((e: unknown) => {
console.error(e)
})
}, [featureId])
return (
Project
Disease Type
Site
# Mutation Affected Cases
# CNV Gains
# CNV Losses
{cases &&
projectsInformation &&
geneProjectsCounts?.map((project, key) => (
))}
)
}
export const GDCExtraPanel = observer(function GDCExtraPanel({
feature,
}: {
feature: Record
}) {
return (
<>
{feature.geneId !== undefined ? (
) : null}
{feature.ssmId !== undefined ? (
) : null}
{feature.ssmId !== undefined ? : null}
{feature.geneId !== undefined ? (
) : null}
{feature.ssmId !== undefined ? (
) : null}
>
)
})