forked from sanger-pathogens/gffmunger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gffutils-dumper.py
28 lines (23 loc) · 1.5 KB
/
gffutils-dumper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import gffutils
import warnings
import dumper
# provisioning on ubuntu/xenial64 virtual box:
# apt-get install -y git python3 python-setuptools python3-biopython python3-pip
# pip3 install dumper gffutils
data_dir = os.path.dirname( os.path.realpath( __file__ ) )
test_gff_file = os.path.join( data_dir, 'SAMPLE.gff3.gz' )
test_gff_db_file = os.path.join( data_dir, 'gffutils_test.db' )
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "unclosed file <_io\.TextIOWrapper", ResourceWarning, "gffutils", 133 )
warnings.filterwarnings("ignore", "generator '_FileIterator\.", PendingDeprecationWarning, "gffutils", 186 )
warnings.filterwarnings("ignore", "unclosed file <_io\.TextIOWrapper", ResourceWarning, "gffutils", 668 )
test_gff_db = gffutils.create_db( test_gff_file,
dbfn = test_gff_db_file,
force = True, # overwrite previous testing db file
merge_strategy = 'error',
keep_order = False, # True doesn't appear to maintain attribute order :-/ (and turning this off may be faster)
sort_attribute_values = False
)
for this_feature in test_gff_db.all_features():
print(dumper.dump(this_feature))