-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go cam viz #823
Open
dlrice
wants to merge
84
commits into
main
Choose a base branch
from
go-cam-viz
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Go cam viz #823
Changes from 52 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
2798405
Add @geneontology/wc-gocam-viz/loader package.
dlrice 33db87f
Add wc-gocam-viz module types.
dlrice 46e30a4
Create GoCamViz wrapper around wc.
dlrice 2718779
Add GoCam component.
dlrice e01ac22
Add GoCap to function section.
dlrice 6313446
Add go-cam-viz.module.scss
dlrice 4de38ea
Add NoctuaAlliancePathwayPreview url.
dlrice f0db1ff
Style tweak.
dlrice adeda43
Snapshot update.
dlrice 6d8da70
Merge remote-tracking branch 'origin/main' into go-cam-viz
dlrice e8cdfb0
Add gocam url; fetch model ids.
dlrice 3c88995
Provide go-cam id selection; styling.
dlrice eaa0274
Use TreeSelect for go-cam model selection.
dlrice 75324bb
Update Complex Viewer to use TreeSelect rather than drodown.
dlrice 7ea79da
Remove now unused util fn.
dlrice 0e3d5aa
Update tests.
dlrice 287747f
Use native select for go-cam model selection; style tweaks.
dlrice b2cc0f1
Use native select for complex selection; style tweaks.
dlrice db86794
Try to sort out lazy loading of go-cam.
dlrice 91a1b83
Tidy up InteractionSection.
dlrice 5bf40e1
Remove duplicate import.
dlrice 7bf298a
Try to sort out lazy loading of go-cam again.
dlrice b609e77
Use tabs for go ribbon and go cam.
dlrice 23886bc
Import order fix.
dlrice 3b576dc
Upgrade @geneontology/wc-gocam-viz to latest version.
dlrice 54ec131
Add preamble to GO tabs.
dlrice 2590dd1
Add New chip to GO-CAM tab title.
dlrice c27ceb6
Snapshot update.
dlrice b4b5b6f
Update tab title.
dlrice ca6dfd5
Only show go-cam models which are uniprotkb curated.
dlrice c4995cb
Report loading and no go-cam models to user.
dlrice ebd096f
Update go-cam tab title.
dlrice fb54b25
Snapshot update.
dlrice baed1b5
Don't cache GO tabs.
dlrice 20241e8
Only fetch go cam model info if goCamIdToItem has items.
dlrice fa23c31
Merge remote-tracking branch 'origin/main' into go-cam-viz
dlrice af2c607
Add help doc links; twerk loading logic.
dlrice b9331bc
Merge remote-tracking branch 'origin/main' into go-cam-viz
dlrice 6124c87
Adjust coverage.
dlrice e2f2be9
Tweak go-cam loading logic.
dlrice 377d539
Hide both GO tabs if no GO ids.
dlrice 996f706
Update InteractionSection tests.
dlrice 11573f6
Update comment.
dlrice 38431f5
Test getGoCamStructures.
dlrice 4a6947b
Test isUniprotCurated.
dlrice e87bbe8
Lower coverage threshold.
dlrice 50aff0c
Remove old go help article link.
dlrice 826faac
Merge remote-tracking branch 'origin/main' into go-cam-viz
dlrice 21d3f98
Update wc-gocam-viz to 1.1.1-beta.3
dlrice fcb9882
Merge remote-tracking branch 'origin/main' into go-cam-viz
dlrice 4d793ec
Upgrade @geneontology/wc-gocam-viz to 1.1.1
dlrice a46fefd
Adapt GO-CAM model fetching to use p-map.
dlrice e6c5040
Tweak go-cam-viz styles.
dlrice 7d3aa62
Adapt Tabs.
dlrice ee232bc
Don't try to goto history tab if already there.
dlrice 53ef4c3
Update tabs in the BasketMiniView.
dlrice a4b2a83
Add bordered option to GO tabs and SimilarProteins.
dlrice 7bfe931
Add bordered optoin to SubEntrySimilarProteins, Subcell Location, Sta…
dlrice d673e04
Remove unused imports.
dlrice 56433c1
Conditionally disable GO-CAMs based on reviewed/unreviewed entry type.
dlrice 22379d9
Hide process-label.
dlrice 251ece5
Show relevant viz node as chip above go-cam viz.
dlrice 937891c
Add netlify.toml.
dlrice 2b60aa6
Gitignore local Netlify folder.
dlrice e779878
Remove unneeded colours import.
dlrice 085243c
Use Custom Properties throughout go-cam-viz styles.
dlrice 7a88eb5
Adapt tests to use real mock data.
dlrice df00c5b
Use useSafeState in when loading wc-gocam-viz.
dlrice 1f3016a
useSafeState for gocam to node map.
dlrice 0cd1be0
Cancel all of the gocam reqeusts if users navigates away.
dlrice bc0dccf
Exclude the organism eg Hsap.
dlrice 3ac9be0
Add missing hook dep.
dlrice fc16089
Update snapshots.
dlrice 3ec1003
Rename build:ux-netlify to build:netlify
dlrice ce2aba2
Add deploy:netlify script.
dlrice 0d1021c
Wording tweak.
dlrice 3f91eb0
Try to adjust styles for more consistent link indication.
dlrice 995960f
More style tweaks.
dlrice aa0607e
Make go-cam-viz layout tighter.
dlrice 6ec710f
More white space tweakings.
dlrice 1f0267e
Bold text in the go-cam panel. Tweak colors.
dlrice df57d28
Add activity-color-link-hover and tweak button-background-hover color…
dlrice 10f36c7
Case tweak.
dlrice 2eac5c6
Table and GO tabs spacing tweaks.
dlrice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
declare module '@geneontology/wc-gocam-viz'; | ||
|
||
declare namespace JSX { | ||
interface IntrinsicElements { | ||
'wc-gocam-viz': any; | ||
} | ||
} |
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,162 @@ | ||
import { ReactNode, useEffect, useMemo, useState } from 'react'; | ||
import { ExternalLink, Loader } from 'franklin-sites'; | ||
import pMap from 'p-map'; | ||
|
||
import ErrorHandler from '../../../shared/components/error-pages/ErrorHandler'; | ||
import GoCamViz from '../protein-data-views/GoCamViz'; | ||
|
||
import { useSmallScreen } from '../../../shared/hooks/useMatchMedia'; | ||
import useDataApi from '../../../shared/hooks/useDataApi'; | ||
|
||
import fetchData from '../../../shared/utils/fetchData'; | ||
import { heuristic } from '../../../tools/state/utils/heuristic'; | ||
|
||
import externalUrls from '../../../shared/config/externalUrls'; | ||
|
||
import { GoCamModelInfo, GoCamModels } from '../../types/goCamTypes'; | ||
|
||
import styles from './styles/go-cam.module.scss'; | ||
|
||
const extractGoCamId = (url: string) => { | ||
const reGoCamId = /https?:\/\/model\.geneontology\.org\/(?<goCamId>.*)/; | ||
const m = url.match(reGoCamId); | ||
return m?.groups?.goCamId; | ||
}; | ||
|
||
export const getGoCamStructures = (data: GoCamModels[] = []) => { | ||
const idToItem = new Map<string, { id: string; label: string }>(); | ||
for (const d of data) { | ||
const id = extractGoCamId(d.gocam); | ||
if (id) { | ||
idToItem.set(id, { | ||
id, | ||
label: d.title, | ||
}); | ||
} | ||
} | ||
return idToItem; | ||
}; | ||
|
||
export const isUniprotCurated = (goCamModel: GoCamModelInfo) => | ||
goCamModel?.annotations?.some( | ||
({ key, value }) => | ||
key === 'providedBy' && value === 'https://www.uniprot.org' | ||
); | ||
|
||
type Props = { | ||
primaryAccession: string; | ||
}; | ||
|
||
const GoCam = ({ primaryAccession }: Props) => { | ||
const isSmallScreen = useSmallScreen(); | ||
const [selectedId, setSelectedId] = useState<string | null>(null); | ||
const allGoCamIdsResponse = useDataApi<GoCamModels[]>( | ||
isSmallScreen ? null : externalUrls.GeneOntologyModels(primaryAccession) | ||
); | ||
const [uniprotGoCamIds, setUniprotGoCamIds] = useState<string[] | null>(null); | ||
|
||
const goCamIdToItem = useMemo( | ||
() => getGoCamStructures(allGoCamIdsResponse.data), | ||
[allGoCamIdsResponse.data] | ||
); | ||
|
||
useEffect(() => { | ||
async function fetchGoCamModels() { | ||
if (goCamIdToItem.size) { | ||
const mapper = (id: string) => | ||
fetchData<GoCamModelInfo>( | ||
externalUrls.GeneOntologyModelInfo(id) | ||
).then((response) => ({ | ||
id, | ||
data: response.data, | ||
})); | ||
const results = await pMap(Array.from(goCamIdToItem.keys()), mapper, { | ||
concurrency: heuristic.concurrency, | ||
}); | ||
setUniprotGoCamIds( | ||
results | ||
.filter(({ data }) => isUniprotCurated(data)) | ||
.map(({ id }) => id) | ||
); | ||
} | ||
} | ||
fetchGoCamModels(); | ||
}, [goCamIdToItem]); | ||
|
||
useEffect(() => { | ||
if (uniprotGoCamIds?.[0]) { | ||
setSelectedId(uniprotGoCamIds[0]); | ||
} | ||
}, [uniprotGoCamIds]); | ||
aurel-l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let content: ReactNode; | ||
const loadingUniprotGoCamIds = goCamIdToItem.size && uniprotGoCamIds === null; | ||
if (allGoCamIdsResponse.loading || loadingUniprotGoCamIds) { | ||
content = ( | ||
<> | ||
<div className={styles.preamble} data-article-id="gene-ontology"> | ||
Searching Gene Ontology knowledgebase for GO-CAM models. | ||
</div> | ||
<Loader /> | ||
</> | ||
); | ||
} else if ( | ||
!goCamIdToItem.size || | ||
(Array.isArray(uniprotGoCamIds) && !uniprotGoCamIds.length) | ||
) { | ||
content = ( | ||
<> | ||
<div className={styles.preamble} data-article-id="gene-ontology"> | ||
UniProt curated GO-CAM models have not been found for this entry | ||
within the Gene Ontology knowledgebase. | ||
</div> | ||
<ExternalLink url={externalUrls.GeneOntologyUniprotCuratedModels}> | ||
Browse all available UniProt curated GO-CAM models. | ||
</ExternalLink> | ||
</> | ||
); | ||
} else if (allGoCamIdsResponse.error) { | ||
content = ( | ||
<ErrorHandler | ||
status={allGoCamIdsResponse.status} | ||
error={allGoCamIdsResponse.error} | ||
noReload | ||
/> | ||
); | ||
} else if (!isSmallScreen && selectedId && !!uniprotGoCamIds?.length) { | ||
content = ( | ||
<> | ||
<div className={styles.preamble} data-article-id="gene-ontology"> | ||
Gene Ontology Causal Activity Models (GO-CAM) associated with this | ||
entry. | ||
</div> | ||
<label> | ||
Select GO-CAM model | ||
<select | ||
value={selectedId} | ||
onChange={(e) => setSelectedId(e.target.value)} | ||
className={styles['id-select']} | ||
> | ||
{uniprotGoCamIds.map((id) => ( | ||
<option value={id} key={id}> | ||
{goCamIdToItem.get(id)?.label} | ||
</option> | ||
))} | ||
</select> | ||
</label> | ||
<GoCamViz id={selectedId} /> | ||
<ExternalLink | ||
url={externalUrls.NoctuaAlliancePathwayPreview(selectedId)} | ||
> | ||
View in Noctua Alliance Pathway Preview | ||
</ExternalLink> | ||
</> | ||
); | ||
} | ||
|
||
return content ? ( | ||
<div className={styles['go-cam-container']}>{content}</div> | ||
) : null; | ||
}; | ||
|
||
export default GoCam; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in
GoCamViz.tsx
regarding state setting in async logic. useuseSafeState
.Also use one single AbortController both for each fetch and for p-map (look for
signal
in the documentation https://www.npmjs.com/package/p-map ). Look in the codebase forcontroller.abort()
to see example usage.This will also to stop current and subsequent fetches if the user changes page or switch the tab back