diff --git a/jcvi/formats/base.py b/jcvi/formats/base.py index 8617a145..30450c4a 100644 --- a/jcvi/formats/base.py +++ b/jcvi/formats/base.py @@ -7,7 +7,7 @@ import sys from collections import OrderedDict -from itertools import groupby, islice, cycle +from itertools import cycle, groupby, islice from Bio import SeqIO from ..apps.base import ( @@ -337,7 +337,13 @@ def timestamp(): return "{0}{1:02d}{2:02d}".format(dt.now().year, dt.now().month, dt.now().day) -def must_open(filename, mode="r", checkexists=False, skipcheck=False, oappend=False): +def must_open( + filename: str, + mode: str = "r", + checkexists: bool = False, + skipcheck: bool = False, + oappend: bool = False, +): """ Accepts filename and returns filehandle. @@ -385,7 +391,7 @@ def must_open(filename, mode="r", checkexists=False, skipcheck=False, oappend=Fa elif filename.endswith(".bz2"): if "r" in mode: - cmd = "bzcat {0}".format(filename) + cmd = f"bzcat {filename}" fp = popen(cmd, debug=False) elif "w" in mode: import bz2 diff --git a/jcvi/formats/bed.py b/jcvi/formats/bed.py index 330d8577..df6a2bb6 100755 --- a/jcvi/formats/bed.py +++ b/jcvi/formats/bed.py @@ -135,7 +135,7 @@ def gffline(self, type="match", source="default"): score, strand, ".", - "ID=" + self.accn, + f"ID={self.accn}", ) ) return row diff --git a/jcvi/graphics/landscape.py b/jcvi/graphics/landscape.py index a53bc1b1..91be96ff 100644 --- a/jcvi/graphics/landscape.py +++ b/jcvi/graphics/landscape.py @@ -582,7 +582,7 @@ def linearray(binfile, chr, window, shift): m, n = zip(*mn) m = np.array(m, dtype="float") - w = window / shift + w = window // shift m = moving_sum(m, window=w) return m @@ -883,7 +883,7 @@ def heatmap(args): owindow = clen / 100 if owindow > window: - window = owindow / shift * shift + window = owindow // shift * shift stackplot(ax, stackbins, nbins, palette, chr, window, shift) ax.text( @@ -958,7 +958,7 @@ def draw_gauge(ax, margin, maxl, rightmargin=None): ax.plot([margin, 1 - rightmargin], [1 - margin, 1 - margin], "k-", lw=2) best_stride = autoscale(maxl) - nintervals = maxl * 1.0 / best_stride + nintervals = maxl / best_stride xx, yy = margin, 1 - margin tip = 0.005