My question follows that one: file(1) and magic(5) : describing other formats .
I want to describe a FASTA sequence ( http://en.wikipedia.org/wiki/FASTA_format)
It could be a DNA sequence (with only ATGC)
>header
ATGCTAGCATAGCATCGATGCTGTAGCTACGTAGCTACGTCTACG
A 'magic' pattern would be
>.*\n[ATGC]*
or a PROTEIN sequence ( ACDEFGHIKLMNPQRSTVWYBZX containing ATGC too)
>header
AHITKLMNPQRGHIKLMNPQRC
A 'magic' pattern would be
>.*\n[ACDEFGHIKLMNPQRSTVWYBZX]*
But whenever I use those regular expressions, file tells me that it's a protein because it matches the 2nd regex. Is there a way to prioritize a result ? Is there a way to proritize , something like "Don't try any other pattern if that one matches ? ".
U
(Sec) andO
(Pyl) are correct and valid amino acid codes and you can also find*
for STOP as well as the various IUPAC codes such asY
for pyrimidines etc in nucleotide sequences as well as simple-
for gaps orX
orN
for masked or unknown residues. I'm pretty sure that most software will use some fairly complex heuristics to choose between DNA (and you seem to be ignoring RNA here) and protein. I very much doubt you can do it with a simple regex.>.*\n[ATCGXN-]*\n
for DNA for example (ignoring the other IUPAC codes).