diff --git a/libclusterseq/libclusterseq.py b/libclusterseq/libclusterseq.py index f0b1a69f69fc362c61fd195ed30e1d961a500085..ba663b0a71eaae7e6dd8f466f2b5c1970e3f81f3 100644 --- a/libclusterseq/libclusterseq.py +++ b/libclusterseq/libclusterseq.py @@ -200,11 +200,18 @@ def plot_score_density(scores, min_density_score, axis): # (maybe not the same one as obtained using scipy.stats.gaussian_kde) # rug=True plots small lines where a value exits # his=False disables default plotting of a histogram - if len(scores) < 100: - sns.distplot(scores, kde=True, rug=True, hist=False, ax=axis) - else: - # Figure too heavy when lots of rug lines - sns.distplot(scores, kde=True, rug=False, hist=False, ax=axis) + try: + if len(scores) < 100: + sns.distplot(scores, kde=True, rug=True, hist=False, ax=axis) + else: + # Figure too heavy when lots of rug lines + sns.distplot(scores, kde=True, rug=False, hist=False, ax=axis) + except RuntimeError as err: + if str(err) == "Selected KDE bandwidth is 0. Cannot estiamte density.": + logging.warn("%s\n" % str(err)) + sns.distplot(scores, kde=False, rug=False, hist=True, ax=axis) + else: + raise # Vertical bar at min_density_score, # indicating the estimated score of minimal density # which will be used as threshold to cut edges in the graph. @@ -225,7 +232,7 @@ def make_sequence_similarity_groups(in_fname, cell_dir): """ (score_graph, complete_graph) = build_similarity_graph(in_fname) if len(score_graph.nodes()) <= 2: - logging.debug( + logging.info( "Not enough sequences to make interesting groups for %s", in_fname) # TODO: Use percent similarity between the 2 sequences @@ -258,7 +265,7 @@ def make_sequence_similarity_groups(in_fname, cell_dir): plot_score_density(scores, min_density_score, axis) plt.savefig(out_plot) plt.close(fig) - logging.debug("Similarity score distribution plot: see %s", out_plot) + logging.info("Similarity score distribution plot: see %s", out_plot) ####################### # Splitting the graph # ####################### @@ -301,6 +308,7 @@ def split_fasta(in_fname, cell_id, cell_dir): logging.info("split_fasta: Creating %s", cell_dir) cell_dir.mkdir(parents=True, exist_ok=True) split_graph = make_sequence_similarity_groups(in_fname, cell_dir) + logging.info("Made sequence similarity groups for %s", cell_id) def compute_seq_num(node_set): """