# 【2.2】Fastq格式--phred33/64

FASTQ是基于文本的，保存生物序列（通常是核酸序列）和其测序质量信息的标准格式。一般由测序下级文件bcl得来，其序列以及质量信息都是使用一个ASCII字符标示，最初由Sanger开发，目的是将FASTA序列与质量数据放到一起，目前已经成为高通量测序结果的事实标准。

## 一、文件的命名

fastq文件一般遵循这样的命令规程

__L_R_.fastq.gz


NA10831_ATCACG_L002_R1_001.fastq.gz


## 二、文件的格式

FASTQ格式的序列一般都包含有四行:

• 第一行由'@‘开始，后面跟着序列的描述信息，这点跟FASTA格式是一样的。
• 第二行是序列
• 第三行由’+‘开始，后面也可以跟着序列的描述信息
• 第四行是第二行序列的质量评价**（quality values，注：应该是测序的质量评价），字符数跟第二行的序列是相等的。

@FCC0U6BACXX:6:1101:1418:2067#CTAGTTAT/1
CCGGTAAAGGATCGTATCCTGCGTGCACGATGGCGGTATTTGCGCTGGATACACCCATCCCAATATCAGCTGCTTTATCGATCAACAAGA
+
abbecceegggggiihhhfgihiifhhiihiiiihiZafgffhihg]aabdedddcab^acbcbb_]bcccR]SSYSWQ[JT]_^X[


### 2.1 第一行（ Sequence identifier）

@<instrument>:<run number>:<flowcell ID>:<lane>:<tile>:<x-pos>:<y-pos> <read>:<is filtered>:<control number>:<index sequence>


Element Requirements Description
@ @ Each sequence identifier line starts with @
< instrument> Characters allowed: a-z, A-Z, 0-9 and underscore Instrument ID
< run number> Numerical Run number on instrument
< flowcell ID> Characters allowed: a-z, A-Z, 0-9 -
< lane> Numerical Lane number
< tile> Numerical Tile number
< x_pos> Numerical X coordinate of cluster
< y_pos> Numerical Y coordinate of cluster
< is filtered> Y or N Y if the read is filtered, N otherwise
< control number> Numerical 0 when none of the control bits are on, otherwise it is an even number. See below.
< index sequence> ACTG Index sequence

The tenth columns () is zero if the read is not identified as a control. If the read is identified as a control, the number is greater than zero, and the value specifies what kind of control it is. The value is the decimal representation of a bit-wise encoding scheme, with bit 0 having a decimal value of 1, bit 1 a value of 2, bit 2 a value of 4, and so on. The bits are used as follows:

• Bit 0: always empty (0)
• Bit 1: was the read identified as a control?
• Bit 2: was the match ambiguous?
• Bit 3: did the read match the phiX tag?
• Bit 4: did the read align to match the phiX tag?
• Bit 5: did the read match the control index sequence?
• Bits 6,7: reserved for future use
• Bits 8..15: the report key for the matched record in the controls.fasta file (specified by the REPORT_KEY metadata)

### 2.2 关于质量编码格式

Phred quality scores are logarithmically linked to error probabilities
PHRED QUALITY SCORE PROBABILITY OF INCORRECT BASE CALL BASE CALL ACCURACY
10 1 in 10 90 %
20 1 in 100 99 %
30 1 in 1000 99.9 %
40 1 in 10000 99.99 %
50 1 in 100000 99.999 %
Phred quality scores Q are defined as a property which is logarithmically related to the base-calling error probabilities P.
Q=-10log10P
`

Solexa/Illumina 1.0, Solexa/Illumina quality score，值的范围从-5到63，对应的ASCII码从59到126，对于测序数据，得分一般在-5到40之间；

Illumina 1.3+，Phred quality score，值的范围从0到62对应的ASCII码从64到126，低于测序数据，得分在0到40之间；

Illumina 1.5+，Phred quality score，但是0到2作为另外的标示，详见http://solexaqa.sourceforge.net/questions.htm#illumina

Illumina 1.8+

fastq_phred_decide.pl