{"action":"closed","issue":{"url":"https://api.github.com/repos/arq5x/bedtools/issues/111","labels_url":"https://api.github.com/repos/arq5x/bedtools/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/arq5x/bedtools/issues/111/comments","events_url":"https://api.github.com/repos/arq5x/bedtools/issues/111/events","html_url":"https://github.com/arq5x/bedtools/issues/111","id":121536360,"number":111,"title":"annotating vcf with intersect","user":{"login":"dwaggott","id":3149944,"avatar_url":"https://avatars.githubusercontent.com/u/3149944?v=3","gravatar_id":"","url":"https://api.github.com/users/dwaggott","html_url":"https://github.com/dwaggott","followers_url":"https://api.github.com/users/dwaggott/followers","following_url":"https://api.github.com/users/dwaggott/following{/other_user}","gists_url":"https://api.github.com/users/dwaggott/gists{/gist_id}","starred_url":"https://api.github.com/users/dwaggott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwaggott/subscriptions","organizations_url":"https://api.github.com/users/dwaggott/orgs","repos_url":"https://api.github.com/users/dwaggott/repos","events_url":"https://api.github.com/users/dwaggott/events{/privacy}","received_events_url":"https://api.github.com/users/dwaggott/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-10T17:20:43Z","updated_at":"2015-12-10T17:45:11Z","closed_at":"2015-12-10T17:45:11Z","body":"I'm trying to annotate a vcf with a number of bedfiles. Not hard but it would be good to confirm the strategy with bedtools.\r\n\r\nObjective\r\na) The annotations are sorted but NOT collapsed/merged to avoid annotating positions with regions that don't overlap the position\r\nb) The output should have the same number of lines and order as the original vcf \r\nc) Multiple hits for a position should have `distinct` values collapsed\r\nd) Only chr, start,stop,annocol1,annocolx are required in the output. i.e. no score,name in `-a` and no chr, start, stop in `-b` \r\n\r\nChallenge\r\n1) `intersect` results in multiple hits/rows for a single position in the vcf when the annotations aren't merged. Seems like the easiest thing to do is do a `merge` on the output, right?\r\n2) `Intersect` on a bed3 (just the index) and bed4 results in a ragged output (8 columns where there is no  match and 7 where there is). Is there a way to avoid defaulting to a bed5 internally or should I add dummy columns to a bed3? See example.\r\n3) `merge` requires enumeration of all the columns but these are dynamically changing. Any way to default to all columns if `-o` is set? \r\n\r\nStrategy\r\n[tmp1.bed](https://gist.github.com/98c87cf7365a757d3a46) \r\n[tmp2.bed](https://gist.github.com/869ecc409d571185986e)\r\n```\r\n# bcftools view a.vcf |  awk '{OFS=\"\\t\";print $1, $2-1, $2}'  > tmp1.bed\r\nbedtools intersect -loj  -a tmp1.bed -b tmp2.bed > out1.bed\r\nbedtools merge -i out1.bed -o distinct -d delim -c 5 > out2.bed\r\n```"}}