Skip to content

Commit

Permalink
fixed dep issue
Browse files Browse the repository at this point in the history
  • Loading branch information
prabh-t committed Oct 25, 2024
1 parent 7b11883 commit 1b2a0f8
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/ui/components/structure/StructuralDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,25 @@ function StructuralDetail(props: StructuralDetailProps) {
const ref = useRef(null);
const [pdbeRef] = useState(new PdbeRef(ref))

const addPredictedStructures = (newPredictedStructures: PredictedStructure[]) => {
setPredictedStructureData(prevItems => [...prevItems, ...newPredictedStructures]);
};

useEffect(() => {
let id = ''
getStructureData(proteinStructureUri).then(
response => {
setPdbData(response.data);
if (response.data.length > 0) {
id = response.data[0].pdb_id
setSelected(response.data[0]);
//pdbeRef.subscribeOnload(response.data[0].start)
}
return getPredictedStructure(isoFormAccession);
}).then(response => {

response.data.forEach(p => {
predictedStructureData.push(p)
})
setPredictedStructureData(predictedStructureData)
if (predictedStructureData.length > 0 && !id) {
// if id already set (pdb id), use that, otherwise, use alphaFold id
id = predictedStructureData[0].entryId
setSelected(predictedStructureData[0])
//pdbeRef.subscribeOnload(aaPosition)
}
addPredictedStructures(response.data)
return hasAlphafillStructure(isoFormAccession)
}).then(response => {
if (response) {
const alphaFillStruc = {
entryId: 'AlphaFill-' + isoFormAccession,
cifUrl: ALPHAFILL_URL + isoFormAccession
}
predictedStructureData.push(alphaFillStruc)
setPredictedStructureData(predictedStructureData)
if (!id) {
setSelected(alphaFillStruc)
}
addPredictedStructures([alphaFillStruc])
}
let functionUrl = '/function/' + isoFormAccession + '/' + aaPosition + (variantAA == null ? '' : ('?variantAA=' + variantAA))
return getFunctionalData(functionUrl)
Expand All @@ -100,9 +84,20 @@ function StructuralDetail(props: StructuralDetailProps) {
setPocketData(funcData.pockets)
}).catch(err => {
console.log(err);
});
})
}, [proteinStructureUri, isoFormAccession, aaPosition, variantAA]);

useEffect(() => {
if (!selected) {
if (pdbData.length > 0) {
setSelected(pdbData[0]);
//pdbeRef.subscribeOnload(response.data[0].start)
} else if (predictedStructureData.length > 0) {
setSelected(predictedStructureData[0])
}
}
}, [pdbData, predictedStructureData, selected]);

if (!selected) {
return <LoaderRow/>
}
Expand Down

0 comments on commit 1b2a0f8

Please sign in to comment.