- {torsions[Object.keys(torsions)[glycanTab]] !== undefined ? (
+ {torsions !== undefined ? (
<>
Linkage Torsion Analysis
@@ -109,15 +113,13 @@ export default function TorsionGraph(data) {
>
) : (
<>
-
-
Linkage Torsion Analysis
-
+
Linkage Torsion Analysis
+
There are no linkages detected in this model.
-
-
- >
+
+ >
)}
);
diff --git a/webapp/src/shared/TorsionPlot/TorsionMultiPlot.tsx b/webapp/src/shared/TorsionPlot/TorsionMultiPlot.tsx
index c1f7283c..8b0ff530 100644
--- a/webapp/src/shared/TorsionPlot/TorsionMultiPlot.tsx
+++ b/webapp/src/shared/TorsionPlot/TorsionMultiPlot.tsx
@@ -134,11 +134,12 @@ export default function TorsionMultiPlot({
useEffect(() => {
setTab(0);
- console.log(torsions)
}, []);
useEffect(() => {
- if (torsions === undefined) {return}
+ if (torsions === undefined) {
+ return;
+ }
const [linkageArray_, sortedLinkageArray_] = sortTorsions(torsions);
setLinkageArray(linkageArray_);
setSortedLinkageArray(sortedLinkageArray_);
From 982447e3053929b5487b95edd2fdd933e5954ccf Mon Sep 17 00:00:00 2001
From: Jordan Dialpuri <44945647+Dialpuri@users.noreply.github.com>
Date: Wed, 13 Mar 2024 10:51:32 +0000
Subject: [PATCH 21/25] Refactor 'getColour' and 'extracted' functions for
cleaner code
The changes in this commit refactor 'getColour' and 'extracted' functions in Constants.tsx file for cleaner, more readable code. Specifically, the ternary operator in 'getColour' function was simplified and the unnecessary return parentheses in 'extracted' function were removed. Also, missing semicolons were added after function calls for better coding practices.
---
webapp/src/data/Constants.tsx | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/webapp/src/data/Constants.tsx b/webapp/src/data/Constants.tsx
index 7bb50d3f..7282c216 100644
--- a/webapp/src/data/Constants.tsx
+++ b/webapp/src/data/Constants.tsx
@@ -139,23 +139,20 @@ export const DatabaseColumns = [
},
];
-
function getColour(diagnostic) {
- return diagnostic !== "yes" ? "text-red-600" : (diagnostic === "check" ? "text-yellow-600" : "")
+ return diagnostic !== 'yes'
+ ? 'text-red-600'
+ : diagnostic === 'check'
+ ? 'text-yellow-600'
+ : '';
}
-
function extracted(props, accessor) {
const typeValue = props.row.original[accessor];
const diagnostic = props.row.original.diagnostic;
- const colour = getColour(diagnostic)
- return (
-
- {typeValue}
-
- );
+ const colour = getColour(diagnostic);
+ return
{typeValue};
}
export const SugarListColumns = [
@@ -172,7 +169,7 @@ export const SugarListColumns = [
}) => {
const typeValue = props.row.original.conformation;
const diagnostic = props.row.original.diagnostic;
- const colour = getColour(diagnostic)
+ const colour = getColour(diagnostic);
const regex = /([a-zA-Z]*?\d*)([a-zA-Z])(\d*)/;
const formattedString = typeValue.replace(
From 8d009c6d074cf8aeb198457e7bbedccbebd1ecf4 Mon Sep 17 00:00:00 2001
From: Jordan Dialpuri <44945647+Dialpuri@users.noreply.github.com>
Date: Wed, 13 Mar 2024 11:08:34 +0000
Subject: [PATCH 22/25] Implement early return in TorsionPlot effect
Included an early return statement in TorsionPlot.tsx's useEffect to prevent execution when sortedTorsionList is undefined. Also introduced a return statement in the promise error catch block, although its effect would generally be limited as it is the last action in the block.
---
webapp/src/shared/TorsionPlot/TorsionPlot.tsx | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/webapp/src/shared/TorsionPlot/TorsionPlot.tsx b/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
index 5ccd0a65..71a11f99 100644
--- a/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
+++ b/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
@@ -19,6 +19,11 @@ export default function TorsionPlot({
const [linkageFound, setLinkageFound] = useState(false);
useEffect(() => {
+
+ if (sortedTorsionList === undefined) {
+ return;
+ }
+
fetch(linkageDB[linkageType])
.then(async (response) => await response.text())
.then((text) => {
@@ -60,6 +65,7 @@ export default function TorsionPlot({
.catch((error) => {
console.error(error);
setLinkageFound(false);
+ return
});
const overlayPhi: number[] = [];
From f08108e4df0b121c8a47bda4f3f1f02a796f8fcc Mon Sep 17 00:00:00 2001
From: Jordan Dialpuri <44945647+Dialpuri@users.noreply.github.com>
Date: Wed, 13 Mar 2024 11:17:00 +0000
Subject: [PATCH 23/25] Improve sugar data diagnostics in BFactorVsRSCC.tsx
Modified the calculatePoints function to clearly distinguish and handle 'issue' and 'no issue' sugars. Altered data plotting to accurately reflect this improved diagnostic handling, and implemented a comprehensive legend for user-friendly data distinction.
---
.../DatabaseComponents/BFactorVsRSCC.tsx | 59 +++++++++++++++----
1 file changed, 49 insertions(+), 10 deletions(-)
diff --git a/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx b/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
index 35c1bd02..79b0da07 100644
--- a/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
+++ b/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
@@ -2,40 +2,53 @@ import React, { useEffect, useState, lazy } from 'react';
const Plot = lazy(async () => await import('react-plotly.js'));
-function calculatePoints(data): [number[], number[], string[]] {
+function calculatePoints(data): [number[], number[], string[], number[], number[], string[]] {
const glycans = data.data.glycans;
const xAxis: number[] = [];
const yAxis: number[] = [];
const text: string[] = [];
+ const errorXAxis: number[] = [];
+ const errorYAxis: number[] = [];
+ const errorText: string[] = [];
+
for (const key in glycans) {
const glycanType = glycans[key];
for (let i = 0; i < glycanType.length; i++) {
const sugars = glycanType[i].sugars;
for (let j = 0; j < sugars.length; j++) {
- xAxis.push(sugars[j].bFactor as number);
- yAxis.push(sugars[j].rscc as number);
- text.push(sugars[j]['Sugar ID'] as string);
+ if (sugars[j].diagnostic !== 'yes') {
+ errorXAxis.push(sugars[j].bFactor as number);
+ errorYAxis.push(sugars[j].rscc as number);
+ errorText.push(sugars[j].sugarId as string);
+ } else {
+ xAxis.push(sugars[j].bFactor as number);
+ yAxis.push(sugars[j].rscc as number);
+ text.push(sugars[j].sugarId as string);
+ }
}
}
}
- return [xAxis, yAxis, text];
+ return [xAxis, yAxis, text, errorXAxis, errorYAxis, errorText];
}
export default function BFactorVsRSCC(props) {
const [trace, setTrace] = useState({});
const [corrTrace, setCorrTrace] = useState({});
+ const [badTrace, setBadTrace] = useState({});
useEffect(() => {
- const [xAxis, yAxis, text] = calculatePoints(props);
-
- const maxX = Math.max(...xAxis) + 5;
+ const [xAxis, yAxis, text, errorXAxis, errorYAxis, errorText] = calculatePoints(props);
+ const maxX = Math.max(Math.max(...xAxis), Math.max(...errorXAxis)) + 5;
+ console.log(errorXAxis, xAxis)
setCorrTrace({
x: [0, maxX],
y: [0.7, 0.7],
+ text,
+ hoverinfo: 'text',
fill: 'tozeroy',
fillcolor: 'rgba(173,181,189,0.3)',
fillopacity: 0.1,
@@ -44,6 +57,7 @@ export default function BFactorVsRSCC(props) {
color: 'rgba(173,181,189,0.5)',
symbol: 'x',
},
+ showlegend: false,
});
setTrace({
@@ -58,6 +72,23 @@ export default function BFactorVsRSCC(props) {
color: 'blue',
symbol: 'o',
},
+ name: 'No Issues',
+
+ });
+
+ setBadTrace({
+ x: errorXAxis,
+ y: errorYAxis,
+ text: errorText,
+ hoverinfo: 'text',
+ mode: 'markers',
+ type: 'scatter',
+ marker: {
+ size: 8,
+ color: 'red',
+ symbol: 'x',
+ },
+ name: 'Issues',
});
}, [props]);
@@ -65,12 +96,20 @@ export default function BFactorVsRSCC(props) {
BFactor vs RSCC
Date: Wed, 13 Mar 2024 11:18:58 +0000
Subject: [PATCH 24/25] Remove unnecessary return and blank lines in
TorsionPlot
This commit simplifies the TorsionPlot.tsx file by eliminating a return statement in the error catch block that was superfluous. Also, it removes unnecessary blank lines to improve code readability.
---
webapp/src/database/DatabaseComponents/TorsionGraph.tsx | 2 +-
webapp/src/shared/TorsionPlot/TorsionPlot.tsx | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/webapp/src/database/DatabaseComponents/TorsionGraph.tsx b/webapp/src/database/DatabaseComponents/TorsionGraph.tsx
index c0f90f7f..7ca84613 100644
--- a/webapp/src/database/DatabaseComponents/TorsionGraph.tsx
+++ b/webapp/src/database/DatabaseComponents/TorsionGraph.tsx
@@ -70,7 +70,7 @@ export default function TorsionGraph(data) {
Object.keys(torsionList)
.sort()
- .forEach(function (k, v) {
+ .forEach(function (k, _) {
sortedTorsionList[k] = torsionList[k];
});
diff --git a/webapp/src/shared/TorsionPlot/TorsionPlot.tsx b/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
index 71a11f99..cf7d1d66 100644
--- a/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
+++ b/webapp/src/shared/TorsionPlot/TorsionPlot.tsx
@@ -19,7 +19,6 @@ export default function TorsionPlot({
const [linkageFound, setLinkageFound] = useState(false);
useEffect(() => {
-
if (sortedTorsionList === undefined) {
return;
}
@@ -65,7 +64,6 @@ export default function TorsionPlot({
.catch((error) => {
console.error(error);
setLinkageFound(false);
- return
});
const overlayPhi: number[] = [];
From 455d7b2c7c72d715a6c5341f5d4a82c045c1b899 Mon Sep 17 00:00:00 2001
From: Jordan Dialpuri <44945647+Dialpuri@users.noreply.github.com>
Date: Wed, 13 Mar 2024 11:19:22 +0000
Subject: [PATCH 25/25] Refactor BFactorVsRSCC.tsx for better readability
This commit cleans up the BFactorVsRSCC.tsx file. It modifies the calculatePoints function declaration layout and improves console.log formatting. It also eliminates unnecessary blank lines and corrects syntax to enhance code readability.
---
webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx b/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
index 79b0da07..1cf9b4d9 100644
--- a/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
+++ b/webapp/src/database/DatabaseComponents/BFactorVsRSCC.tsx
@@ -2,7 +2,9 @@ import React, { useEffect, useState, lazy } from 'react';
const Plot = lazy(async () => await import('react-plotly.js'));
-function calculatePoints(data): [number[], number[], string[], number[], number[], string[]] {
+function calculatePoints(
+ data
+): [number[], number[], string[], number[], number[], string[]] {
const glycans = data.data.glycans;
const xAxis: number[] = [];
@@ -40,10 +42,10 @@ export default function BFactorVsRSCC(props) {
const [badTrace, setBadTrace] = useState({});
useEffect(() => {
- const [xAxis, yAxis, text, errorXAxis, errorYAxis, errorText] = calculatePoints(props);
+ const [xAxis, yAxis, text, errorXAxis, errorYAxis, errorText] =
+ calculatePoints(props);
const maxX = Math.max(Math.max(...xAxis), Math.max(...errorXAxis)) + 5;
- console.log(errorXAxis, xAxis)
setCorrTrace({
x: [0, maxX],
y: [0.7, 0.7],
@@ -73,7 +75,6 @@ export default function BFactorVsRSCC(props) {
symbol: 'o',
},
name: 'No Issues',
-
});
setBadTrace({