在現(xiàn)實生活中,我們經(jīng)常會遇到從0開始計數(shù)還是從1開始計數(shù)的問題。此處先從現(xiàn)實生活中的實例說起,過渡到電腦編程,然后再詳細解釋基因組的坐標問題,最后列出一些有用的網(wǎng)址,感興趣的可以繼續(xù)閱讀、加深理解。
In British English the floor of a building at street level is the ground floor and the floor above that is the first floor. In US English the street-level floor is the first floor and the one above is the second floor.
在多數(shù)程序(此處以Perl為例)中,計數(shù)都是(此處以數(shù)組為例)從0開始的。比如,對于數(shù)組@array來說,它的第一個元素是$array[0],第二個元素是$array[1],…… 正因為這種程序與現(xiàn)實的差異,導致了程序員們養(yǎng)成了從0開始數(shù)數(shù)的習慣。(參看:9條編程帶給程序員的壞習慣;)
在生物學的基因組坐標的表示中,有兩種方法:一種是大家比較容易理解的全包含的1-based(one-based, fully-closed),如[start, end];另一種是容易引起迷惑但卻常用而且易用的半包含的0-based(zero-based, half-open),如[start, end)。下面僅根據(jù)我的理解通過一個簡單的例子來說明一下。至于這兩種方法的詳細區(qū)別以及各自的優(yōu)缺點,請參考后面給出的鏈接。
其中TG的坐標位置如何表示呢?
還有一種不同的(真正的?)解釋方法如下:
我們常用的數(shù)據(jù)格式及數(shù)據(jù)庫中,那些使用的1-based,那些使用的0-based?
Coordinate Transforms 備注:如果你發(fā)現(xiàn)本文有錯誤,或者有需要修改、添加的內(nèi)容,請通知我。先行謝過!補充(20110506)Explanation from “The SAM Format Specification“.
A coordinate system where the first base of a sequence is one. In this coordinate system, a region is specified by a closed interval. For example, the region between the 3rd and the 7th bases inclusive is [3, 7]. The SAM, GFF and Wiggle formats are using the 1-based coordinate system.
A coordinate system where the first base of a sequence is zero. In this coordinate system, a region is specified by a half-closed-half-open interval. For example, the region between the 3rd and the 7th bases inclusive is [2, 7). The BAM, BED, and PSL formats are using the 0-based coordinate system. 相關獲取基因組的子序列2011年5月14日在“所有博文”中 [更新]基因組的坐標系統(tǒng):0-based與1-based2011年5月6日在“所有博文”中 人類基因組中的基因密度、特征長度和SNP密度2012年10月13日在“所有博文”中 |
|