{"action":"opened","issue":{"url":"https://api.github.com/repos/arq5x/bedtools2/issues/171","labels_url":"https://api.github.com/repos/arq5x/bedtools2/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/arq5x/bedtools2/issues/171/comments","events_url":"https://api.github.com/repos/arq5x/bedtools2/issues/171/events","html_url":"https://github.com/arq5x/bedtools2/issues/171","id":53908572,"number":171,"title":"Annotate VCF INFO fields with intersections with N interval files.","user":{"login":"arq5x","id":72291,"avatar_url":"https://avatars.githubusercontent.com/u/72291?v=3","gravatar_id":"","url":"https://api.github.com/users/arq5x","html_url":"https://github.com/arq5x","followers_url":"https://api.github.com/users/arq5x/followers","following_url":"https://api.github.com/users/arq5x/following{/other_user}","gists_url":"https://api.github.com/users/arq5x/gists{/gist_id}","starred_url":"https://api.github.com/users/arq5x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arq5x/subscriptions","organizations_url":"https://api.github.com/users/arq5x/orgs","repos_url":"https://api.github.com/users/arq5x/repos","events_url":"https://api.github.com/users/arq5x/events{/privacy}","received_events_url":"https://api.github.com/users/arq5x/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-09T20:01:54Z","updated_at":"2015-01-09T20:01:54Z","closed_at":null,"body":"Thanks to the numerous improvements by @nkindlon to the chromsweep algorithm,  we now have the ability to quickly intersect a single \"query\" file against many \"database\" files, so long as the query and each database file is sorted by chromosome and start coordinate.\r\n\r\nWe therefore have the ability to create a rather powerful and sophisticated system annotating a VCF file.  For example, imagine we wanted to annotate the INFO field for each variant in a VCF file based on:\r\n    1. it is in a CpG island (BED format)\r\n    2. the observed alternate allele frequency in the ExAC dataset (VCF format)\r\n    3. the gene name from Ensembl if it overlaps an exon.\r\n\r\nOne could imagine a bedtools command called `vcfanno` as follows:\r\n\r\n    # unannotated VCF\r\n    cat my.annotated.vcf\r\n    #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Quinlan\r\n    20 14370 . G A 29 PASS DP=14;AF=0.5; GT 0|1\r\n    20 24370 . G A 29 PASS DP=24;AF=0.5; GT 0|1\r\n    20 24370 . G A 29 PASS DP=34;AF=0.5; GT 0|1\r\n\r\n    # she be annotated \r\n    bedtools vcfanno -a my.vcf \\\r\n       -b cpg.bed \\\r\n           exac.vcf \\\r\n           ensembl.gff \\\r\n       -tags CPG \\\r\n                EXAC \\\r\n                GENE \\\r\n       -rules boolean \\\r\n                 INFO:AF \\\r\n                 name \\\r\n    > my.annotated.vcf\r\n\r\nThe `-rules` option would define how the annotations from the various files would be used to populate the INFO field for each variant.  The `-tags` option defines the labels slammed into the INFO field. This will require some work and may require (prefer) a YAML config file.\r\nRegardless, the output would look something like:\r\n\r\n    cat my.annotated.vcf\r\n    #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Quinlan\r\n    20 14370 . G A 29 PASS DP=14;AF=0.5;CPG=0;EXAC=0.000023; GT 0|1\r\n    20 24370 . G A 29 PASS DP=24;AF=0.5;CPG=1;EXAC=0.013; GT 0|1\r\n    20 24370 . G A 29 PASS DP=34;AF=0.5;CPG=0;EXAC=0.043;GENE=ATM GT 0|1\r\n\r\n"}}