コードは次のとおりです。
def readFasta(filename):
""" Reads a sequence in Fasta format """
fp = open(filename, 'rb')
header = ""
seq = ""
while True:
line = fp.readline()
if (line == ""):
break
if (line.startswith('>')):
header = line[1:].strip()
else:
seq = fp.read().replace('\n','')
seq = seq.replace('\r','') # for windows
break
fp.close()
return (header, seq)
FASTAsequence = readFasta("MusChr01.fa")
私が得ているエラーは次のとおりです。
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
しかし、startswith
ドキュメントによると、最初の引数は文字列であるはずです...では、何が起こっているのでしょうか?
LiClipse の最新バージョンを使用しているため、少なくとも Python 3 を使用していると想定しています。