R/Bioconductor では、タスクは (a) 適切なライブラリをロードする (b) fasta ファイルを読み取る (c) ヌクレオチドの使用を計算し、% を gc する (d) データをビンに分割する (e) 元のデータを個別に出力するファイル。の線に沿って
## load
library(ShortRead)
## input
fa = readFasta("/path/to/fasta.fasta")
## gc content. 'abc' is a matrix, [, c("G", "C")] selects two columns
abc = alphabetFrequency(sread(fa), baseOnly=TRUE)
gc = rowSums(abc[,c("G", "C")]) / rowSums(abc)
## cut gc content into bins, with breaks at seq(0, 1, .2)
bin = cut(gc, seq(0, 1, .2))
## output, [bin==lvl] selects the reads whose 'bin' value is lvl
for (lvl in levels(bin)) {
fileName = sprintf("%s.fasta", lvl)
writeFasta(fa[bin==lvl], file=fileName)
}
R/Bioconductor を使用するには、http://bioconductor.org/install を参照してください。示されたサイズの 454 データのメモリ要件はそれほど悪くなく、ここでのスクリプトはかなり高速です (たとえば、260k の読み取りで 7 秒)。