-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
132 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,78 @@ | ||
//@ts-nocheck | ||
import { LocalFile } from 'generic-filehandle' | ||
import VirtualOffset from '../src/virtualOffset' | ||
import CSI from '../src/csi' | ||
|
||
describe('csi index', () => { | ||
it('loads test.gff3.gz.csi', async () => { | ||
const ti = new CSI({ | ||
filehandle: new LocalFile(require.resolve('./data/test.gff3.gz.csi')), | ||
}) | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(4) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(5) | ||
// console.log( ti ); | ||
let blocks = await ti.blocksForRange('1', 1, 4000) | ||
expect(blocks.length).toEqual(0) | ||
blocks = await ti.blocksForRange('1', 0, 2000046092) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(130) | ||
// console.log( blocks ); | ||
test('loads test.gff3.gz.csi', async () => { | ||
const ti = new CSI({ | ||
filehandle: new LocalFile(require.resolve('./data/test.gff3.gz.csi')), | ||
}) | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(4) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(5) | ||
// console.log( ti ); | ||
let blocks = await ti.blocksForRange('1', 1, 4000) | ||
expect(blocks.length).toEqual(0) | ||
blocks = await ti.blocksForRange('1', 0, 2000046092) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(130) | ||
// console.log( blocks ); | ||
|
||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
columnNumbers: { end: 5, ref: 1, start: 4 }, | ||
csi: true, | ||
csiVersion: 1, | ||
depth: 6, | ||
refCount: 2, | ||
coordinateType: '1-based-closed', | ||
format: 'generic', | ||
firstDataLine: new VirtualOffset(0, 130), | ||
metaChar: '#', | ||
refIdToName: ['1', 'ctgB'], | ||
refNameToId: { 1: 0, ctgB: 1 }, | ||
skipLines: 0, | ||
maxBlockSize: 1 << 16, | ||
maxBinNumber: 299593, | ||
maxRefLength: 4294967296, | ||
}) | ||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
columnNumbers: { end: 5, ref: 1, start: 4 }, | ||
csi: true, | ||
csiVersion: 1, | ||
depth: 6, | ||
refCount: 2, | ||
coordinateType: '1-based-closed', | ||
format: 'generic', | ||
firstDataLine: new VirtualOffset(0, 130), | ||
metaChar: '#', | ||
refIdToName: ['1', 'ctgB'], | ||
refNameToId: { 1: 0, ctgB: 1 }, | ||
skipLines: 0, | ||
maxBlockSize: 1 << 16, | ||
maxBinNumber: 299593, | ||
maxRefLength: 4294967296, | ||
}) | ||
}) | ||
test('loads test.vcf.gz.csi', async () => { | ||
const ti = new CSI({ | ||
filehandle: new LocalFile(require.resolve('./data/test.vcf.gz.csi')), | ||
}) | ||
it('loads test.vcf.gz.csi', async () => { | ||
const ti = new CSI({ | ||
filehandle: new LocalFile(require.resolve('./data/test.vcf.gz.csi')), | ||
}) | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(2) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(0) | ||
// console.log( ti ); | ||
let blocks = await ti.blocksForRange('1', 1, 4000) | ||
expect(blocks.length).toEqual(0) | ||
blocks = await ti.blocksForRange('1', 0, 2000046092) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(2560) | ||
// console.log( blocks ); | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(2) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(0) | ||
// console.log( ti ); | ||
let blocks = await ti.blocksForRange('1', 1, 4000) | ||
expect(blocks.length).toEqual(0) | ||
blocks = await ti.blocksForRange('1', 0, 2000046092) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(2560) | ||
// console.log( blocks ); | ||
|
||
expect(await ti.lineCount('1')).toEqual(37) | ||
expect(await ti.lineCount('1')).toEqual(37) | ||
|
||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
csi: true, | ||
csiVersion: 1, | ||
depth: 6, | ||
refCount: 1, | ||
columnNumbers: { end: 0, ref: 1, start: 2 }, | ||
coordinateType: '1-based-closed', | ||
format: 'VCF', | ||
metaChar: '#', | ||
firstDataLine: new VirtualOffset(0, 2560), | ||
refIdToName: ['1'], | ||
refNameToId: { 1: 0 }, | ||
maxBlockSize: 1 << 16, | ||
skipLines: 0, | ||
maxBinNumber: 299593, | ||
maxRefLength: 4294967296, | ||
}) | ||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
csi: true, | ||
csiVersion: 1, | ||
depth: 6, | ||
refCount: 1, | ||
columnNumbers: { end: 0, ref: 1, start: 2 }, | ||
coordinateType: '1-based-closed', | ||
format: 'VCF', | ||
metaChar: '#', | ||
firstDataLine: new VirtualOffset(0, 2560), | ||
refIdToName: ['1'], | ||
refNameToId: { 1: 0 }, | ||
maxBlockSize: 1 << 16, | ||
skipLines: 0, | ||
maxBinNumber: 299593, | ||
maxRefLength: 4294967296, | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,55 +1,48 @@ | ||
//@ts-nocheck | ||
import { LocalFile } from 'generic-filehandle' | ||
import VirtualOffset from '../src/virtualOffset' | ||
import TabixIndex from '../src/tbi' | ||
import TBI from '../src/tbi' | ||
|
||
describe('tbi index', () => { | ||
it('loads', async () => { | ||
const ti = new TabixIndex({ | ||
filehandle: new LocalFile( | ||
require.resolve('./data/volvox.test.vcf.gz.tbi'), | ||
), | ||
}) | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(2) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(0) | ||
// console.log( ti ); | ||
const blocks = await ti.blocksForRange('contigA', 1, 4000) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(10431) | ||
// console.log( blocks ); | ||
|
||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
columnNumbers: { end: 0, ref: 1, start: 2 }, | ||
coordinateType: '1-based-closed', | ||
format: 'VCF', | ||
metaChar: '#', | ||
maxBinNumber: 37449, | ||
firstDataLine: new VirtualOffset(0, 10431), | ||
refIdToName: ['contigA'], | ||
refNameToId: { contigA: 0 }, | ||
maxBlockSize: 1 << 16, | ||
skipLines: 0, | ||
maxRefLength: 536870912, | ||
}) | ||
console.warn = jest.fn() | ||
expect(await ti.blocksForRange('contigA', 7334998796, 8104229566)).toEqual( | ||
[], | ||
) | ||
expect(console.warn).toHaveBeenCalledWith( | ||
'querying outside of possible tabix range', | ||
) | ||
test('loads', async () => { | ||
const ti = new TBI({ | ||
filehandle: new LocalFile(require.resolve('./data/volvox.test.vcf.gz.tbi')), | ||
}) | ||
it('failing tabix', async () => { | ||
const ti = new TabixIndex({ | ||
filehandle: new LocalFile( | ||
require.resolve('./data/failing_tabix.vcf.gz.tbi'), | ||
), | ||
}) | ||
const indexData = await ti.parse() | ||
expect(indexData.columnNumbers.start).toEqual(2) | ||
expect(indexData.columnNumbers.ref).toEqual(1) | ||
expect(indexData.columnNumbers.end).toEqual(0) | ||
// console.log( ti ); | ||
const blocks = await ti.blocksForRange('contigA', 1, 4000) | ||
expect(blocks.length).toEqual(1) | ||
expect(blocks[0].minv.blockPosition).toEqual(0) | ||
expect(blocks[0].minv.dataPosition).toEqual(10431) | ||
// console.log( blocks ); | ||
|
||
await expect(ti.parse()).rejects.toThrow(/too many bins/) | ||
const metadata = await ti.getMetadata() | ||
expect(metadata).toEqual({ | ||
columnNumbers: { end: 0, ref: 1, start: 2 }, | ||
coordinateType: '1-based-closed', | ||
format: 'VCF', | ||
metaChar: '#', | ||
maxBinNumber: 37449, | ||
firstDataLine: new VirtualOffset(0, 10431), | ||
refIdToName: ['contigA'], | ||
refNameToId: { contigA: 0 }, | ||
maxBlockSize: 1 << 16, | ||
skipLines: 0, | ||
maxRefLength: 536870912, | ||
}) | ||
console.warn = jest.fn() | ||
expect(await ti.blocksForRange('contigA', 7334998796, 8104229566)).toEqual([]) | ||
expect(console.warn).toHaveBeenCalledWith( | ||
'querying outside of possible tabix range', | ||
) | ||
}) | ||
test('failing tabix', async () => { | ||
const ti = new TBI({ | ||
filehandle: new LocalFile( | ||
require.resolve('./data/failing_tabix.vcf.gz.tbi'), | ||
), | ||
}) | ||
|
||
await expect(ti.parse()).rejects.toThrow(/too many bins/) | ||
}) |
This file was deleted.
Oops, something went wrong.