{"action":"created","issue":{"url":"https://api.github.com/repos/samtools/hts-specs/issues/167","repository_url":"https://api.github.com/repos/samtools/hts-specs","labels_url":"https://api.github.com/repos/samtools/hts-specs/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/samtools/hts-specs/issues/167/comments","events_url":"https://api.github.com/repos/samtools/hts-specs/issues/167/events","html_url":"https://github.com/samtools/hts-specs/issues/167","id":174754804,"number":167,"title":"New Restrictions on Contig Names not Strict Enough","user":{"login":"jamesemery","id":16102845,"avatar_url":"https://avatars.githubusercontent.com/u/16102845?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesemery","html_url":"https://github.com/jamesemery","followers_url":"https://api.github.com/users/jamesemery/followers","following_url":"https://api.github.com/users/jamesemery/following{/other_user}","gists_url":"https://api.github.com/users/jamesemery/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesemery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesemery/subscriptions","organizations_url":"https://api.github.com/users/jamesemery/orgs","repos_url":"https://api.github.com/users/jamesemery/repos","events_url":"https://api.github.com/users/jamesemery/events{/privacy}","received_events_url":"https://api.github.com/users/jamesemery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-02T13:02:47Z","updated_at":"2016-09-02T17:09:44Z","closed_at":null,"body":"I see that in section 1.4.7 of VCFv4.3, it states that contig names can mostly follow restrictions placed upon them by the SAM spec except for a few explicitly disallowed characters. It would seem that the restricted characters are not enough to preserve parsing of VCF files. Specifically, the SAM format restrictions specify (”[!-)+-<>-~][!-~]*”) which translates into any printable character so long as it isn't in the first place. We place some restrictions on this, namely specifying that the characters ”<>[]:*” are additionally non-valid. Since the contig name has to appear in a header line this runs the risk of making it impossible to parse a header string. An example contig header line might be:\r\n\r\n`##contig=<ID=ctg1,length=81195210,Description=\"Foo\">`\r\n\r\nUnfortunately both the `=` and the `,` characters are legal according to the new restrictions so technically the string \"ctg1,length=81195210\" COULD be a valid contig name, which means that parsing is ambiguous. Something needs to be done about these two characters at least, the way I see it there are a couple options:\r\n\r\n1. Restrict the contig name to disallow `=` and `,` would fix this problem at the expense of further restricting contigs allowed by the SAM spec.\r\n\r\n2. Escape the ID field in the contig header line somehow, for example with a second set of `<>` or `\"\"` characters making the header line look something like this: \r\n`##contig=<ID=<ctg1>,length=81195210,Description=\"Foo\">` which would break forward compatibility and add some complexity into parsing.\r\n\r\n3. Encode dangerous characters in the header somehow, perhaps by percent encoding of the header contig ID field. The VCFv4.3 spec only seems to explicitly specify percent encoding for INFO and FORMAT field values. Perhaps it could be expanded/clarified to also apply to header ID line values (except for INFO and FORMAT where a regex is already imposed)?\r\n"},"comment":{"url":"https://api.github.com/repos/samtools/hts-specs/issues/comments/244433512","html_url":"https://github.com/samtools/hts-specs/issues/167#issuecomment-244433512","issue_url":"https://api.github.com/repos/samtools/hts-specs/issues/167","id":244433512,"user":{"login":"tfenne","id":1609210,"avatar_url":"https://avatars.githubusercontent.com/u/1609210?v=3","gravatar_id":"","url":"https://api.github.com/users/tfenne","html_url":"https://github.com/tfenne","followers_url":"https://api.github.com/users/tfenne/followers","following_url":"https://api.github.com/users/tfenne/following{/other_user}","gists_url":"https://api.github.com/users/tfenne/gists{/gist_id}","starred_url":"https://api.github.com/users/tfenne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tfenne/subscriptions","organizations_url":"https://api.github.com/users/tfenne/orgs","repos_url":"https://api.github.com/users/tfenne/repos","events_url":"https://api.github.com/users/tfenne/events{/privacy}","received_events_url":"https://api.github.com/users/tfenne/received_events","type":"User","site_admin":false},"created_at":"2016-09-02T17:09:44Z","updated_at":"2016-09-02T17:09:44Z","body":"I think that before making anything more restrictive it's worth doing a survey of what's actually being used.  E.g. disallowing anything that's in the broadly used hs38DH (including `:` and `*`) would cause a lot of people a lot of unnecessary pain."}}
{"actor":{"display_login":"tfenne"}}