Skip to content

Commit 8b42dbe

Browse files
author
Jon Palmer
committed
bump version; fix for gzip writing output
1 parent aae041f commit 8b42dbe

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

gfftk/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = (0, 1, 6)
1+
VERSION = (0, 1, 7)
22

33
__version__ = ".".join(map(str, VERSION))

gfftk/genbank.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .go import go_term_dict
77
from .interlap import InterLap
88
import io
9+
import gzip
910

1011

1112
def tbl2dict(input, fasta, annotation=False, table=1, debug=False):
@@ -434,7 +435,13 @@ def _goFormat(id, goDict=goDict):
434435
return False
435436

436437
if output:
437-
tbl = zopen(output, mode="w")
438+
if output.endswith(".gz"):
439+
copen = gzip.open
440+
mopen = "wt"
441+
else:
442+
copen = open
443+
mopen = "w"
444+
tbl = copen(output, mopen)
438445
else:
439446
tbl = sys.stdout
440447
# now convert to tbl format

gfftk/gff.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from urllib.parse import unquote
99
import uuid
1010
import io
11+
import gzip
1112

1213

1314
def start_end_gap(seq, coords):
@@ -1275,7 +1276,13 @@ def _sortDict(d):
12751276
sortedGenes = OrderedDict(sGenes)
12761277
# then loop through and write GFF3 format
12771278
if output:
1278-
gffout = zopen(output, mode="w")
1279+
if output.endswith(".gz"):
1280+
copen = gzip.open
1281+
mopen = "wt"
1282+
else:
1283+
copen = open
1284+
mopen = "w"
1285+
gffout = copen(output, mopen)
12791286
else:
12801287
gffout = sys.stdout
12811288
gffout.write("##gff-version 3\n")
@@ -1522,7 +1529,13 @@ def _sortDict(d):
15221529
sGenes = natsorted(iter(input.items()), key=_sortDict)
15231530
sortedGenes = OrderedDict(sGenes)
15241531
if output:
1525-
gtfout = zopen(output, mode="w")
1532+
if output.endswith(".gz"):
1533+
copen = gzip.open
1534+
mopen = "wt"
1535+
else:
1536+
copen = open
1537+
mopen = "w"
1538+
gtfout = copen(output, mopen)
15261539
else:
15271540
gtfout = sys.stdout
15281541
for k, v in list(sortedGenes.items()):

0 commit comments

Comments
 (0)