Unverified Commit 141bb080 authored by Andrey Azov's avatar Andrey Azov Committed by GitHub
Browse files

Handle empty uniprot xref in Entity Viewer protein view (#455)

parent d1a44c9a
......@@ -81,10 +81,6 @@ const ProteinsListItemInfo = (props: Props) => {
LoadingState.LOADING
);
const [xrefLoadingState, setXrefLoadingState] = useState<LoadingState>(
LoadingState.LOADING
);
const [summaryStatsLoadingState, setSummaryStatsLoadingState] = useState<
LoadingState
>(LoadingState.LOADING);
......@@ -92,10 +88,10 @@ const ProteinsListItemInfo = (props: Props) => {
const proteinId =
transcript.product_generating_contexts[0].product.unversioned_stable_id;
const { product } =
const { product: productWithProteinDomains } =
transcriptWithProteinDomains?.product_generating_contexts[0] || {};
const uniprotXref = product?.external_references.find(
const uniprotXref = transcript.product_generating_contexts[0].product.external_references.find(
(xref) => xref.source.id === SWISSPROT_SOURCE
);
......@@ -124,7 +120,8 @@ const ProteinsListItemInfo = (props: Props) => {
useEffect(() => {
const abortController = new AbortController();
if (xrefLoadingState === LoadingState.SUCCESS && !uniprotXref) {
if (summaryStatsLoadingState === LoadingState.LOADING && !uniprotXref) {
// if uniprotXref is absent, we cannot fetch relevant data from PDBe; so pretend that we've successfully completed the request
setSummaryStatsLoadingState(LoadingState.SUCCESS);
return;
}
......@@ -147,19 +144,19 @@ const ProteinsListItemInfo = (props: Props) => {
return function cleanup() {
abortController.abort();
};
}, [summaryStatsLoadingState, xrefLoadingState, uniprotXref]);
}, [summaryStatsLoadingState, uniprotXref]);
return (
<div className={styles.proteinsListItemInfo}>
{product && (
{productWithProteinDomains && (
<>
<ProteinDomainImage
proteinDomains={product.protein_domains}
proteinDomains={productWithProteinDomains.protein_domains}
trackLength={trackLength}
width={gene_image_width}
/>
<ProteinImage
product={product}
product={productWithProteinDomains}
trackLength={trackLength}
width={gene_image_width}
/>
......@@ -169,7 +166,7 @@ const ProteinsListItemInfo = (props: Props) => {
<div className={styles.proteinSummary}>
<>
<div className={styles.proteinSummaryTop}>
{uniprotXref && (
{uniprotXref && domainsLoadingState === LoadingState.SUCCESS && (
<div className={styles.interproUniprotWrapper}>
<ProteinExternalReference
source={ExternalSource.INTERPRO}
......@@ -183,35 +180,37 @@ const ProteinsListItemInfo = (props: Props) => {
/>
</div>
)}
<div className={styles.downloadWrapper}>
<InstantDownloadProtein
genomeId={genomeId}
transcriptId={transcript.unversioned_stable_id}
/>
</div>
{domainsLoadingState === LoadingState.SUCCESS && (
<div className={styles.downloadWrapper}>
<InstantDownloadProtein
genomeId={genomeId}
transcriptId={transcript.unversioned_stable_id}
/>
</div>
)}
</div>
{proteinSummaryStats && uniprotXref && (
<div>
<ProteinExternalReference
source={ExternalSource.PDBE}
accessionId={uniprotXref.accession_id}
name={uniprotXref.name}
/>
{proteinSummaryStats && (
<div className={styles.proteinFeaturesCountWrapper}>
<ProteinFeaturesCount proteinStats={proteinSummaryStats} />
</div>
)}
</div>
)}
{proteinSummaryStats &&
uniprotXref &&
domainsLoadingState === LoadingState.SUCCESS && (
<div>
<ProteinExternalReference
source={ExternalSource.PDBE}
accessionId={uniprotXref.accession_id}
name={uniprotXref.name}
/>
{proteinSummaryStats && (
<div className={styles.proteinFeaturesCountWrapper}>
<ProteinFeaturesCount proteinStats={proteinSummaryStats} />
</div>
)}
</div>
)}
</>
<StatusContent
summaryLoadingState={summaryStatsLoadingState}
domainsLoadingState={domainsLoadingState}
xrefLoadingState={xrefLoadingState}
setSummaryStatsLoadingState={setSummaryStatsLoadingState}
setDomainsLoadingState={setDomainsLoadingState}
setXrefLoadingState={setXrefLoadingState}
/>
<div className={styles.keyline}></div>
......@@ -223,10 +222,8 @@ const ProteinsListItemInfo = (props: Props) => {
type StatusContentProps = {
summaryLoadingState: LoadingState;
domainsLoadingState: LoadingState;
xrefLoadingState: LoadingState;
setSummaryStatsLoadingState: (loadingState: LoadingState) => void;
setDomainsLoadingState: (loadingState: LoadingState) => void;
setXrefLoadingState: (loadingState: LoadingState) => void;
};
const StatusContent = (props: StatusContentProps) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment