|
| 1 | +import React, { FC, useEffect, useState } from 'react' |
| 2 | + |
| 3 | +import GeneticElement from '@eplant/GeneticElement' |
| 4 | +import arabidopsis from '@eplant/Species/arabidopsis' |
| 5 | +import { |
| 6 | + useActiveGeneId, |
| 7 | + useGeneticElements, |
| 8 | + useSetGeneticElements, |
| 9 | +} from '@eplant/state' |
| 10 | +import Box from '@mui/material/Box' |
| 11 | +import useTheme from '@mui/material/styles/useTheme' |
| 12 | +import Table from '@mui/material/Table' |
| 13 | +import TableBody from '@mui/material/TableBody' |
| 14 | +import TableCell from '@mui/material/TableCell' |
| 15 | +import TableRow from '@mui/material/TableRow' |
| 16 | + |
| 17 | +import { GeneItem } from '../../ChromosomeViewer/types' |
| 18 | +interface GeneDialogProps { |
| 19 | + gene: GeneItem |
| 20 | +} |
| 21 | +/** Gene dialog to show gene infomation when hovering over gene node. currently not implemented due to restrictions of cytoscape |
| 22 | + * @param {GeneItem} gene GeneItem object to show in table format in the dialog |
| 23 | + * */ |
| 24 | +const GeneDialog: FC<GeneDialogProps> = ({ gene }) => { |
| 25 | + // Global State |
| 26 | + const [activeGeneId, setActiveGeneId] = useActiveGeneId() |
| 27 | + const geneticElements = useGeneticElements() |
| 28 | + const setGeneticElements = useSetGeneticElements() |
| 29 | + const theme = useTheme() |
| 30 | + |
| 31 | + const handleLoadGeneClick = (event: React.MouseEvent<HTMLElement>) => { |
| 32 | + if (gene != null) { |
| 33 | + const geneticElement = new GeneticElement( |
| 34 | + gene.id, |
| 35 | + gene.annotation, |
| 36 | + arabidopsis, |
| 37 | + gene.aliases |
| 38 | + ) |
| 39 | + |
| 40 | + setGeneticElements([...geneticElements[0], geneticElement]) |
| 41 | + setActiveGeneId(gene.id) |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + return ( |
| 46 | + <div |
| 47 | + style={{ |
| 48 | + minWidth: '350px', |
| 49 | + maxWidth: '350px', |
| 50 | + minHeight: '150px', |
| 51 | + maxHeight: '400px', |
| 52 | + paddingInline: 2, |
| 53 | + paddingBlockStart: 1, |
| 54 | + paddingBlockEnd: 2, |
| 55 | + border: '2px solid white', |
| 56 | + }} |
| 57 | + > |
| 58 | + {/* GENE INFO TABLE */} |
| 59 | + <table> |
| 60 | + <tr> |
| 61 | + <td className='label'>Identifier</td> |
| 62 | + <td>{gene.id}</td> |
| 63 | + </tr> |
| 64 | + <tr> |
| 65 | + <td className='label'>Aliases</td> |
| 66 | + <td>{gene.aliases.length > 0 ? gene.aliases : 'N/A'}</td> |
| 67 | + </tr> |
| 68 | + <tr> |
| 69 | + <td className='label'>Annotation</td> |
| 70 | + <td>{gene.annotation != '' ? gene.annotation : 'N/A'}</td> |
| 71 | + </tr> |
| 72 | + </table> |
| 73 | + </div> |
| 74 | + ) |
| 75 | +} |
| 76 | + |
| 77 | +export default GeneDialog |
0 commit comments