Skip to content

Commit

Permalink
All ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 12, 2023
1 parent 78a51d5 commit 8db6cac
Show file tree
Hide file tree
Showing 19 changed files with 349 additions and 450 deletions.
7 changes: 2 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/** @type {import("ts-jest/dist/types").InitialOptionsTsJest} */
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
transform: {
'^.+\\.(ts|js)x?$': 'ts-jest',
},
testEnvironment: 'node',
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!quick-lru/).+\\.js$'],
testTimeout: 1000,
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
"@babel/preset-typescript": "^7.17.12",
"@gmod/indexedfasta": "^2.0.2",
"@gmod/indexedfasta": "^2.1.0",
"@types/buffer-crc32": "^0.2.2",
"@types/jest": "^29.2.4",
"@types/long": "^4.0.2",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/rans/d04.js → src/rans/d04.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { CramMalformedError } from '../errors'

import { TF_SHIFT } from './constants'
Expand Down
1 change: 1 addition & 0 deletions src/rans/d14.js → src/rans/d14.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { TF_SHIFT } from './constants'
import Decoding from './decoding'

Expand Down
1 change: 1 addition & 0 deletions src/rans/decoding.js → src/rans/decoding.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { CramMalformedError } from '../errors'

import { RANS_BYTE_L } from './constants'
Expand Down
1 change: 1 addition & 0 deletions src/rans/frequencies.js → src/rans/frequencies.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { CramMalformedError } from '../errors'

import { TOTFREQ } from './constants'
Expand Down
1 change: 1 addition & 0 deletions src/rans/index.js → src/rans/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { CramMalformedError } from '../errors'

import Decoding from './decoding'
Expand Down
23 changes: 23 additions & 0 deletions test/__snapshots__/compressions.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`bzip2 1`] = `
{
"code": "X",
"data": 1,
"pos": 51,
"ref": "A",
"refPos": 1050,
"sub": "G",
}
`;

exports[`lzma 1`] = `
{
"code": "X",
"data": 1,
"pos": 51,
"ref": "A",
"refPos": 1050,
"sub": "G",
}
`;
31 changes: 31 additions & 0 deletions test/compressions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//@ts-nocheck
import { testDataFile } from './lib/util'
import { dumpWholeFile } from './lib/dumpFile'
import { CramFile } from '../src/index'
import { FetchableSmallFasta } from './lib/fasta'

test('lzma', async () => {
const fasta = new FetchableSmallFasta(testDataFile('hts-specs/ce.fa'))
const seqFetch = fasta.fetch.bind(fasta)
const file = new CramFile({
filehandle: testDataFile('hts-specs/0903_comp_lzma.cram'),
seqFetch,
})
const fileData = await dumpWholeFile(file)
const feat = fileData[2].data[1].features[0]
const hardClip = feat.readFeatures[0]
expect(hardClip).toMatchSnapshot()
})

test('bzip2', async () => {
const fasta = new FetchableSmallFasta(testDataFile('hts-specs/ce.fa'))
const seqFetch = fasta.fetch.bind(fasta)
const file = new CramFile({
filehandle: testDataFile('hts-specs/0902_comp_bz2.cram'),
seqFetch,
})
const fileData = await dumpWholeFile(file)
const feat = fileData[2].data[1].features[0]
const hardClip = feat.readFeatures[0]
expect(hardClip).toMatchSnapshot()
})
36 changes: 0 additions & 36 deletions test/dump.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,6 @@ test('works with hard clipping', async () => {
expect(hardClip.data).toEqual(803)
})

test('lzma', async () => {
const fasta = new FetchableSmallFasta(testDataFile('hts-specs/ce.fa'))
const seqFetch = fasta.fetch.bind(fasta)
const file = new CramFile({
filehandle: testDataFile('hts-specs/0903_comp_lzma.cram'),
seqFetch,
})
const fileData = await dumpWholeFile(file)
const feat = fileData[2].data[1].features[0]
const hardClip = feat.readFeatures[0]
const nextReadFeature = feat.readFeatures[0]
expect(hardClip.refPos).toEqual(1050)
expect(nextReadFeature.refPos).toEqual(1050)
expect(hardClip.refPos).toEqual(1050)
expect(hardClip.pos).toEqual(51)
expect(hardClip.data).toEqual(1)
})

test('bzip2', async () => {
const fasta = new FetchableSmallFasta(testDataFile('hts-specs/ce.fa'))
const seqFetch = fasta.fetch.bind(fasta)
const file = new CramFile({
filehandle: testDataFile('hts-specs/0902_comp_bz2.cram'),
seqFetch,
})
const fileData = await dumpWholeFile(file)
const feat = fileData[2].data[1].features[0]
const hardClip = feat.readFeatures[0]
const nextReadFeature = feat.readFeatures[0]
expect(hardClip.refPos).toEqual(737)
expect(nextReadFeature.refPos).toEqual(737)
expect(hardClip.refPos).toEqual(feat.alignmentStart)
expect(hardClip.pos).toEqual(1)
expect(hardClip.data).toEqual(803)
})

function isIterable(input) {
if (input === null || input === undefined) {
return false
Expand Down
1 change: 1 addition & 0 deletions test/lib/dumpFile.js → test/lib/dumpFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
async function dumpSlice(container, sliceOffset) {
const slice = container.getSlice(sliceOffset)
const header = await slice.getHeader()
Expand Down
7 changes: 3 additions & 4 deletions test/lib/fasta/index.js → test/lib/fasta/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import IndexedFasta from './indexedFasta'

function parseSmallFasta(text) {
//@ts-nocheck
function parseSmallFasta(text: string) {
return text
.split('>')
.filter(t => /\S/.test(t))
Expand Down Expand Up @@ -38,4 +37,4 @@ class FetchableSmallFasta {
}
}

export { parseSmallFasta, FetchableSmallFasta, IndexedFasta }
export { parseSmallFasta, FetchableSmallFasta }
120 changes: 0 additions & 120 deletions test/lib/fasta/indexedFasta.js

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions test/lib/syncLocalFile.js → test/lib/syncLocalFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
// don't load fs native module if running in webpacked code
const fs = typeof __webpack_require__ !== 'function' ? require('fs') : null // eslint-disable-line camelcase

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions test/lib/util.js → test/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
const path = typeof __webpack_require__ !== 'function' ? require('path') : null // eslint-disable-line camelcase
const fs = typeof __webpack_require__ !== 'function' ? require('fs') : null // eslint-disable-line camelcase
import { fromUrl } from '../../src/io'
Expand Down
Loading

0 comments on commit 8db6cac

Please sign in to comment.