Last active
August 29, 2015 14:03
-
-
Save roryk/ed9b58d724da84ebc0ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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