<p>I would use <code>BCBio</code> for gff handling as it is written to directly interface with BioPython’s object model.</p>

<p>The only downside is that I believe it is no longer actively supported. It is however the package that the <a href="https://biopython.org/wiki/GFF_Parsing" rel="nofollow noreferrer">BioPython docs</a> use generally. There are plans to properly incorporate GFF/GTF parsers in to BP in the not too distant future according to that link though.</p>

CC BY-SA 4.0
2018-12-11T19:53:27.250Z
2018-12-11T19:53:27.250Z
Joe Healey
<p>Most GFF parsers handle the work of reading annotation data into objects for convenient data access, but most do not handle the important task of resolving relationships between features. The <a href="https://tag.readthedocs.io/en/stable/" rel="nofollow noreferrer"><strong>tag</strong> Python library</a> does both, grouping related features together for inspection, traversal, and feature-by-feature processing.</p>

<p><strong>CAVEAT</strong>: The tag library only supports GFF3.</p>

<p><strong>DISCLAIMER</strong>: I'm the developer of the tag library, so this is a shameless plug. :-)</p>

CC BY-SA 4.0
2018-12-13T14:35:19.103Z
2018-12-13T14:35:19.103Z
Daniel Standage
<p>No, <a href="https://biopython.org/wiki/GFF_Parsing" rel="noreferrer">there is currently no GFF support in biopython</a>. </p>

<p><a href="https://github.com/daler/gffutils" rel="noreferrer">However, you can read in GFF files into python using this package, gffutils</a>. There are also a few other packages to read/write GFF files, like <a href="https://pypi.org/project/gff3/" rel="noreferrer"><code>gff3</code></a>.</p>

CC BY-SA 4.0
2018-12-10T02:57:42.623Z
2018-12-10T02:57:42.623Z
conchoecia
<p>Is there a way to import a GFF file for an organism with Biopython in the same way you can for a Genbank file?</p>

<p>For example,</p>

<pre><code>from Bio import Entrez as ez
ez.email = '...'
handle = ez.efetch(db='gene', id='AE015451.2', rettype='genbank', retmode='xml')
h = handle.read()
print(h)
</code></pre>

<p>This will import a Gebank xml file for Pseudomonas putida.  Is there a way to do this for a GFF file?</p>

<python><phylogenetics><genbank><gff>
Importing GFF file with Biopython
# Importing GFF file with Biopython

(Asked by: username_0 on 2018-12-10)

Is there a way to import a GFF file for an organism with Biopython in the same way you can for a Genbank file?
For example,
from Bio import Entrez as ez
ez.email = '...'
handle = ez.efetch(db='gene', id='AE015451.2', rettype='genbank', retmode='xml')
h = handle.read()
print(h)

This will import a Gebank xml file for Pseudomonas putida.  Is there a way to do this for a GFF file?

**Tags:** python, phylogenetics, genbank, gff

---

## 3 answers

### Answer by username_3 on 2018-12-10. Score: 10 | Accepted answer

No, [there is currently no GFF support in biopython](https://biopython.org/wiki/GFF_Parsing).

[However, you can read in GFF files into python using this package, gffutils](https://github.com/daler/gffutils). There are also a few other packages to read/write GFF files, like [`gff3`](https://pypi.org/project/gff3/).


---

### Answer by username_1 on 2018-12-11. Score: 2

I would use `BCBio` for gff handling as it is written to directly interface with BioPython’s object model.

The only downside is that I believe it is no longer actively supported. It is however the package that the [BioPython docs](https://biopython.org/wiki/GFF_Parsing) use generally. There are plans to properly incorporate GFF/GTF parsers in to BP in the not too distant future according to that link though.


---

### Answer by username_2 on 2018-12-13. Score: 1

Most GFF parsers handle the work of reading annotation data into objects for convenient data access, but most do not handle the important task of resolving relationships between features. The [**tag** Python library](https://tag.readthedocs.io/en/stable/) does both, grouping related features together for inspection, traversal, and feature-by-feature processing.

**CAVEAT**: The tag library only supports GFF3.

**DISCLAIMER**: I'm the developer of the tag library, so this is a shameless plug. :-)


---

