[Biopython] GFF.writer

Mic mictadlo at gmail.com
Mon May 6 05:02:01 UTC 2013


Hi Brad,
Thank you it is working, but I have few questions by running the bellow
code:
from BCBio import GFF
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.SeqFeature import SeqFeature, FeatureLocation

out_file = "your_file.gff"
seq = Seq("GATCGATCGATCGATCGATC")
rec = SeqRecord(seq, "ID1")
qualifiers = {"source": "prediction", "note": "F5M15.26 n:1 Tax:Arabidopsis
thaliana RepID:Q9LMV1_ARATH",
              "ID": "gene1"}
sub_qualifiers = {"source": "prediction"}
top_feature = SeqFeature(FeatureLocation(0, 20), type="gene", strand=1,
                         qualifiers=qualifiers)
top_feature.sub_features = [SeqFeature(FeatureLocation(0, 5), type="exon",
strand=1, score=12,
                                       qualifiers=sub_qualifiers),
                            SeqFeature(FeatureLocation(15, 20),
type="exon", strand=1, score=-13,
                                       qualifiers=sub_qualifiers)]
rec.features = [top_feature]

with open(out_file, "w") as out_handle:
    GFF.write([rec], out_handle)


* How is it possible to avoid to get e.g. *%20* and is there a way to get
this order ID, note in below output?
note=F5M15.26*%20*n*%3A*
1%20Tax%3AArabidopsis%20thaliana%20RepID%3AQ9LMV1_ARATH;ID=gene1

* How is it possible to get score in sub_features, because the above code
caused the following error?
Traceback (most recent call
last):

  File "problem.py", line 15, in
<module>


qualifiers=sub_qualifiers),

TypeError: __init__() got an unexpected keyword argument 'score'

Thank you in advance

Mic


On Fri, May 3, 2013 at 8:51 PM, Brad Chapman <chapmanb at 50mail.com> wrote:

>
> Mic;
>
> > I found here ( http://www.biopython.org/wiki/GFF_Parsing#Writing_GFF3 )
> an
> > example how to write gff3 files.
> >
> > Is it possible not to write "##sequence-region ID1 1 20"?
>
> It only writes that line if you supply a sequence for the SeqRecord:
>
>
> https://github.com/chapmanb/bcbb/blob/master/gff/BCBio/GFF/GFFOutput.py#L105
>
> so manually removing the sequence before writing will prevent it from
> outputting that metadata. However, the GFF3 spec encourages writing
> these metadata items:
>
> http://www.sequenceontology.org/gff3.shtml
>
> Brad
>



More information about the Biopython mailing list