''' Alan Garvey filestuff.py A program to demonstrate various operations you can do with text files. ''' from readfasta import readfasta def rnawrite(): # read in the rna from disk # we assume there is exactly one sequence in the fasta file filename = input("Please enter the input filename: ") rnainfo = readfasta(filename) # Ignore all but the first sequence in the file and assume it is an RNA # sequence. rnasequence = rnainfo[0][2] # remove the start codon rnasequence = rnasequence[3:] # print the results print('The RNA sequence is:') print(rnasequence) # Save the result to an output file. outfilename = input("Please enter the output filename: ") handle = open(outfilename, mode="w") handle.write(rnasequence) handle.close() def copyfile(): filename = input("Please enter a filename: ") fobj_in = open(filename, mode="r") outname = filename.split(".")[0] + "-copy.txt" fobj_out = open(outname,"w") i = 1 for line in fobj_in: print(line.rstrip()) fobj_out.write(str(i) + ": " + line) i = i + 1 fobj_in.close() fobj_out.close()