Concatenate All Vcf.Gz Files
2
2
Entering edit mode
10.9 years ago
win ▴ 990

hi all. i am a bit new to linux environment and i wanted to how the following command could be modified to concatenate all VCF files from a directory.

vcf-concat A.vcf.gz B.vcf.gz C.vcf.gz | gzip -c > out.vcf.gz

instead of A.vcf.gz, B.vcf.gz I would like all vcf.gz from my directory concatenated knowing they are all from the same source.

thanks in advance.

vcf • 14k views
ADD COMMENT
4
Entering edit mode
10.9 years ago
Andreas ★ 2.5k

Well, the command you gave is 90% of the answer you're looking for. To match several files, you can use shell wildcards (also called globs) like * which the shell expands to match many files. For example to convert all files ending in vcf.gz in a directory called myvcfs you can just use:

vcf-concat myvcfs/*.vcf.gz | gzip > out.vcf.gz

The -c for gzip in your original command is not strictly necessary because it's the default anyway. If you're paranoid you might want to add -s to vcf-concat which does some checks for you (assumes that your files are tabix indexed).

Andreas

ADD COMMENT
2
Entering edit mode
10.9 years ago
vcf-concat *.vcf.gz | gzip -c > out.vcf.gz

Simple as that. The bash expansion will convert that to a list of all vcfs

ADD COMMENT

Login before adding your answer.

Traffic: 1966 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6