Skip to content

Instantly share code, notes, and snippets.

@roryk
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryk/ed9b58d724da84ebc0ff to your computer and use it in GitHub Desktop.
Save roryk/ed9b58d724da84ebc0ff to your computer and use it in GitHub Desktop.
import gffutils
import os
gtf = "path/to/your/gtf/file"
def get_gtf_db(gtf, in_memory=False):
db_file = ":memory:" if in_memory else gtf + ".db"
if in_memory or not os.path.exists(db_file):
db = gffutils.create_db(gtf, dbfn=db_file)
if in_memory:
return db
else:
return gffutils.FeatureDB(db_file)
db = get_gtf_db(gtf)
for feature in db.all_features():
print feature
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment