[Biopython] Writting fasta file

xyz mitlox at op.pl
Thu Aug 26 11:27:31 UTC 2010


On 25/08/10 23:08, Peter wrote:
>
> Hi "xyz",
>
> Did you try looking in the tutorial? i.e.
> http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec:SeqIO-reverse-complement
>
> You could modify your code to use a generator expression like this:
>
> def make_rc(record):
>      """Modifies a SeqRecord in place, and returns it."""
>      record.seq = record.seq.reverse_complement()
>      return record
> records = (make_rc(r) for r in SeqIO.parse(in_opts.inputFasta, "fasta"))
> SeqIO.write(records, out_opts.outputFasta, "fasta")
>
> I also changed it to pass filenames directly to SeqIO - its shorter ;)
>
> See also this thread about adding a reverse complement
> method to the SeqRecord which would make this easier:
> http://lists.open-bio.org/pipermail/biopython-dev/2010-June/007850.html
>
> Peter
>    
Thank you for your code it looks much better than mine.

In order to save memory is it possible to write each record ie. one by 
one with SeqIO.write instead of all records at once?




More information about the Biopython mailing list