Dear all,
I have a problem with Biopython.
I give it a fasta-sequence and need to make either reversed fasta sequence out of it in a separate output file, or just complement fasta-sequence in a separate output file.
The four lines below were taken from Biopython cookbook, and the script works perfectly well.
from Bio import SeqIO
records = (rec.reverse_complement(id="rc_"+rec.id, description = "reverse complement") \
for rec in SeqIO.parse("example.fasta", "fasta") if len(rec)<700)
SeqIO.write(records, "rev_comp.fasta", "fasta")
18
But my goal is fasta-file with just complement to the initial sequence, or reverse sequence to the initial fasta sequence.
So far I have not found any way to get them in Biopython.
I can open final rev_comp.fasta, copy the sequence itself, do something like that:
my_seq[::-1] and print the result to a new fasta-file, it will give me just complement sequence.
But it won't be a pure Biopython application, and a little bit more complicated with reverse sequence only.
Is there any simple way to do it in Biopython only? Actually I don't need reverse complement sequence at all, just either reverse or complement fasta sequences for my initial fasta-sequence.
Thank you very much!
Natasha
Please use code formatting for readability (101010 button), I modified your post for now.
But the code looks weird to me, I don't think this can work.
EDIT: I was wrong :)
This code is not mine,
see http://biopython.org/DIST/docs/tutorial/Tutorial.html
chapter 5.5.3
Honestly I didn't expect it would work, but it did.
Oh right, now I see it, it is a set comprehension split over two lines. Nevermind :-)