This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error in converting vcf to bed file using bedops

Hello,

I am using bedops to convert a vcf file to a bed file:

vcf2bed < in.vcf.gz > out.bed

But I get this error:

BED row length exceeds capacity at line 47483 in -.
Check that you have unix newlines (cat -A) or increase TOKENS_MAX_LENGTH in BEDOPS.Constants.hpp and recompile BEDOPS.

Thank you for any help!

bedops vcf bed

1 answer

You may need to decompress the gzipped VCF file to text, before conversion.

If you use the bash shell, you can use a process substitution:

$ vcf2bed < <( gunzip -c in.vcf.gz ) > out.bed

Or you can pipe uncompressed data, using the hyphen with vcf2bed to specify standard input:

$ gunzip -c in.vcf.gz | vcf2bed - > out.bed

Another possibility is that your VCF file contains genuinely very long lines, in which case, you'd need to run a version of BEDOPS that supports longer lines.

If this is your case, if you're using the binaries I distribute on our Github site, you should be able to run the following:

$ switch-BEDOPS-binary-type --megarow

This transparently swaps the binaries around so that your host runs a "megarow" build of these tools, which supports longer lines, at the cost of slightly longer runtime for set operations.

If you're using someone else's build (e.g., via Homebrew or a package manager I don't control) then my advice would be to compile the binaries you need.

Instructions for compilation are located at:

https://bedops.readthedocs.io/en/latest/content/installation.html#installation-via-source-code

As the instructions note, you'd run make megarow or make all to build the set of binaries of the "megarow" variety. Grab some coffee as it may take a few minutes. Install the binaries where you need them, then run the command as described above.

Log in to answer this question.