View Single Post
Old 01-24-2017, 11:19 PM   #2
finswimmer
Member
 
Location: Europe

Join Date: Oct 2016
Posts: 60
Default

Hello,

Quote:
Originally Posted by sadiexiaoyu View Post
File "try", line 7, in <module>
out.write(id,a,"fasta")
TypeError: function takes exactly 1 argument (3 given)
write() expected only one string as parameter. So if you like to write these 3 arguments seperated with comma to the file you can do something like this:

Code:
from Bio import SeqIO

out = open("try_out.fasta", "w")
for seq_record in SeqIO.parse("try.fasta", "fasta"):
    a = seq_record.seq
    a = a[5:-6]
    id = seq_record.id
    out.write(id+","+a+","+"fasta"+"\n")
out.close()
The "\n" at the end is neccessary for linebreak, otherwise you would have all entrys in one line.

fin swimmer
finswimmer is offline   Reply With Quote