@@ -36,8 +36,8 @@ class RecordCollector {
3636}
3737test ( 'can read contigA:1000..4000' , async ( ) => {
3838 const f = new TabixIndexedFile ( {
39- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
40- tbiPath : require . resolve ( './ data/volvox.test.vcf.gz.tbi') ,
39+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
40+ tbiPath : new URL ( ' data/volvox.test.vcf.gz.tbi', import . meta . url ) . pathname ,
4141 } )
4242 const items = new RecordCollector ( )
4343 await f . getLines ( 'contigA' , 1000 , 4000 , items . callback )
@@ -81,8 +81,8 @@ test('can read contigA:1000..4000', async () => {
8181} )
8282test ( 'can read contigA:10000' , async ( ) => {
8383 const f = new TabixIndexedFile ( {
84- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
85- tbiPath : require . resolve ( './ data/volvox.test.vcf.gz.tbi') ,
84+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
85+ tbiPath : new URL ( ' data/volvox.test.vcf.gz.tbi', import . meta . url ) . pathname ,
8686 } )
8787 const items = new RecordCollector ( )
8888 await f . getLines ( 'contigA' , 10_000 , undefined , items . callback )
@@ -97,8 +97,8 @@ test('can read contigA:10000', async () => {
9797} )
9898test ( 'can read contigA' , async ( ) => {
9999 const f = new TabixIndexedFile ( {
100- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
101- tbiPath : require . resolve ( './ data/volvox.test.vcf.gz.tbi') ,
100+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
101+ tbiPath : new URL ( ' data/volvox.test.vcf.gz.tbi', import . meta . url ) . pathname ,
102102 } )
103103 const items = new RecordCollector ( )
104104 await f . getLines ( 'contigA' , undefined , undefined , items . callback )
@@ -112,32 +112,32 @@ test('can read contigA', async () => {
112112} )
113113test ( 'can count lines with TBI' , async ( ) => {
114114 const f = new TabixIndexedFile ( {
115- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
116- tbiPath : require . resolve ( './ data/volvox.test.vcf.gz.tbi') ,
115+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
116+ tbiPath : new URL ( ' data/volvox.test.vcf.gz.tbi', import . meta . url ) . pathname ,
117117 } )
118118 expect ( await f . lineCount ( 'contigA' ) ) . toEqual ( 109 )
119119 expect ( await f . lineCount ( 'nonexistent' ) ) . toEqual ( - 1 )
120120} )
121121test ( 'can count lines with CSI' , async ( ) => {
122122 const f = new TabixIndexedFile ( {
123- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
124- csiPath : require . resolve ( './ data/volvox.test.vcf.gz.csi') ,
123+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
124+ csiPath : new URL ( ' data/volvox.test.vcf.gz.csi', import . meta . url ) . pathname ,
125125 } )
126126 expect ( await f . lineCount ( 'contigA' ) ) . toEqual ( 109 )
127127 expect ( await f . lineCount ( 'nonexistent' ) ) . toEqual ( - 1 )
128128} )
129129test ( "can't count lines without pseudo-bin" , async ( ) => {
130130 const f = new TabixIndexedFile ( {
131- path : require . resolve ( './ data/volvox.test.vcf.gz') ,
132- tbiPath : require . resolve ( './ data/volvox.test.vcf.gz.tbi.no_pseudo') ,
131+ path : new URL ( ' data/volvox.test.vcf.gz', import . meta . url ) . pathname ,
132+ tbiPath : new URL ( ' data/volvox.test.vcf.gz.tbi.no_pseudo', import . meta . url ) . pathname ,
133133 } )
134134 expect ( await f . lineCount ( 'contigA' ) ) . toEqual ( - 1 )
135135} )
136136
137137test ( 'can query volvox.sort.gff3.gz.1' , async ( ) => {
138138 const f = new TabixIndexedFile ( {
139- path : require . resolve ( './ data/volvox.sort.gff3.gz.1') ,
140- tbiPath : require . resolve ( './ data/volvox.sort.gff3.gz.tbi') ,
139+ path : new URL ( ' data/volvox.sort.gff3.gz.1', import . meta . url ) . pathname ,
140+ tbiPath : new URL ( ' data/volvox.sort.gff3.gz.tbi', import . meta . url ) . pathname ,
141141 } )
142142
143143 const headerString = await f . getHeader ( )
@@ -169,7 +169,7 @@ test('can query volvox.sort.gff3.gz.1', async () => {
169169} )
170170test ( 'can query gvcf.vcf.gz' , async ( ) => {
171171 const f = new TabixIndexedFile ( {
172- path : require . resolve ( './ data/gvcf.vcf.gz') ,
172+ path : new URL ( ' data/gvcf.vcf.gz', import . meta . url ) . pathname ,
173173 } )
174174
175175 const headerString = await f . getHeader ( )
@@ -202,7 +202,7 @@ test('can query gvcf.vcf.gz', async () => {
202202
203203test ( 'can query out.gff.gz with a TBI index' , async ( ) => {
204204 const f = new TabixIndexedFile ( {
205- path : require . resolve ( './ data/out.gff.gz') ,
205+ path : new URL ( ' data/out.gff.gz', import . meta . url ) . pathname ,
206206 } )
207207
208208 const headerString = await f . getHeader ( )
@@ -233,8 +233,8 @@ test('can query out.gff.gz with a TBI index', async () => {
233233
234234test ( 'can query test.vcf.gz with a CSI index' , async ( ) => {
235235 const f = new TabixIndexedFile ( {
236- path : require . resolve ( './ data/test.vcf.gz') ,
237- csiPath : require . resolve ( './ data/test.vcf.gz.csi') ,
236+ path : new URL ( ' data/test.vcf.gz', import . meta . url ) . pathname ,
237+ csiPath : new URL ( ' data/test.vcf.gz.csi', import . meta . url ) . pathname ,
238238 } )
239239
240240 const headerString = await f . getHeader ( )
@@ -280,7 +280,7 @@ test('can query test.vcf.gz with a CSI index', async () => {
280280
281281test ( 'can fetch the entire header for a very large vcf header' , async ( ) => {
282282 const f = new TabixIndexedFile ( {
283- path : require . resolve ( './ data/large_vcf_header.vcf.gz') ,
283+ path : new URL ( ' data/large_vcf_header.vcf.gz', import . meta . url ) . pathname ,
284284 } )
285285
286286 const h = await f . getHeader ( )
@@ -292,7 +292,7 @@ test('can fetch the entire header for a very large vcf header', async () => {
292292
293293test ( 'can fetch a CNV with length defined by END in INFO field' , async ( ) => {
294294 const f = new TabixIndexedFile ( {
295- path : require . resolve ( './ data/CNVtest.vcf.gz') ,
295+ path : new URL ( ' data/CNVtest.vcf.gz', import . meta . url ) . pathname ,
296296 } )
297297
298298 const lines = new RecordCollector ( )
@@ -302,7 +302,7 @@ test('can fetch a CNV with length defined by END in INFO field', async () => {
302302
303303test ( 'can fetch a CNV with length defined by END in INFO field using the opts.lineCallback' , async ( ) => {
304304 const f = new TabixIndexedFile ( {
305- path : require . resolve ( './ data/CNVtest.vcf.gz') ,
305+ path : new URL ( ' data/CNVtest.vcf.gz', import . meta . url ) . pathname ,
306306 } )
307307
308308 const lines = new RecordCollector ( )
@@ -314,7 +314,7 @@ test('can fetch a CNV with length defined by END in INFO field using the opts.li
314314
315315test ( 'returns and empty string for `getHeader()` if there is no header' , async ( ) => {
316316 const f = new TabixIndexedFile ( {
317- path : require . resolve ( './ data/test.bed.gz') ,
317+ path : new URL ( ' data/test.bed.gz', import . meta . url ) . pathname ,
318318 } )
319319
320320 const headerString = await f . getHeader ( )
@@ -323,7 +323,7 @@ test('returns and empty string for `getHeader()` if there is no header', async (
323323
324324test ( 'can fetch NC_000001.11:184099343..184125655 correctly' , async ( ) => {
325325 const f = new TabixIndexedFile ( {
326- path : require . resolve ( './ data/ncbi_human.sorted.gff.gz') ,
326+ path : new URL ( ' data/ncbi_human.sorted.gff.gz', import . meta . url ) . pathname ,
327327 } )
328328
329329 // const headerString = await f.getHeader()
@@ -363,7 +363,7 @@ NC_000001.11 Gnomon exon 184121787 184122540 . + . Parent=lnc_RNA1661;Dbxref=Gen
363363
364364test ( 'usage of the chr22 ultralong nanopore as a bed file' , async ( ) => {
365365 const ti = new TabixIndexedFile ( {
366- path : require . resolve ( './ data/chr22_nanopore_subset.bed.gz') ,
366+ path : new URL ( ' data/chr22_nanopore_subset.bed.gz', import . meta . url ) . pathname ,
367367 } )
368368 await ti . getHeader ( )
369369 const ret1 = new RecordCollector ( )
@@ -381,7 +381,7 @@ test('usage of the chr22 ultralong nanopore as a bed file', async () => {
381381
382382test ( 'too few' , async ( ) => {
383383 const ti = new TabixIndexedFile ( {
384- path : require . resolve ( './ data/too_few_reads_if_chunk_merging_on.bed.gz') ,
384+ path : new URL ( ' data/too_few_reads_if_chunk_merging_on.bed.gz', import . meta . url ) . pathname ,
385385 } )
386386 await ti . getHeader ( )
387387
@@ -392,7 +392,7 @@ test('too few', async () => {
392392
393393test ( 'long read consistent IDs' , async ( ) => {
394394 const ti = new TabixIndexedFile ( {
395- path : require . resolve ( './ data/CHM1_pacbio_clip2.bed.gz') ,
395+ path : new URL ( ' data/CHM1_pacbio_clip2.bed.gz', import . meta . url ) . pathname ,
396396 } )
397397 await ti . getHeader ( )
398398 const ret1 = new RecordCollector ( )
@@ -412,8 +412,8 @@ test('long read consistent IDs', async () => {
412412
413413test ( 'fake large chromosome' , async ( ) => {
414414 const ti = new TabixIndexedFile ( {
415- path : require . resolve ( './ data/fake_large_chromosome/test.gff3.gz') ,
416- csiPath : require . resolve ( './ data/fake_large_chromosome/test.gff3.gz.csi') ,
415+ path : new URL ( ' data/fake_large_chromosome/test.gff3.gz', import . meta . url ) . pathname ,
416+ csiPath : new URL ( ' data/fake_large_chromosome/test.gff3.gz.csi', import . meta . url ) . pathname ,
417417 } )
418418 await ti . getHeader ( )
419419
@@ -425,8 +425,8 @@ test('fake large chromosome', async () => {
425425} )
426426test ( 'start equal to end in tabix columns' , async ( ) => {
427427 const ti = new TabixIndexedFile ( {
428- path : require . resolve ( './ data/out.bed.gz') ,
429- tbiPath : require . resolve ( './ data/out.bed.gz.tbi') ,
428+ path : new URL ( ' data/out.bed.gz', import . meta . url ) . pathname ,
429+ tbiPath : new URL ( ' data/out.bed.gz.tbi', import . meta . url ) . pathname ,
430430 } )
431431 await ti . getHeader ( )
432432
0 commit comments