-3
$\begingroup$

I have a zipped vcf file of dbSNP hg38 version

No space left on my device to unzip that

I want to extract a column from that

I have tried this

cut -f 3 00-All.vcf.gz | sed 's/[\t]/,/g' > cols.csv

But that needs my vcf to be unzipped

Do you know any solution please?

$\endgroup$

1 Answer 1

3
$\begingroup$

Either the zcat command or gunzip -c will decompress the file in a streaming fashion to the standard output without writing the decompressed data to disk. Pipe the output to cut, sed, etc.

Try

zcat 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' > cols.csv

or

gunzip -c 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' > cols.csv

But if you just want a single 'column' (I presume you mean field), then you are better off just doing bcftools query.

$\endgroup$
5
  • 1
    $\begingroup$ On some systems I have issues with zcat but gunzip -c will also accomplish the same result. $\endgroup$ Jan 26, 2022 at 15:38
  • 2
    $\begingroup$ @Exhausted Don't use unix utilities for this - it needs a level of expertise that your post history suggests you do not have. Use bcftools instead, that will address a lot of edge cases that you can't foresee. $\endgroup$
    – Ram RS
    Jan 26, 2022 at 19:44
  • $\begingroup$ tar can do select zip file search and extraction, but you're also data munging. $\endgroup$
    – M__
    Jan 26, 2022 at 20:47
  • $\begingroup$ Thank you all, but why you down voting me? $\endgroup$
    – Exhausted
    Jan 27, 2022 at 11:10
  • $\begingroup$ I have No idea, I didn’t downvote. $\endgroup$
    – user438383
    Jan 27, 2022 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.