-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathJupyterNotebookTool.tsx
82 lines (73 loc) · 2.82 KB
/
JupyterNotebookTool.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import * as React from 'react';
import { observer } from 'mobx-react';
import { Helmet } from 'react-helmet';
import { PageLayout } from '../../../../shared/components/PageLayout/PageLayout';
import OncoprinterStore from './OncoprinterStore';
import { observable, makeObservable } from 'mobx';
import { getBrowserWindow } from 'cbioportal-frontend-commons';
export interface IOncoprinterToolProps {}
@observer
export default class JupyterNotebookTool extends React.Component<
IOncoprinterToolProps,
{}
> {
private store = new OncoprinterStore();
@observable geneticDataInput = '';
@observable clinicalDataInput = '';
@observable heatmapDataInput = '';
@observable geneOrderInput = '';
@observable sampleOrderInput = '';
constructor(props: IOncoprinterToolProps) {
super(props);
makeObservable(this);
(window as any).oncoprinterTool = this;
}
componentDidMount() {
const postData = getBrowserWindow().clientPostedData;
if (postData) {
this.geneticDataInput = postData.genetic;
this.clinicalDataInput = postData.clinical;
this.heatmapDataInput = postData.heatmap;
getBrowserWindow().clientPostedData = null;
}
}
render() {
const code0 = `import pandas as pd\n`;
const code1 = `pd.read_csv('output.csv')\n`;
const final_code = [code0, code1].join('\n');
function toggle() {
// Access the iframe using window.frames
const jupyterIframe = window.frames[0];
if (jupyterIframe) {
jupyterIframe.postMessage({ type: 'from-host-to-iframe' }, '*');
}
}
return (
<PageLayout className={'whiteBackground staticPage'}>
<Helmet>
<title>
{'cBioPortal for Cancer Genomics::JupyterNotebook'}
</title>
</Helmet>
<div className="cbioportal-frontend">
<h1 style={{ display: 'inline', marginRight: 10 }}>
Oncoprinter
</h1>{' '}
Jupyter Notebook for visualization and advance works.
<button onClick={toggle}>Change Theme</button>
<br />
<br />
<div style={{ marginTop: 10 }}>
<iframe
src={`https://master--regal-malabi-ea7e9f.netlify.app/lite/repl/index.html?toolbar=1&kernel=python&code=${encodeURIComponent(
final_code
)}`}
width="100%"
height="900px"
></iframe>
</div>
</div>
</PageLayout>
);
}
}