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