printing - Send output of print to a new file in python? -
this question has answer here:
- what code mean: “print >> sys.stderr” 2 answers
in section of program i'm making converted plain sequence of letters fasta format. need take fasta format , put in file form can send program come later in code. in line 3 created "fasta.txt". need put output of line 8, fastaform, in file. in last line tried didn't work , have no idea how. feel should pretty simple i'm new @ this.
infname = sys.argv[2] handle = open(infname, "r") file = open("fasta.txt", "w") line in handle: linearr = line.split() seqid = linearr[0] seq = linearr[1] fastaform = (">%s\n%s\n" % (seqid,seq)) print fastaform >> "fasta.txt"
try
file.write(fastaform) file.close()