1 2 #------------------------------------------------------------------------------ 3 # $File: bioinformatics,v 1.5 2019/04/19 00:42:27 christos Exp $ 4 # bioinfomatics: file(1) magic for Bioinfomatics file formats 5 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 ############################################################################### 10 0 string \037\213 11 >3 byte &0x04 12 >>12 string BC 13 >>>14 leshort &0x02 Blocked GNU Zip Format (BGZF; gzip compatible) 14 >>>>16 leshort x \b, block length %d 15 !:mime application/x-gzip 16 17 18 ############################################################################### 19 # Tabix index file 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) 26 >0x08 lelong ^0x10000 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 32 >0x08 lelong =0 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 36 37 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) 44 >0x04 lelong >0 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 48 49 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 56 57 58 ############################################################################### 59 # CRAM (Binary Sequence Alignment/Map format) 60 ############################################################################### 61 0 string CRAM CRAM 62 >0x04 byte >-1 version %d. 63 >0x05 byte >-1 \b%d 64 >0x06 string >\0 (identified as %s) 65 66 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 ############################################################################### 72 0 string BCF\4 73 # length of seqnm data in bytes is positive 74 >&0x00 lelong >0 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 82 83 84 ############################################################################### 85 # BCF (Binary Call Format), version 2.1 86 # used by SAMtools (https://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 91 >&0x00 lelong >0 92 # have header string 93 >>&0x00 search ##samtoolsVersion= 94 >>>&0x00 string x \b, generated by SAMtools version %s 95 96 97 ############################################################################### 98 # BCF (Binary Call Format), version 2.2 99 # used by SAMtools (https://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 104 >&0x00 lelong >0 105 # have header string 106 >>&0x00 search ##samtoolsVersion= 107 >>>&0x00 string x \b, generated by SAMtools version %s 108 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 115 116 ############################################################################### 117 # FASTQ 118 # used by MAQ (http://maq.sourceforge.net/fastq.shtml) 119 ############################################################################### 120 # XXX Broken? 121 # @<seqname> 122 #0 regex =^@[A-Za-z0-9_.:-]+\?\n 123 # <seq> 124 #>&1 regex =^[A-Za-z\n.~]++ 125 # +[<seqname>] 126 #>>&1 regex =^[A-Za-z0-9_.:-]*\?\n 127 # <qual> 128 #>>>&1 regex =^[!-~\n]+\n FASTQ 129 130 ############################################################################### 131 # FASTA 132 # used by FASTA (https://fasta.bioch.virginia.edu/fasta_www2/fasta_guide.pdf) 133 ############################################################################### 134 #0 byte 0x3e 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 142 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 ############################################################################### 149 0 string @HD\t 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} 157 # SAM Alignment FLAG 158 >0 regex =^([^\t]+\t){1}[0-9]{1,5}\t 159 # SAM Alignment RNAME 160 >>0 regex =^([^\t]+\t){2}\\*|[^*=]*\t 161 # SAM Alignment POS 162 >>>0 regex =^([^\t]+\t){3}[0-9]{1,9}\t 163 # SAM Alignment MAPQ 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 171 # SAM Alignment TLEN 172 >>>>>>>>0 regex =\t[+-]{0,1}[0-9]{1,9}\t.*\t 173 # SAM Alignment SEQ 174 >>>>>>>>>0 regex =^([^\t]+\t){9}(\\*|[A-Za-z=.]+)\t 175 # SAM Alignment QUAL 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 179