Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest';
import React, { act } from 'react';
import { act } from 'react';
import { createRoot } from 'react-dom/client';
import Page from './index';

Expand Down
2 changes: 1 addition & 1 deletion src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const App = (): React.JSX.Element => {
>
<Tabs
value={store.activeIndex}
onChange={( event, value ) => store.setActive( value )}
onChange={( _event, value ) => store.setActive( value )}
>
{TabItems}
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/ErrorDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, vi } from 'vitest';
import React, { act } from 'react';
import { act } from 'react';
import { createRoot } from 'react-dom/client';
import type { RendererBridge } from '../../common/rendererBridge';
import type RunList from '../store/RunList';
Expand Down
1 change: 0 additions & 1 deletion src/app/components/OptionCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
import type { SxProps, Theme } from '@mui/material/styles';
import FormControlLabel from '@mui/material/FormControlLabel';
Expand Down
1 change: 0 additions & 1 deletion src/app/components/OptionSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
import type { SxProps, Theme } from '@mui/material/styles';
import FormControl from '@mui/material/FormControl';
Expand Down
1 change: 0 additions & 1 deletion src/app/components/OptionTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { observer } from 'mobx-react-lite';
import type { SxProps, Theme } from '@mui/material/styles';
import TextField from '@mui/material/TextField';
Expand Down
2 changes: 1 addition & 1 deletion src/app/droppedFile.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, vi } from 'vitest';
import React, { act } from 'react';
import { act } from 'react';
import { createRoot } from 'react-dom/client';
import { ThemeProvider } from '@mui/material/styles';
import theme from './theme';
Expand Down
5 changes: 1 addition & 4 deletions src/app/store/FinalAlignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ class FinalAlignment {
const setMethod = this.fillTaxonGapsWithEmptySeqeunces
? union
: intersection;
return setMethod.apply(
setMethod,
this.run.alignments.map( ( { taxons } ) => taxons ),
);
return setMethod( ...this.run.alignments.map( ( { taxons } ) => taxons ) );
}

get numSequences(): number {
Expand Down
2 changes: 1 addition & 1 deletion src/app/unhandledError.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest';
import React, { act } from 'react';
import { act } from 'react';
import { createRoot } from 'react-dom/client';
import Page from './index';
import store from './store';
Expand Down
17 changes: 17 additions & 0 deletions src/common/io.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
// @vitest-environment node
import fs from 'fs';
import os from 'os';
import path from 'path';
import { expect, it } from 'vitest';
import io from './io';

it( 'writeAlignment writes every sequence as FASTA', async () => {
const dir = fs.mkdtempSync( path.join( os.tmpdir(), 'io-test-' ) );
try {
const filePath = path.join( dir, 'out.fas' );
await io.writeAlignment( filePath, {
sequences: [{ taxon: 'a', code: 'ACGT' }, { taxon: 'b', code: 'TTGA' }],
length: 4,
} );
expect( fs.readFileSync( filePath, 'utf8' ) ).toBe( '>a\nACGT\n>b\nTTGA' );
} finally {
fs.rmSync( dir, { recursive: true, force: true } );
}
} );

it( 'parseAlignment rejects a missing file with a user-fix error naming the file', async () => {
await expect( io.parseAlignment( 'Tt-5.fas' ) ).rejects.toMatchObject( {
isUserFix: true,
Expand Down
12 changes: 7 additions & 5 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,19 @@ export const writeAlignment = async ( filePath: string, alignment: Alignment ):
console.log( `Write alignment in FASTA format to ${filePath}` );
console.log( alignment );
const writeStream = fs.createWriteStream( filePath );
const write = util.promisify( writeStream.write );
const end = util.promisify( writeStream.end );
const write = util.promisify(
( chunk: string, cb: ( err?: Error | null ) => void ) => writeStream.write( chunk, cb ),
);
const end = util.promisify( ( cb: () => void ) => writeStream.end( cb ) );
for ( let i = 0; i < alignment.sequences.length; ++i ) {
const prefix = i === 0
? '>'
: '\n>';
const sequence = alignment.sequences[i];
await write.call( writeStream, `${prefix}${sequence.taxon}\n` );
await write.call( writeStream, sequence.code );
await write( `${prefix}${sequence.taxon}\n` );
await write( sequence.code );
}
await end.call( writeStream );
await end();
};

interface Io {
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { createRoot } from 'react-dom/client';

import App from './app/';
Expand Down
2 changes: 1 addition & 1 deletion src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async function readalGetFormat( alignmentPath: string ): Promise<string | undefi
return f;
}
}
return;
return undefined;
}
// Function to convert an alignment to fasta with readal
async function convertAlignment( alignmentPath: string ): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/cancelRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ it( 'cancelRun stops that run and sends no terminal event', async () => {
} );

it( 'a late exit from a cancelled run leaves the next run tracked', () => {
const oldProc = { kill() { this.killed = true; } };
const oldProc: { killed?: boolean; kill(): void } = { kill() { this.killed = true; } };
const nextProc: { killed?: boolean; kill(): void } = { kill() { this.killed = true; } };
const token = beginRun( 8 );
trackRun( 8, oldProc );
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"allowSyntheticDefaultImports": true,
"strict": false,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictBindCallApply": true,
"skipLibCheck": true
},
"include": ["src", "e2e/helpers/**/*.test.ts"]
Expand Down
Loading