Skip to content

Commit 4b8c7c7

Browse files
authored
Hotfix/issue4 empty ambig bookkeeping (#5)
* addressing issue #4 * added check for empty ambig_dumpfile * version -> 1.0.1 minors: * removed pyyaml requirement * import version from gffquant module
1 parent 59ba916 commit 4b8c7c7

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

gffquant/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0"
1+
__version__ = "1.0.1"

gffquant/feature_quantifier.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,25 @@ def process_data(self, bamfile):
275275
self.gff_dbm.clear_caches()
276276

277277
# second pass: process ambiguous alignment groups
278-
if self.require_ambig_bookkeeping():
279-
t0 = time.time()
280-
281-
ambig_aln = self._read_ambiguous_alignments(ambig_dumpfile)
282-
n_align = self._process_ambiguous_aln_groups(ambig_aln)
278+
if ambig_dumpfile:
279+
if os.path.isfile(ambig_dumpfile) and os.stat(ambig_dumpfile).st_size > 0:
280+
t0 = time.time()
283281

284-
if not DEBUG:
285-
os.remove(ambig_dumpfile)
282+
ambig_aln = self._read_ambiguous_alignments(ambig_dumpfile)
283+
n_align = self._process_ambiguous_aln_groups(ambig_aln)
286284

287-
t1 = time.time()
288-
print("Processed {n_align} secondary alignments in {n_seconds:.3f}s.".format(
289-
n_align=n_align, n_seconds=t1-t0), flush=True)
285+
t1 = time.time()
286+
print("Processed {n_align} secondary alignments in {n_seconds:.3f}s.".format(
287+
n_align=n_align, n_seconds=t1-t0), flush=True)
288+
else:
289+
print("Warning: ambig-mode chosen, but bamfile does not contain secondary alignments.")
290+
self.overlap_counter.has_ambig_counts = True # we expect ambig cols in the outfile!
291+
292+
try:
293+
if not DEBUG:
294+
os.remove(ambig_dumpfile)
295+
except:
296+
pass
290297

291298
self.overlap_counter.annotate_counts(self.bamfile)
292299
self.overlap_counter.unannotated_reads += unannotated_ambig

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import re
99
import sys
1010

11-
11+
from gffquant import __version__ as gffquant_version
1212
here = path.abspath(path.dirname("__file__"))
1313

1414
with open(path.join(here, "DESCRIPTION.md"), encoding="utf-8") as description:
1515
description = long_description = description.read()
1616

1717
name="gffquant"
18-
version = [line.strip().split(" ")[-1] for line in open("gffquant/__init__.py") if line.startswith("__version__")][0]
18+
version = gffquant_version
1919

2020
if sys.version_info.major != 3:
2121
raise EnvironmentError("""{toolname} is a python module that requires python3, and is not compatible with python2.""".format(toolname=name))
@@ -33,7 +33,7 @@
3333
"Development Status :: 4 - Beta",
3434
"Topic :: Scientific Engineering :: Bio/Informatics",
3535
"License :: OSI Approved :: MIT License",
36-
"Operating System :: POSIX :: Linux",
36+
"Operating System :: POSIX :: Linux",
3737
"Programming Language :: Python :: 3.7"
3838
],
3939
zip_safe=False,

0 commit comments

Comments
 (0)