Fasta 형식의 파일에서 빈서열 제거

가끔씩 Blast를 수행하고자 formatdb를 수행 할 때,
다음과 같은 에러를 접한 적이 있으리라 본다.

[formatdb] WARNING: Cannot add sequence number XXXXX XX.XXX.XXX.
 because it has zero-length.

[formatdb] FATAL ERROR: Fatal error when adding sequence to BLAST database.


formatdb를 수행하려는 fasta 서열에
빈 서열을 가지고 있기 때문에 나오는 에러로
빈 서열을 제거하면 OK!

vi check.py

import glob,sys
from Bio import SeqIO

file = sys.argv[1]

ow = open(file.split('.')[0]+'.check','w')
seqs = SeqIO.parse(open(file), format='fasta')
 for rec in seqs:
        name = rec.description
        seq = rec.seq.tostring()

        if len(seq.strip()) != 0:
                ow.write('>'+name+'\n')
                ow.write(seq+'\n')

ow.close()



[test]$python check.py test.fasta

크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by gwlee

2009/05/08 19:30 2009/05/08 19:30
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://thegreatgoodplace.com/tt/study/rss/response/128

Trackback URL : http://thegreatgoodplace.com/tt/study/trackback/128

Leave a comment
« Previous : 1 : ... 31 : 32 : 33 : 34 : 35 : 36 : 37 : 38 : 39 : ... 128 : Next »

블로그 이미지

gwLee's Study story

- gwlee



Site Stats

Total hits:
49735
Today:
48
Yesterday:
80