1. 程式人生 > >reads count檔案轉化為fasta格式檔案(uniq reads)

reads count檔案轉化為fasta格式檔案(uniq reads)

在NCBI下載測序資料時有很多是以reads序列 + count數的格式,這種是作者去完接頭並過濾掉低質量reads後的結果。下面實現將reads count格式轉化為fasta格式

cat reads_count.txt
AAACCCGGGTTT 3
ACAAGATTAG 5
TAGACAGA 1

python實現

fw = open('./reads.fas', 'w')
s = 0
with open('./reads_count.txt', 'r') as fr:
    for line in fr.readlines():
        s += 1
        name = '>ID' +s + '_' + line.strip().split('\t')[1]
        seq = line.strip().split('\t')[0]
        fw.write(name + '\n' + seq + '\n')
fw.close()

linux實現

awk