Here I have made a simple program to go through a text file containing a bunch of genes in a bacterial genome, including the amino acids that code for those genes (explicit use is better right?) I am relying heavily on modules in Biopython.
This runs fine in my Python shell, but I can't get it to save to a file.
This works:
import Bio
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqUtils import GC
from Bio.SeqUtils import ProtParam
for record in SeqIO.parse("RTEST.faa", "fasta"):
identifier=record.id
length=len(record.seq)
print identifier, length
but this doesnt:
import Bio
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqUtils import GC
from Bio.SeqUtils import ProtParam
for record in SeqIO.parse("RTEST.faa", "fasta"):
identifier=record.id
length=len(record.seq)
print identifier, length >> "testing.txt"
nor this:
import Bio
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqUtils import GC
from Bio.SeqUtils import ProtParam
f = open("testingtext.txt", "w")
for record in SeqIO.parse("RTEST.faa", "fasta"):
identifier=record.id
length=len(record.seq)
f.write(identifier, length)
nor this:
import Bio
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqUtils import GC
from Bio.SeqUtils import ProtParam
f = open("testingtext.txt", "w")
for record in SeqIO.parse("RTEST.faa", "fasta"):
identifier=record.id
length=len(record.seq)
f.write("len(record.seq) \n")