Closed
Description
$ bcftools --version
bcftools 1.13
Using htslib 1.13
I have a sites.txt and a temp.vcf.
$ cat site.txt
1 10001 G A
1 10002 A A
1 10003 G C
1 10004 A C
$ cat temp.vcf
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=1,length=20000000>
#CHROM POS ID REF ALT QUAL FILTER INFO
1 10001 . G C 40 . .
1 10002 . T A 50 . .
1 10003 . A G 60 . .
1 10004 . A T 70 . .
Use bcftools view to get site in sites.txt.
$ bcftools view -T site.txt temp.vcf
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=1,length=20000000>
##bcftools_viewVersion=1.13+htslib-1.13
##bcftools_viewCommand=view -T site.txt temp.vcf; Date=Mon Oct 18 20:03:23 2021
#CHROM POS ID REF ALT QUAL FILTER INFO
1 10002 . T A 50 . .
1 10004 . A T 70 . .
The third columns of 10001 and 10003 is both G.
Only using the first two columns will help.
$ awk '{print $1"\t"$2}' site.txt > site1.txt
$ bcftools view -T site1.txt temp.vcf
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=1,length=20000000>
##bcftools_viewVersion=1.13+htslib-1.13
##bcftools_viewCommand=view -T site1.txt temp.vcf; Date=Mon Oct 18 20:04:41 2021
#CHROM POS ID REF ALT QUAL FILTER INFO
1 10001 . G C 40 . .
1 10002 . T A 50 . .
1 10003 . A G 60 . .
1 10004 . A T 70 . .
But it is unexpected that the unused columns have effect on result.
Activity