Question: VCF header line counting
1
gravatar for basalganglia
5.9 years ago by
basalganglia40
England
basalganglia40 wrote:

Hello happy bioinformaticians :)

It can be a very simple quesion but I want to ask that how can I count line (row) of header of VCF ?

I can be done manually but I want to get accurate result.

 

Thanks,

BG

header vcf • 4.3k views
ADD COMMENTlink modified 5.9 years ago by Biostar ♦♦ 20 • written 5.9 years ago by basalganglia40

Thanks !! :)

ADD REPLYlink written 5.9 years ago by basalganglia40

Please accept Coryza's answer if it was helpful, otherwise give them feedback on why it did not address your problem.

ADD REPLYlink written 5.9 years ago by _r_am32k
9
gravatar for Coryza
5.9 years ago by
Coryza390
Netherlands
Coryza390 wrote:

Simply count the number of rows starting with a #: 

grep -c '^#' <vcf>

If you want to count the number of sequence headers:

grep -c '##contig' <vcf>

And even more.. if you want to count the number of non-headers:

grep -c '^[^#]' <vcf>

On the command line ofcourse ;)

ADD COMMENTlink modified 5.9 years ago • written 5.9 years ago by Coryza390
5

The grep command will read the entire file, so if your VCF file is very large, something like this will run faster:

sed -n '/^[^#]/q;p' <vcf> | wc -l

 

 

ADD REPLYlink written 5.9 years ago by Len Trigg1.5k

Thanks it was so helpful !!! 

ADD REPLYlink written 5.9 years ago by basalganglia40
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1086 users visited in the last hour