Entering edit mode
7.0 years ago
horsedog
▴
60
Hi, I'm new to python, now I'm using python to parse my data but I have no idea how to save my print-out result in a new file. I tried some codes but the new file is empty, does anyone know? Here is my script:
with open("new_file.txt", "w") as f:
from Bio import SeqIO
for seq_record in SeqIO.parse("genome.fna", "fasta"):
print seq_record.id, file = f)
f.close()
I mistyped, should be: print seq_record.id, file = f)
This is a known rendering issue on the site, don't worry about the missing
(
.works with python3.biopython 1.7 and python 3.6:
(note: Bracket open is lost in forum board formatting, after dnafile.write.)
output:
Your indentation is a bit unclear, can you correct this please? I'm not close enough to a computer to figure it out but I would expect your code to work...