diff --git a/PanACoTA/annotate_module/genome_seq_functions.py b/PanACoTA/annotate_module/genome_seq_functions.py index dacb8c6ff9eecd0a78e98d92f60540f0a30e4771..1dc8f794dfebd8ab60167e084873001a8b5eda3c 100755 --- a/PanACoTA/annotate_module/genome_seq_functions.py +++ b/PanACoTA/annotate_module/genome_seq_functions.py @@ -21,6 +21,7 @@ import progressbar from PanACoTA import utils +logger = logging.getLogger("annotate.gseq_functions") def analyse_all_genomes(genomes, dbpath, tmp_path, nbn, soft, logger, quiet=False): """ @@ -454,10 +455,10 @@ def plot_distributions(genomes, res_path, listfile_base, l90, nbconts): nbcont_vals = [val for _, (_, _, _, _, val, _) in genomes.items()] outnbcont = os.path.join(res_path, "QC_nb-contigs-" + listfile_base + ".png") dist1 = utils.plot_distr(l90_vals, l90, "L90 distribution for all genomes", - "max L90 =") + "max L90 =", logger) dist2 = utils.plot_distr(nbcont_vals, nbconts, "Distribution of number of contigs among all genomes", - "max #contigs =") + "max #contigs =", logger) dist1.savefig(outl90) dist2.savefig(outnbcont) return l90_vals, nbcont_vals, dist1, dist2 diff --git a/PanACoTA/utils.py b/PanACoTA/utils.py index 11eee75f6007b6d32a09fec6ada4d44e85575d81..3654e6018f0f7d6d9d15471a38c72cf3b06f78f8 100755 --- a/PanACoTA/utils.py +++ b/PanACoTA/utils.py @@ -319,7 +319,7 @@ def run_cmd(cmd, error, eof=False, **kwargs): return call -def plot_distr(values, limit, title, text): +def plot_distr(values, limit, title, text, logger): """ Plot histogram of given 'values', and add a vertical line corresponding to the chosen 'limit' and return the mpl figure @@ -334,6 +334,8 @@ def plot_distr(values, limit, title, text): Title to give to plot text : str text to write near the vertical line representing the limit + logger : logging.Logger + logger object to write log information Returns ------- @@ -764,7 +766,7 @@ def read_genomes_info(list_file, name, date=None, logger=None): # If invalid values, warning message and ignore genome except ValueError: logger.warning(f"For genome {gname}, at least one of your columns 'gsize', " - "'nb_conts' or 'L90' contains a non numeric character. " + "'nb_conts' or 'L90' contains a non numeric value. " "This genome will be ignored.") continue # If no value for at least 1 field, warning message and ignore genome @@ -786,7 +788,11 @@ def read_genomes_info(list_file, name, date=None, logger=None): gfile = os.path.basename(gpath) gname = os.path.splitext(gfile)[0] genomes[gfile] = [gname, gpath, gpath, gsize, gcont, gl90] - logger.info(("Found {} genomes in total").format(len(genomes))) + if len(genomes) > 0: + logger.info(("Found {} genomes in total").format(len(genomes))) + else: + logger.error(f"no genome listed in {list_file} were found.") + sys.exit(1) return genomes