Skip to content
Snippets Groups Projects
Commit 0a16ef10 authored by Blaise Li's avatar Blaise Li
Browse files

More logging, catching exception.

parent 344accb5
No related branches found
No related tags found
No related merge requests found
......@@ -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):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment