[Biopython] gff3file
Peter Cock
p.j.a.cock at googlemail.com
Wed Jun 3 14:47:36 UTC 2015
On Wed, Jun 3, 2015 at 1:58 PM, Atteyet-Alla.Yassin
<Atteyet-Alla.Yassin at ukb.uni-bonn.de> wrote:
> I hope that is now right. I obtained the following erreor
>
>>>> from Bio import SeqIO
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named 'Bio'
This means you have not installed Biopython successfully.
Have you taken any introductory Python courses? I would suggest
Martin Jones' "Python for Biologists", available as a book or online:
http://pythonforbiologists.com/
>>>> with open("CP008802.out", "w") as output:
> ...
> output.write("Seqname\tSource\tfeature\tStart\tEnd\tScore\tStrand\tFrame\tAttributes\n")
> ... for record in SeqIO.parse("CP008802.txt", "genbank"):
> ... print("Converting %s" % record.name)
> ... for f in record.features:
> ... if f.type != "gene":
> ... continue
> ... locus_tag = f.qualifiers["locus_tag"][0]
> ... if len(f.location.parts) > 1:
> ... print("What should we do for %s (compound location)? %s"
> % (locus_tag, f.location))
> ... continue
> ... output.write('%s\tGenBank\t%s\t%i\t%i\t0,000000\t%s\t.\tlocus_tag\t"%s";
> transcript_id "%s"\n'
> ... % (record.name, f.type,
> ... f.location.start + 1, f.location.end,
> f.location.strand,
> ... locus_tag, locus_tag))
> ... print("Done")
>
It is quite hard to copy and paste multi-line code snippets
like with block or for loops into the interactive Python prompt.
Instead, I was recommending you save that whole example
as a Python script (a plain text file ending with .py).
Peter
More information about the Biopython
mailing list