diff --git a/jcvi/apps/base.py b/jcvi/apps/base.py index 32ff24e3..306a434e 100644 --- a/jcvi/apps/base.py +++ b/jcvi/apps/base.py @@ -54,14 +54,14 @@ def debug(level=logging.DEBUG): debug() -def get_logger(name: str): +def get_logger(name: str, level: int = logging.DEBUG): """Return a logger with a default ColoredFormatter.""" logger = logging.getLogger(name) if logger.hasHandlers(): logger.handlers.clear() logger.addHandler(RichHandler()) logger.propagate = False - logger.setLevel(logging.DEBUG) + logger.setLevel(level) return logger diff --git a/jcvi/graphics/chromosome.py b/jcvi/graphics/chromosome.py index f726a76e..5f590283 100644 --- a/jcvi/graphics/chromosome.py +++ b/jcvi/graphics/chromosome.py @@ -5,20 +5,20 @@ Legacy script to plot distribution of certain classes onto chromosomes. Adapted from the script used in the Tang et al. PNAS 2010 paper, sigma figure. """ -import logging import sys from itertools import groupby from math import ceil -from natsort import natsorted from typing import Tuple import numpy as np -from jcvi.apps.base import OptionGroup, OptionParser, datafile, sample_N -from jcvi.formats.base import DictFile, get_number -from jcvi.formats.bed import Bed -from jcvi.formats.sizes import Sizes -from jcvi.graphics.base import ( +from natsort import natsorted + +from ..apps.base import OptionGroup, OptionParser, datafile, logger, sample_N +from ..formats.base import DictFile, get_number +from ..formats.bed import Bed +from ..formats.sizes import Sizes +from ..graphics.base import ( CirclePolygon, Polygon, Rectangle, @@ -29,7 +29,7 @@ set1_n, set3_n, ) -from jcvi.graphics.glyph import BaseGlyph, plot_cap +from ..graphics.glyph import BaseGlyph, plot_cap class Chromosome(BaseGlyph): @@ -236,7 +236,7 @@ def __init__( # tip = length of the ticks y1, y2 = sorted((y1, y2)) ax.plot([x, x], [y1, y2], "-", color=fc, lw=2) - max_marker_name, max_chr_len = max(markers, key=lambda x: x[-1]) + _, max_chr_len = max(markers, key=lambda x: x[-1]) r = y2 - y1 ratio = r / max_chr_len marker_pos = {} @@ -314,7 +314,7 @@ def write_ImageMapLine(tlx, tly, brx, bry, w, h, dpi, chr, segment_start, segmen """ tlx, brx = [canvas2px(x, w, dpi) for x in (tlx, brx)] tly, bry = [canvas2px(y, h, dpi) for y in (tly, bry)] - chr, bac_list = chr.split(":") + chr, _ = chr.split(":") return ( '", file=mapfh) mapfh.close() - logging.debug("Image map written to `{0}`".format(mapfh.name)) + logger.debug("Image map written to `%s`", mapfh.name) if gauge: xstart, ystart = 0.9, 0.85