Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3/2 compatibility #978

Merged
merged 20 commits into from
Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2015-06-12 Luiz Irber <khmer@luizirber.org>

* *.py: refactor for Python 3 compatibility. Clear separation of Unicode
and Byte strings, use __future__ imports for compatibility (print function,
absolute imports, unicode_literals), fix tests to consider changes to random
number generator between Python versions.
* khmer/_khmer.cc: rename file, methods return Unicode strings instead of
Bytestrings.

2015-06-12 Luiz Irber <khmer@luizirber.org>

* khmer/{khmermodule.cc},tests/test_hashbits.py: Add Unicode support to
Expand Down Expand Up @@ -83,7 +92,7 @@
* scripts/normalize-by-median.py: major refactoring to use context
managers and classes; fixed -R
* tests/test_scripts.py: added test for normalize's -R arg

2015-06-01 Tamer Mansour <drtamermansour@gmail.com>

* scripts/normalize-by-median.py: changed to count kmers from both PE reads
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CPPSOURCES=$(wildcard lib/*.cc lib/*.hh khmer/_khmermodule.cc)
PYSOURCES=$(wildcard khmer/*.py scripts/*.py)
SOURCES=$(PYSOURCES) $(CPPSOURCES) setup.py
DEVPKGS=sphinxcontrib-autoprogram pep8==1.5.7 diff_cover \
autopep8 pylint coverage gcovr nose screed pep257
autopep8 pylint coverage gcovr nose pep257 future screed

GCOVRURL=git+https://github.com/nschum/gcovr.git@never-executed-branches
VERSION=$(shell git describe --tags --dirty | sed s/v//)
Expand Down Expand Up @@ -36,7 +36,7 @@ help: Makefile
install-dep: install-dependencies

install-dependencies:
pip2 install --upgrade $(DEVPKGS) || pip install --upgrade $(DEVPKGS)
pip install --upgrade $(DEVPKGS)

## sharedobj : build khmer shared object file
sharedobj: khmer/_khmermodule.so
Expand Down
16 changes: 10 additions & 6 deletions khmer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
"""This is khmer; please see http://khmer.readthedocs.org/."""

from __future__ import print_function

from khmer._khmer import CountingHash
from khmer._khmer import LabelHash as _LabelHash
from khmer._khmer import Hashbits as _Hashbits
Expand Down Expand Up @@ -179,12 +181,14 @@ def calc_expected_collisions(hashtable, force=False, max_false_pos=.2):
fp_all = fp_one ** n_ht

if fp_all > max_false_pos:
print >>sys.stderr, "**"
print >>sys.stderr, "** ERROR: the graph structure is too small for "
print >>sys.stderr, "this data set. Increase k-mer presence table "
print >>sys.stderr, "size/num of tables."
print >>sys.stderr, "** Do not use these results!!"
print >>sys.stderr, "**"
print("**", file=sys.stderr)
print(
"** ERROR: the graph structure is too small for ", file=sys.stderr)
print(
"this data set. Increase k-mer presence table ", file=sys.stderr)
print("size/num of tables.", file=sys.stderr)
print("** Do not use these results!!", file=sys.stderr)
print("**", file=sys.stderr)
if not force:
sys.exit(1)

Expand Down
Loading