I've a set of sequences like :-
sequenceset = ['AGATAAGTTCACGTTACCAT', 'GTATT', 'TAGATGAAGCGGGATAGTCTTTTTCTGATATGCACTTATCAGTTCACTAGCAGT', 'ACTGAACGTGATTGATGAAGCT', 'ATCTA']
i converted them into SeqRecord Objects:-
for records in sequenceset:
my_seqs = SeqRecord(Seq(records,IUPAC.DNA), id = randomsequence)
now how can i write this to a file in fasta format ?
I tried :-
handle = open(file_location,"w")
for sequences in my_seqs:
SeqIO.write(sequences,handle,"fasta")
But this shows error :
AttributeError: 'str' object has no attribute 'id'
python is indentation specific, please fix your indentation in you code fragments, also what is
"randomsequence", is it defined elsewhere? I suggest to put the complete code, and put it in one block.
You're missing bits of code here (e.g. the import lines). As Michael wrote, putting a complete example is a good idea.
I've reverted the code back to randomsequence not having quotes, as it keeps the question logical in respect to the answer given by Dk.