Skip to content

Commit

Permalink
Lint unicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 14, 2024
1 parent 8c840e8 commit 8e27a19
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 39 deletions.
15 changes: 14 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default [
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:unicorn/recommended',
),
),
{
Expand All @@ -50,6 +51,13 @@ export default [
},

rules: {
'unicorn/prevent-abbreviations': 'off',
'unicorn/no-null': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/catch-error-name': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/better-regex': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
Expand All @@ -59,7 +67,12 @@ export default [
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/require-await': 'off',

'no-console': [
'warn',
{
allow: ['error', 'warn'],
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"eslint-plugin-prettier": "^5.1.0",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^54.0.0",
"mobx": "^6.10.2",
"mobx-react": "^9.0.1",
"mobx-state-tree": "^5.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ const NcbiBlastPanel = observer(function NcbiBlastPanel2({
maxRows={10}
fullWidth
value={
!proteinSequence
? 'Loading...'
: `>${getTranscriptDisplayName(selectedTranscript)}\n${proteinSequence}`
proteinSequence
? `>${getTranscriptDisplayName(selectedTranscript)}\n${proteinSequence}`
: 'Loading...'
}
InputProps={{
readOnly: true,
Expand Down
3 changes: 1 addition & 2 deletions src/LaunchMsaView/components/NewNCBIBlastQuery/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import NcbiBlastPanel from './NcbiBlastPanel'
export default NcbiBlastPanel
export { default } from './NcbiBlastPanel'
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getTranscriptDisplayName,
getId,
getTranscriptFeatures,
getGeneDisplayName,
} from '../../util'
import { fetchGeneList } from './fetchGeneList'
import { preCalculatedLaunchView } from './preCalculatedLaunchView'
Expand Down Expand Up @@ -120,7 +121,7 @@ const PreLoadedMSA = observer(function PreLoadedMSA2({
await preCalculatedLaunchView({
userSelection,
session,
newViewTitle: '',
newViewTitle: getGeneDisplayName(ret),
view,
feature: ret,
})
Expand Down
23 changes: 11 additions & 12 deletions src/MsaViewPanel/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Instance, addDisposer, cast, types } from 'mobx-state-tree'
import { autorun } from 'mobx'
import { MSAModelF } from 'react-msaview'
import { Feature, getSession, notEmpty } from '@jbrowse/core/util'
import { Feature, getSession } from '@jbrowse/core/util'
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes'

Expand Down Expand Up @@ -101,7 +101,6 @@ export default function stateModelFactory() {
* #getter
*/
get transcriptToMsaMap() {
console.log(self.connectedFeature)
return self.connectedFeature
? genomeToTranscriptSeqMapping(self.connectedFeature)
: undefined
Expand Down Expand Up @@ -250,14 +249,14 @@ export default function stateModelFactory() {
autorun(() => {
const { mouseCol, mouseClickCol } = self
const r1 =
mouseCol !== undefined
? msaCoordToGenomeCoord({ model: self, coord: mouseCol })
: undefined
mouseCol === undefined
? undefined
: msaCoordToGenomeCoord({ model: self, coord: mouseCol })
const r2 =
mouseClickCol !== undefined
? msaCoordToGenomeCoord({ model: self, coord: mouseClickCol })
: undefined
self.setConnectedHighlights([r1, r2].filter(notEmpty))
mouseClickCol === undefined
? undefined
: msaCoordToGenomeCoord({ model: self, coord: mouseClickCol })
self.setConnectedHighlights([r1, r2].filter(f => !!f))
}),
)

Expand All @@ -268,9 +267,9 @@ export default function stateModelFactory() {
const { connectedView, zoomToBaseLevel, mouseClickCol } = self
const { assemblyManager } = getSession(self)
const r2 =
mouseClickCol !== undefined
? msaCoordToGenomeCoord({ model: self, coord: mouseClickCol })
: undefined
mouseClickCol === undefined
? undefined
: msaCoordToGenomeCoord({ model: self, coord: mouseClickCol })

if (!r2 || !connectedView) {
return
Expand Down
26 changes: 16 additions & 10 deletions src/utils/msa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,21 @@ export async function launchMSA({
onProgress: (arg: string) => void
}) {
onProgress(`Launching ${algorithm} MSA...`)
if (algorithm === 'clustalo') {
return runClustalOmega({ sequence, onProgress })
} else if (algorithm === 'muscle') {
return runMuscle({ sequence, onProgress })
} else if (algorithm === 'kalign') {
return runKalign({ sequence, onProgress })
} else if (algorithm === 'mafft') {
return runMafft({ sequence, onProgress })
} else {
throw new Error('unknown algorithm')
switch (algorithm) {
case 'clustalo': {
return runClustalOmega({ sequence, onProgress })
}
case 'muscle': {
return runMuscle({ sequence, onProgress })
}
case 'kalign': {
return runKalign({ sequence, onProgress })
}
case 'mafft': {
return runMafft({ sequence, onProgress })
}
default: {
throw new Error('unknown algorithm')
}
}
}
8 changes: 4 additions & 4 deletions src/utils/ncbiBlast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ async function waitForRid({
const res = await textfetch(
`${BLAST_URL}?CMD=Get&FORMAT_OBJECT=SearchInfo&RID=${rid}`,
)
if (res.match(/\s+Status=WAITING/m)) {
if (/\s+Status=WAITING/m.test(res)) {
continue
} else if (res.match(/\s+Status=FAILED/m)) {
} else if (/\s+Status=FAILED/m.test(res)) {
throw new Error(
`BLAST ${rid} failed; please report to [email protected]`,
)
} else if (res.match(/\s+Status=READY/m)) {
if (res.match(/\s+ThereAreHits=yes/m)) {
} else if (/\s+Status=READY/m.test(res)) {
if (/\s+ThereAreHits=yes/m.test(res)) {
return true
} else {
throw new Error('No hits found')
Expand Down
Loading

0 comments on commit 8e27a19

Please sign in to comment.