`d4tools create` builds empty d4 file for small input files
pamelarussell opened this issue · comments
I'm trying to build small D4 files to test my code, and have not been able to get d4tools create
to successfully build a file from a small bedgraph or bigwig file: the D4 output is always empty. It does work for large public data files. Here is an example with a small bedgraph file.
I'm running version 0.3.4 installed from bioconda.
$ cat example1.bedgraph
track type=bedGraph name="BedGraph Format" description="BedGraph format" visibility=full color=200,100,0 altColor=0,100,200 priority=20
chr1 49302000 49302300 1.0
chr1 49302300 49302600 0.75
chr1 49302600 49302900 0.50
chr1 49302900 49303200 0.25
chr1 49303200 49303500 0.0
chr1 49303500 49303800 0.25
chr1 49303800 49304100 0.50
chr1 49304100 49304400 0.75
chr1 49304400 49304700 1.00
$ cat chrom.sizes
chr1 248956422
chr2 242193529
chr3 198295559
chr4 190214555
chr5 181538259
chr6 170805979
chr7 159345973
chr8 145138636
chr9 138394717
chr10 133797422
chr11 135086622
chr12 133275309
chr13 114364328
chr14 107043718
chr15 101991189
chr16 90338345
chr17 83257441
chr18 80373285
chr19 58617616
chr20 64444167
chr21 46709983
chr22 50818468
chrX 156040895
chrY 57227415
chrM 16569
$ d4tools create -g chrom.sizes example1.bedgraph
$ d4tools view example1.d4
chr1 0 248956422 0
chr2 0 242193529 0
chr3 0 198295559 0
chr4 0 190214555 0
chr5 0 181538259 0
chr6 0 170805979 0
chr7 0 159345973 0
chr8 0 145138636 0
chr9 0 138394717 0
chr10 0 133797422 0
chr11 0 135086622 0
chr12 0 133275309 0
chr13 0 114364328 0
chr14 0 107043718 0
chr15 0 101991189 0
chr16 0 90338345 0
chr17 0 83257441 0
chr18 0 80373285 0
chr19 0 58617616 0
chr20 0 64444167 0
chr21 0 46709983 0
chr22 0 50818468 0
chrX 0 156040895 0
chrY 0 57227415 0
chrM 0 16569 0
Hi @pamelarussell , thanks for reporting the issue.
I tried this locally, it seems you may have a file with space between fields - Please let me know if this is your case.
Thanks!
Thanks! That was the problem. Would it be possible to fail with an informative message for an invalid input file?
Yes, indeed. Also, D4 should support fractional values by default (it supports them but one has to invoke a flag). @38 is working on addressing both of these.
Hi @pamelarussell, just pushed the fix for this bug. Please let me know if there's anything still wrong.
This change will allow d4tools detect if the input needs to be fractional values automatically. Please let me know if this works on your side. Thanks!
Does this work for you, @pamelarussell ?