您的位置:首页 > Web前端

SAM得到完美匹配(perfect match)

2017-02-22 15:03 447 查看
主要针对bwa生成的sam文件中,如何找到完美匹配的比对结果。

完美匹配(perfect match)是指:一条序列能够在不允许编辑距离(edit distance),碱基错配(mismatch), GAP opens/extentions时能够比对到参考基因组上。

BWA比对的结果最终为sam(Sequence Alignment/Map)格式,内容如下:

ColFieldDescription
1QNAMEQuery (pair) NAME
2FLAGbitwise FLAG
3RNAMEReference sequence NAME
4POS1-based leftmost POSition/coordinate of clipped sequence
5MAPQMAPping Quality (Phred-scaled)
6CIAGRextended CIGAR string
7MRNMMate Reference sequence NaMe (‘=’ if same as RNAME)
8MPOS1-based Mate POSistion
9ISIZEInferred insert SIZE
10SEQquery SEQuence on the same strand as the reference
11QUALquery QUALity (ASCII-33 gives the Phred base quality)
12OPTvariable OPTional fields in the format TAG:VTYPE:VALUE
CIGAR值能够指示部分比对情况,但是但从CIGAR值来判断比对详细情况是不够的,所以,比如一条序列长度为36bp,比对到基因组上,CIGAR值为“36M”,单凭这个值是不能判断是否为完美匹配的。

我们需要根据bwa结果中的OPT列,即tag值来进行进一步的判断。bwa中提供的tag值如下:

TagMeaning
NMEdit distance
MDMismatching positions/bases
ASAlignment score
BCBarcode sequence
X0Number of best hits
X1Number of suboptimal hits found by BWA
XNNumber of ambiguous bases in the referenece
XMNumber of mismatches in the alignment
XONumber of gap opens
XGNumber of gap extentions
XTType: Unique/Repeat/N/Mate-sw
XAAlternative hits; format: (chr,pos,CIGAR,NM;)*
XSSuboptimal alignment score
XFSupport from forward/reverse alignment
XENumber of supporting seeds
在使用tag信息挑选perfect match时,设置NM(编辑距离)为0,XM(错配个数)为0,X0(最佳匹配个数)为1。之所以设置最佳匹配数,是因为一条序列有可能有多个完美匹配,这种序列在后续分析中不会用到,这个参数是可选的。

使用Perl语言设置的过滤条件如下:

next if $line !~ /NM:i:0/;
next if $line !~ /XM:i:0/;
next if $line !~ /X0:i:1\s+/;


(完)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bioinfo bwa sam