diff --git a/backend/app/app/api/v2/endpoints/molecule.py b/backend/app/app/api/v2/endpoints/molecule.py
index fa29c9b..930ed40 100644
--- a/backend/app/app/api/v2/endpoints/molecule.py
+++ b/backend/app/app/api/v2/endpoints/molecule.py
@@ -424,8 +424,13 @@ def search_neighbors(
raise HTTPException(
status_code=400, detail="No molecule with the id provided was found!"
)
-
- return results
+ # If a molecule does not have UMAP or PCA data, the results returned will just be molecules from id 1 to the limit.
+ # The easiest way to check if the molecule has PCA or UMAP data is to see if the first molecule returned is the same as the one requested since the distance should be 0.
+ if (results[0][1] == molecule_id):
+ return results
+ else:
+ # Return a 204 since the query executed but there is no real UMAP or PCA data.
+ return Response(status_code=204)
@router.get("/dimensions/", response_model=List[schemas.MoleculeComponents])
diff --git a/frontend/src/pages/Molecule.jsx b/frontend/src/pages/Molecule.jsx
index 90e2bb7..fe6e020 100644
--- a/frontend/src/pages/Molecule.jsx
+++ b/frontend/src/pages/Molecule.jsx
@@ -46,7 +46,10 @@ async function dimensionality(molecule_id, type, components, signal, limit=10) {
if (!response.ok) {
throw new Error('Invalid Molecule Id')
}
-
+ else if (response.status == 204) {
+ // Return an empty array because there is no PCA or UMAP data.
+ return [];
+ }
else {
return await response.json()
}
@@ -169,7 +172,9 @@ export default function MoleculeInfo() {
return (
-
+
+ { Object.keys(molData).length > 0 ?
+
1366) ? 6 : 12} sx={{mt: 3}}>
{Object.keys(svg).length > 0 &&
1366) ? 6 : 12}>
{Object.keys(molData).length > 0 && }
- {(width > 768) && allConformers.length > 0 && conformer.length > 0 && 1366) ? 6 : 12}>
+ {(width > 768) && allConformers.length > 0 && conformer.length > 0 && 1366) && Object.keys(neighborData).length > 0 ? 6 : 12}>
Conformer
@@ -219,8 +224,8 @@ export default function MoleculeInfo() {
}
- {(width > 768) && 1366) && allConformers.length > 0 && conformer.length > 0 ? 6 : 12}>
- {Object.keys(neighborData).length > 0 ?
+ {(width > 768) && Object.keys(neighborData).length > 0 && 1366) && allConformers.length > 0 && conformer.length > 0 ? 6 : 12}>
+ {Object.keys(neighborData).length > 0 &&
- :
-
-
-
}
}
- {Object.keys(molData).length > 0 && (width > 768) &&
- }
-
+ :
+
+
+ }
)
}