Skip to content

Commit

Permalink
Don't show highlight/alignment if exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 12, 2024
1 parent 1534717 commit 8856770
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 172 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"pako": "^2.1.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/compat": "^1.1.1",
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
"@jbrowse/core": "^2.0.0",
"@jbrowse/plugin-linear-genome-view": "^2.4.2",
Expand Down
23 changes: 19 additions & 4 deletions src/LaunchProteinView/components/AlphaFoldDBSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const AlphaFoldDBSearch = observer(function ({
feature,
view,
})
const protein = isoformSequences?.[userSelection ?? '']
const userSelectedProteinSequence = isoformSequences?.[userSelection ?? '']
const {
uniprotId,
isLoading: isMyGeneLoading,
Expand Down Expand Up @@ -116,6 +116,20 @@ const AlphaFoldDBSearch = observer(function ({
variant="h6"
message="Looking up UniProt ID from mygene.info"
/>
) : !uniprotId ? (
<div>
UniProt ID not found. Search sequence on AlphaFoldDB{' '}
<a
href={`https://alphafold.ebi.ac.uk/search/sequence/${userSelectedProteinSequence?.seq.replaceAll('*', '')}`}
target="_blank"
rel="noreferrer"
>
here
</a>{' '}
<br />
After visiting the above link, then paste the structure URL into the
Manual tab
</div>
) : null}
{isIsoformProteinSequencesLoading ? (
<LoadingEllipses
Expand Down Expand Up @@ -153,14 +167,15 @@ const AlphaFoldDBSearch = observer(function ({
<Button
variant="contained"
color="primary"
disabled={!uniprotId || !protein || !selectedTranscript}
disabled={
!uniprotId || !userSelectedProteinSequence || !selectedTranscript
}
onClick={() => {
session.addView('ProteinView', {
type: 'ProteinView',
url,
seq2: protein?.seq,
seq2: userSelectedProteinSequence?.seq,
feature: selectedTranscript?.toJSON(),
completeMatch:
connectedViewId: view.id,
displayName: `Protein view ${getGeneDisplayName(feature)} - ${getTranscriptDisplayName(selectedTranscript)}`,
})
Expand Down
2 changes: 1 addition & 1 deletion src/LaunchProteinView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function extendStateModel(stateModel: IAnyModelType) {
...(feature
? [
{
label: 'Launch protein view',
label: 'Launch 3-D protein view',
icon: AddIcon,
onClick: () => {
getSession(track).queueDialog(handleClose => [
Expand Down
12 changes: 7 additions & 5 deletions src/ProteinView/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const ProteinViewHeader = observer(function ({
return (
<div>
<InformativeHeaderArea model={model} />
{showAlignment && alignment ? (
<ProteinAlignment model={model} />
) : (
<LoadingEllipses message="Loading pairwise alignment" />
)}
{showAlignment ? (
alignment ? (
<ProteinAlignment model={model} />
) : (
<LoadingEllipses message="Loading pairwise alignment" />
)
) : null}
</div>
)
})
Expand Down
20 changes: 15 additions & 5 deletions src/ProteinView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ function stateModelFactory() {
/**
* #property
*/
showHighlight: true,
showHighlight: false,
/**
* #property
*/
zoomToBaseLevel: false,
zoomToBaseLevel: true,
/**
* #property
*/
showAlignment: true,
showAlignment: false,
}),
)
.volatile(() => ({
Expand Down Expand Up @@ -317,6 +317,12 @@ function stateModelFactory() {
get structureSeqHoverPos(): number | undefined {
return self.hoverPosition?.structureSeqPos
},

get exactMatch() {
const r1 = self.seq1?.replaceAll('*', '')
const r2 = self.seq2?.replaceAll('*', '')
return r1 === r2
},
}))
.actions(self => ({
afterAttach() {
Expand All @@ -325,20 +331,24 @@ function stateModelFactory() {
self,
autorun(async () => {
try {
const { seq1, seq2 } = self
const { seq1, seq2, exactMatch } = self
if (!!self.alignment || !seq1 || !seq2) {
return
}
const r1 = seq1.replaceAll('*', '')
const r2 = seq2.replaceAll('*', '')
if (r1 !== r2) {
if (!exactMatch) {
const alignment = await launchPairwiseAlignment({
seq1: r1,
seq2: r2,
algorithm: 'emboss_needle',
onProgress: arg => self.setProgress(arg),
})
self.setAlignment(alignment.alignment)

// showHighlight when we are
self.setShowHighlight(true)
self.setShowAlignment(true)
} else {
let consensus = ''
// eslint-disable-next-line @typescript-eslint/prefer-for-of
Expand Down
Loading

0 comments on commit 8856770

Please sign in to comment.