[Biopython] Read sequence from file

Peter Cock p.j.a.cock at googlemail.com
Fri Feb 27 09:07:46 UTC 2015


On Fri, Feb 27, 2015 at 4:42 AM, Horea Chrristian <h.chr at mail.ru> wrote:
> Many thanks,
>
> from Bio.Seq import Seq
> from Bio.Alphabet import generic_dna
> with open("my_example.txt") as handle:
>     my_seq = Seq(handle.read().strip(), generic_dna)
>
> solves it just fine. I would want one sequence regardless the line breaks,
> but that is not relly that important.

Then try:

my_seq = Seq("".join(handle.read().strip().split()), generic_dna)

> What do you mean by "Right now" - will this likely change soon?
>
> Chhers,

We could add a "raw" format to Bio.SeqIO if there was a clear
motivating use-case or user demand. I'm a little wary because
of ambiguities like if some people would expect multiple lines
to be separate sequences or not.

Regards,

Peter


More information about the Biopython mailing list