2 #------------------------------------------------------------------------------
3 # $File: bioinformatics,v 1.4 2016/06/20 16:13:46 christos Exp $
4 # bioinfomatics: file(1) magic for Bioinfomatics file formats
6 ###############################################################################
7 # BGZF (Blocked GNU Zip Format) - gzip compatible, but also indexable
8 # used by SAMtools bgzip/tabix (http://samtools.sourceforge.net/tabix.shtml)
9 ###############################################################################
13 >>>14 leshort &0x02 Blocked GNU Zip Format (BGZF; gzip compatible)
14 >>>>16 leshort x \b, block length %d
15 !:mime application/x-gzip
18 ###############################################################################
20 # used by SAMtools bgzip/tabix (http://samtools.sourceforge.net/tabix.shtml)
21 ###############################################################################
22 0 string TBI\1 SAMtools TBI (Tabix index format)
23 >0x04 lelong =1 \b, with %d reference sequence
24 >0x04 lelong >1 \b, with %d reference sequences
25 >0x08 lelong &0x10000 \b, using half-closed-half-open coordinates (BED style)
27 >>0x08 lelong =0 \b, using closed and one based coordinates (GFF style)
28 >>0x08 lelong =1 \b, using SAM format
29 >>0x08 lelong =2 \b, using VCF format
30 >0x0c lelong x \b, sequence name column: %d
31 >0x10 lelong x \b, region start column: %d
33 >>0x14 lelong x \b, region end column: %d
34 >0x18 byte x \b, comment character: %c
35 >0x1c lelong x \b, skip line count: %d
38 ###############################################################################
39 # BAM (Binary Sequence Alignment/Map format)
40 # used by SAMtools (http://samtools.sourceforge.net/SAM1.pdf)
41 # data is normally present only within compressed BGZF blocks (CDATA), so use file -z to examine it
42 ###############################################################################
43 0 string BAM\1 SAMtools BAM (Binary Sequence Alignment/Map)
45 >>&0x00 regex =^[@]HD\t.*VN: \b, with SAM header
46 >>>&0 regex =[0-9.]+ \b version %s
47 >>&(0x04) lelong >0 \b, with %d reference sequences
50 ###############################################################################
51 # BAI (BAM indexing format)
52 # used by SAMtools (http://samtools.sourceforge.net/SAM1.pdf)
53 ###############################################################################
54 0 string BAI\1 SAMtools BAI (BAM indexing format)
55 >0x04 lelong >0 \b, with %d reference sequences
58 ###############################################################################
59 # CRAM (Binary Sequence Alignment/Map format)
60 ###############################################################################
62 >0x04 byte >-1 version %d.
64 >0x06 string >\0 (identified as %s)
67 ###############################################################################
68 # BCF (Binary Call Format), version 1
69 # used by SAMtools & VCFtools (http://vcftools.sourceforge.net/bcf.pdf)
70 # data is normally present only within compressed BGZF blocks (CDATA), so use file -z to examine it
71 ###############################################################################
73 # length of seqnm data in bytes is positive
75 # length of smpl data in bytes is positive
76 >>&(&-0x04) lelong >0 SAMtools BCF (Binary Call Format)
77 # length of meta in bytes
78 >>>&(&-0x04) lelong >0
79 # have meta text string
80 >>>>&0x00 search ##samtoolsVersion=
81 >>>>>&0x00 string x \b, generated by SAMtools version %s
84 ###############################################################################
85 # BCF (Binary Call Format), version 2.1
86 # used by SAMtools (http://samtools.github.io/hts-specs/BCFv2_qref.pdf)
87 # data is normally present only within compressed BGZF blocks (CDATA), so use file -z to examine it
88 ###############################################################################
89 0 string BCF\2\1 Binary Call Format (BCF) version 2.1
90 # length of header text
93 >>&0x00 search ##samtoolsVersion=
94 >>>&0x00 string x \b, generated by SAMtools version %s
97 ###############################################################################
98 # BCF (Binary Call Format), version 2.2
99 # used by SAMtools (http://samtools.github.io/hts-specs/BCFv2_qref.pdf)
100 # data is normally present only within compressed BGZF blocks (CDATA), so use file -z to examine it
101 ###############################################################################
102 0 string BCF\2\2 Binary Call Format (BCF) version 2.2
103 # length of header text
106 >>&0x00 search ##samtoolsVersion=
107 >>>&0x00 string x \b, generated by SAMtools version %s
109 ###############################################################################
110 # VCF (Variant Call Format)
111 # used by VCFtools (http://vcftools.sourceforge.net/)
112 ###############################################################################
113 0 search ##fileformat=VCFv Variant Call Format (VCF)
114 >&0 string x \b version %s
116 ###############################################################################
118 # used by MAQ (http://maq.sourceforge.net/fastq.shtml)
119 ###############################################################################
122 #0 regex =^@[A-Za-z0-9_.:-]+\?\n
124 #>&1 regex =^[A-Za-z\n.~]++
126 #>>&1 regex =^[A-Za-z0-9_.:-]*\?\n
128 #>>>&1 regex =^[!-~\n]+\n FASTQ
130 ###############################################################################
132 # used by FASTA (http://fasta.bioch.virginia.edu/fasta_www2/fasta_guide.pdf)
133 ###############################################################################
135 # q>0 regex =^[>][!-~\t\ ]+$
136 # Amino Acid codes: [A-IK-Z*-]+
137 #>>1 regex !=[!-'Jj;:=?@^`|~\\] FASTA
138 # IUPAC codes/gaps: [ACGTURYKMSWBDHVNX-]+
139 # not in IUPAC codes/gaps: [EFIJLOPQZ]
140 #>>>1 regex !=[EFIJLOPQZefijlopqz] \b, with IUPAC nucleotide codes
141 #>>>1 regex =^[EFIJLOPQZefijlopqz]+$ \b, with Amino Acid codes
143 ###############################################################################
144 # SAM (Sequence Alignment/Map format)
145 # used by SAMtools (http://samtools.sourceforge.net/SAM1.pdf)
146 ###############################################################################
147 # Short-cut version to recognise SAM files with (optional) header at beginning
148 ###############################################################################
150 >4 search VN: Sequence Alignment/Map (SAM), with header
151 >>&0 regex [0-9.]+ \b version %s
152 ###############################################################################
153 # Longer version to recognise SAM alignment lines using (many) regexes
154 ###############################################################################
155 # SAM Alignment QNAME
156 0 regex =^[!-?A-~]{1,255}(\t[^\t]+){11}
158 >0 regex =^([^\t]+\t){1}[0-9]{1,5}\t
159 # SAM Alignment RNAME
160 >>0 regex =^([^\t]+\t){2}\\*|[^*=]*\t
162 >>>0 regex =^([^\t]+\t){3}[0-9]{1,9}\t
164 >>>>0 regex =^([^\t]+\t){4}[0-9]{1,3}\t
165 # SAM Alignment CIGAR
166 >>>>>0 regex =\t(\\*|([0-9]+[MIDNSHPX=])+)\t
167 # SAM Alignment RNEXT
168 >>>>>>0 regex =\t(\\*|=|[!-()+->?-~][!-~]*)\t
169 # SAM Alignment PNEXT
170 >>>>>>>0 regex =^([^\t]+\t){7}[0-9]{1,9}\t
172 >>>>>>>>0 regex =\t[+-]{0,1}[0-9]{1,9}\t.*\t
174 >>>>>>>>>0 regex =^([^\t]+\t){9}(\\*|[A-Za-z=.]+)\t
176 >>>>>>>>>>0 regex =^([^\t]+\t){10}[!-~]+ Sequence Alignment/Map (SAM)
177 >>>>>>>>>>>0 regex =^[@]HD\t.*VN: \b, with header
178 >>>>>>>>>>>>&0 regex =[0-9.]+ \b version %s