I have a bgzip vcf file and build tabix index already, but I am wondering if tabix can query VCF file by ID, just like:

```
tabix my.vcf.gz id='rs527352437'
```

or is there another way to query dbSNP by ID quickly?
Here's an approach that uses `hg38` SNP data from UCSC, an `rs*` ID of interest, and `pts-line-bisect` to do a binary search.

Your VCF-formatted data will be in different columns, but the principle here is the same — you permute the ID into the first column of a text file. You sort that text file on the first column. You do a binary search on the sorted text file.

Binary searches on sorted data are fast — *log n* fast — resulting in searches that take fractions of a second where they would otherwise take minutes or longer.

1) Get SNPs and write them into a text file sorted by SNP ID. For `hg38`, for instance:

    $ LC_ALL=C
    $ wget -qO- http://hgdownload.cse.ucsc.edu/goldenpath/hg38/database/snp147.txt.gz \
       | gunzip -c \
       | awk -v OFS="\t" '{ print $5,$2,$3,($3+1) }' \
       | sort -k1,1 \
       > hg38.snp147.sortedByName.txt

2) Install [pts-line-bisect][1]:

    $ git clone https://github.com/pts/pts-line-bisect.git
    $ cd pts-line-bisect && make && cd ..
    
3) Run a query:

    $ rs_of_interest=rs2814778
    $ ./pts-line-bisect/pts_lbsearch -p hg38.snp147.sortedByName.txt ${rs_of_interest} \
       | head -1 \
       | cut -f2- \
       > result.bed

In your case, you could modify your VCF file to permute the columns, so that the ID is in the first column of all columns. You permute and then sort as in step 1. This is the file you query with `pts-line-bisect`. Whatever result you get — if any — you permute back into VCF field ordering, likely using `awk` or similar.

With some modifications, it should be possible to do a binary search on a sorted, compressed text file. An important consideration is that the sort order is stable, so that compressed blocks provide a consistent or "deterministic" direction to go in finding the right compressed block for the data being queried.

  [1]: https://github.com/pts/pts-line-bisect