-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hgvsg column in mutation table and link out to genome nexus
- hgvsg is shown by default - the hgvsg will be shorted with ... if the ref or var is too long
- Loading branch information
Showing
8 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions
107
src/shared/components/mutationTable/column/HgvsgColumnFormatter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import * as React from 'react'; | ||
import {Circle} from "better-react-spinkit"; | ||
import 'rc-tooltip/assets/bootstrap_white.css'; | ||
import {Mutation} from "shared/api/generated/CBioPortalAPI"; | ||
import { | ||
TableCellStatusIndicator, | ||
TableCellStatus, | ||
VariantAnnotation | ||
} from "cbioportal-frontend-commons"; | ||
import GenomeNexusCache, { GenomeNexusCacheDataType } from "shared/cache/GenomeNexusCache"; | ||
|
||
import hgvsgStyles from "./hgvsg.module.scss"; | ||
|
||
|
||
export default class HgvsgColumnFormatter { | ||
|
||
public static renderFunction(data:Mutation[], | ||
genomeNexusCache:GenomeNexusCache|undefined) { | ||
const genomeNexusCacheData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache); | ||
|
||
return <span className={hgvsgStyles["hgvsg-data"]}>{HgvsgColumnFormatter.getHgvsgDataViz(genomeNexusCacheData)}</span>; | ||
} | ||
|
||
private static getGenomeNexusDataFromCache(data:Mutation[], cache:GenomeNexusCache|undefined):GenomeNexusCacheDataType | null { | ||
if (data.length === 0 || !cache) { | ||
return null; | ||
} | ||
return cache.get(data[0]); | ||
} | ||
|
||
private static getHgvsgDataViz(genomeNexusCacheData:GenomeNexusCacheDataType|null) { | ||
let status:TableCellStatus | null = null; | ||
if (genomeNexusCacheData === null) { | ||
status = TableCellStatus.LOADING; | ||
} else if (genomeNexusCacheData.status === "error") { | ||
status = TableCellStatus.ERROR; | ||
} else if (genomeNexusCacheData.data === null) { | ||
status = TableCellStatus.NA; | ||
} else { | ||
let hgvsgData = HgvsgColumnFormatter.getData(genomeNexusCacheData.data); | ||
if (hgvsgData == null) { | ||
return null; | ||
} | ||
else { | ||
return ( | ||
<a href={`https://www.genomenexus.org/variant/${hgvsgData}`} target="_blank" rel="noopener noreferrer"> | ||
{hgvsgData} | ||
<img | ||
height='16' | ||
width='16' | ||
src={require("./GenomeNexusLogo.png")} | ||
alt='Genome Nexus' | ||
/> | ||
</a> | ||
); | ||
} | ||
} | ||
|
||
if (status !== null) { | ||
// show loading circle | ||
if (status === TableCellStatus.LOADING) { | ||
return <Circle size={18} scaleEnd={0.5} scaleStart={0.2} color="#aaa" className="pull-left"/>; | ||
} | ||
else { | ||
return <TableCellStatusIndicator status={status}/>; | ||
} | ||
} | ||
} | ||
|
||
public static getData(genomeNexusData: VariantAnnotation | null): string | null | ||
{ | ||
if (!genomeNexusData) | ||
{ | ||
return null; | ||
} | ||
return genomeNexusData.hgvsg; | ||
} | ||
|
||
public static download(data:Mutation[], genomeNexusCache:GenomeNexusCache): string | ||
{ | ||
const genomeNexusData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache); | ||
const hgvsgData = genomeNexusData && HgvsgColumnFormatter.getData(genomeNexusData.data); | ||
|
||
if (!hgvsgData) { | ||
return ""; | ||
} | ||
else { | ||
return hgvsgData; | ||
} | ||
} | ||
|
||
public static getSortValue(data:Mutation[], genomeNexusCache:GenomeNexusCache): string|null { | ||
const genomeNexusCacheData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache); | ||
if (genomeNexusCacheData) { | ||
let hgvsgData = HgvsgColumnFormatter.getData(genomeNexusCacheData.data); | ||
if (hgvsgData == null) { | ||
return null | ||
} | ||
else { | ||
return hgvsgData; | ||
} | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/shared/components/mutationTable/column/hgvsg.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.hgvsg-data a, | ||
.hgvsg-data a:hover, | ||
.hgvsg-data a:focus, | ||
.hgvsg-data a:active, | ||
.hgvsg-data a:visited { | ||
color: black; | ||
} | ||
|
||
.hgvsg-data { | ||
white-space: nowrap; | ||
max-width: 300px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display:block; | ||
} | ||
|
||
.hgvsg-data:hover { | ||
text-overflow: clip; | ||
word-break: break-all; | ||
overflow: visible; | ||
white-space: normal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters