Hey, that is pretty cool!
According to the SAM format white paper (http://samtools.sourceforge.net/SAM1.pdf) header lines should be matched by /^@[A-Za-z][A-Za-z](\t[A-Za-z][A-Za-z0-9]:[ -~])+$/ or /^@CO\t.*/. However, this does not seem to be the case with the example in the format white paper - or with real world data.
ruby -e 'puts "@HD\tVN:1.3\tSO:coordinate" =~ /^@[A-Za-z][A-Za-z](\t[A-Za-z][A-Za-z0-9]:[ -~])+$/'
So is the SAM header or the regex flawed?
Cheers
Martin
2 answers
Hm, looks like the regex is flawed. Whereas, it's currently:
/^@[A-Za-z][A-Za-z](\t[A-Za-z][A-Za-z0-9]:[ -~])+$/
It seems it should be:
/^@[A-Za-z][A-Za-z](\t[A-Za-z][A-Za-z0-9]:[ -~]+)+$/
Where the extra '+' allows more than 1 character following the :
Funny, to my understanding [ -~]+ allows one or more of that group of chars space, dash and tilde. How it matches '1.3' and 'coordinate' baffles me.
@masha it does look odd, but it's the same format as [A-Z] it means match any characters between (including endpoints) " " and "~". ord(" ") == 32 and ord("~") == 126
Of cause. I submitted the question to the samtools mailing list. Waiting for an answer.
Log in to answer this question.