-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from glycojones/add_statistics_for_db
Add New Stats Page
- Loading branch information
Showing
14 changed files
with
816 additions
and
4 deletions.
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ export default function Footer(): ReactElement { | |
<span className="text-sm text-primary text-center justify-center dark:text-gray-400"> | ||
Jordan Dialpuri, Haroldas Bagdonas and Jon Agirre | ||
<br /> | ||
© 2023 University of York. All Rights Reserved. | ||
© 2023-2024 University of York. All Rights Reserved. | ||
<br /> | ||
Email: [email protected] | ||
<br /> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { lazy, type ReactElement, Suspense } from 'react'; | ||
import { type StatisticsHeaderProps } from '../interfaces/types'; | ||
import Graphs from '../statistics/Graphs/Graphs.tsx'; | ||
|
||
const Loading = lazy(async () => await import('../shared/Loading/Loading.tsx')); | ||
const NavBar = lazy(async () => await import('./NavBar.tsx')); | ||
|
||
export default function StatisticsHeader( | ||
props: StatisticsHeaderProps | ||
): ReactElement { | ||
return ( | ||
<div className="bg-gray text-primary"> | ||
<NavBar setResetApp={props.setResetApp} /> | ||
<Graphs /> | ||
</div> | ||
); | ||
} |
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,34 @@ | ||
import React, { lazy, type ReactElement, useState } from 'react'; | ||
import { Information } from '../../shared/Information/Information.tsx'; | ||
import { type StatisticsHeaderProps } from '../../interfaces/types'; | ||
import StatisticsHeader from '../../layouts/StatisticsHeader.tsx'; | ||
const Footer = lazy(async () => await import('../../layouts/Footer.tsx')); | ||
const BorderElement = lazy( | ||
async () => await import('../../layouts/BorderElement.tsx') | ||
); | ||
|
||
export default function DatabaseSection(): ReactElement { | ||
const [resetApp, setResetApp] = useState<boolean>(false); | ||
|
||
const mainProps: StatisticsHeaderProps = { | ||
resetApp, | ||
setResetApp, | ||
}; | ||
return ( | ||
<> | ||
<StatisticsHeader {...mainProps} /> | ||
<BorderElement | ||
topColor={'#D6D9E5'} | ||
bottomColor={'#F4F9FF'} | ||
reverse={false} | ||
></BorderElement> | ||
<Information /> | ||
<BorderElement | ||
topColor={'#F4F9FF'} | ||
bottomColor={'#D6D9E5'} | ||
reverse={true} | ||
></BorderElement> | ||
<Footer></Footer> | ||
</> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { type Dispatch, type SetStateAction } from 'react'; | ||
|
||
export default function toggleSwitch(props: { | ||
checkState: boolean; | ||
setCheckState: Dispatch<SetStateAction<boolean>>; | ||
}) { | ||
const handleCheckboxChange = () => { | ||
props.setCheckState(!props.checkState); | ||
}; | ||
|
||
return ( | ||
<div className="mt-4"> | ||
<label className="themeSwitcherTwo shadow-card relative inline-flex cursor-pointer select-none items-center justify-center rounded-md bg-white p-1"> | ||
<input | ||
type="checkbox" | ||
className="sr-only" | ||
checked={props.checkState} | ||
onChange={handleCheckboxChange} | ||
/> | ||
<span | ||
className={`flex items-center space-x-[6px] rounded py-2 px-[18px] text-sm font-medium ${ | ||
!props.checkState | ||
? 'text-primary bg-[#f4f7ff]' | ||
: 'text-body-color' | ||
}`} | ||
> | ||
PDB | ||
</span> | ||
<span | ||
className={`flex items-center space-x-[6px] rounded py-2 px-[18px] text-sm font-medium ${ | ||
props.checkState | ||
? 'text-primary bg-[#f4f7ff]' | ||
: 'text-body-color' | ||
}`} | ||
> | ||
{/* {pdbRedoSVG()} */} | ||
PDB-REDO | ||
</span> | ||
</label> | ||
</div> | ||
); | ||
} |
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,184 @@ | ||
import React, { lazy, useEffect, useState } from 'react'; | ||
import Loading from '../../shared/Loading/Loading.tsx'; | ||
import Plot from 'react-plotly.js'; | ||
|
||
export default function ErrorsVsResolution(props: { database: string }) { | ||
const [totalTrace, setTotalTrace] = useState(); | ||
const [errorTrace, setErrorTrace] = useState(); | ||
const [relativeTrace, setRelativeTrace] = useState(); | ||
|
||
// const [depositedTrace, setDepositedTrace] = useState(); | ||
|
||
const [data, setData] = useState<Record< | ||
string, | ||
Record<string, Record<string, number>> | ||
> | null>(null); | ||
|
||
const [width, setWidth] = useState(1000); | ||
const [height, setHeight] = useState(1000); | ||
const [legendDown, setLegendDown] = useState(false); | ||
|
||
useEffect(() => { | ||
const url = | ||
'https://raw.githubusercontent.com/Dialpuri/PrivateerDatabase/master/stats/validation_errors_per_resolution.json'; | ||
|
||
fetch(url) | ||
.then(async (response) => await response.json()) | ||
.then((data) => { | ||
setData( | ||
data as Record< | ||
string, | ||
Record<string, Record<string, number>> | ||
> | ||
); | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error); | ||
}); | ||
|
||
function handleResize() { | ||
const currentWidth = window.innerWidth; | ||
|
||
if (currentWidth < 1000) { | ||
setWidth(0.75 * currentWidth); | ||
setHeight(600); | ||
setLegendDown(true); | ||
} else { | ||
setWidth(Math.max(0.75 * currentWidth, 1000)); | ||
setHeight(0.5 * Math.max(0.75 * currentWidth, 1000)); | ||
|
||
setLegendDown(false); | ||
} | ||
} | ||
|
||
window.addEventListener('resize', handleResize); | ||
handleResize(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (data === null) return; | ||
const newTotalTrace = { | ||
x: Object.keys(data[props.database]), | ||
y: Object.values(data[props.database]).map((e) => { | ||
return e.totalGlycans; | ||
}), | ||
type: 'scatter', | ||
mode: 'lines', | ||
// marker: {color: 'red'}, | ||
name: 'Total Glycosylated Models', | ||
}; | ||
|
||
setTotalTrace(newTotalTrace); | ||
|
||
const newErrorTrace = { | ||
x: Object.keys(data[props.database]), | ||
y: Object.values(data[props.database]).map((e) => { | ||
return e.totalErrors; | ||
}), | ||
type: 'scatter', | ||
mode: 'lines', | ||
// marker: {color: 'green'}, | ||
name: 'Validation Errors', | ||
}; | ||
|
||
setErrorTrace(newErrorTrace); | ||
|
||
const newRelativeTrace = { | ||
x: Object.keys(data[props.database]), | ||
y: Object.values(data[props.database]).map((e) => { | ||
return (100 * e.totalErrors) / e.totalGlyco; | ||
}), | ||
type: 'scatter', | ||
mode: 'lines', | ||
// marker: {color: 'green'}, | ||
yaxis: 'y2', | ||
name: 'Validation Errors', | ||
}; | ||
|
||
setRelativeTrace(newRelativeTrace); | ||
}, [data, props.database]); | ||
|
||
return ( | ||
<> | ||
{data === null ? ( | ||
<Loading loadingText={'Crunching latest data...'} /> | ||
) : ( | ||
<Plot | ||
data={[ | ||
totalTrace, | ||
errorTrace, | ||
// relativeTrace | ||
]} | ||
layout={{ | ||
autosize: true, | ||
width, | ||
height, | ||
title: { | ||
text: `Validation Errors in ${ | ||
props.database === 'pdbredo' | ||
? 'PDB-REDO' | ||
: 'the PDB' | ||
} with resolution`, | ||
x: 0.5, | ||
// y: 1.1, | ||
xanchor: 'auto', // or 'auto', which matches 'left' in this case | ||
yanchor: 'bottom', | ||
xref: 'paper', | ||
yref: 'paper', | ||
}, | ||
plot_bgcolor: '#FFFFFF', | ||
paper_bgcolor: '#D6D9E5', | ||
yaxis: { | ||
title: { | ||
text: 'Number', | ||
}, | ||
tickformat: ',.0f', | ||
linewidth: 2, | ||
mirror: true, | ||
automargin: true, | ||
ticksuffix: ' ', | ||
tickprefix: ' ', | ||
range: [-50, 1600], | ||
// type: 'log' | ||
}, | ||
yaxis2: { | ||
overlaying: 'y', | ||
tickformat: ',.0f', | ||
tickmode: 'auto', | ||
// anchor: 'free', | ||
side: 'right', | ||
automargin: true, | ||
tickprefix: ' ', | ||
range: [0, 100], | ||
}, | ||
xaxis: { | ||
title: { | ||
text: 'Resolution / Å', | ||
}, | ||
linecolor: 'black', | ||
linewidth: 2, | ||
mirror: true, | ||
tickmode: 'auto', | ||
range: [0, 5], | ||
}, | ||
|
||
legend: { | ||
x: legendDown ? 0 : 1.15, | ||
y: legendDown ? -0.6 : 0.5, | ||
// bgcolor: '#FFFFFF', | ||
}, | ||
}} | ||
config = {{ | ||
toImageButtonOptions: { | ||
format: 'svg', | ||
filename: 'validationErrorsWithResolution', | ||
height: 1000, | ||
width: 1500, | ||
scale: 1, | ||
|
||
}}} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
Oops, something went wrong.