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

Try to fix detection of clustering diffs.

parent 7b63a9e2
No related branches found
No related tags found
No related merge requests found
__copyright__ = "Copyright (C) 2022 Blaise Li" __copyright__ = "Copyright (C) 2022 Blaise Li"
__licence__ = "GNU GPLv3" __licence__ = "GNU GPLv3"
__version__ = "0.26" __version__ = "0.27"
from .libcodonusage import ( from .libcodonusage import (
aa2colour, aa2colour,
aa_usage, aa_usage,
......
...@@ -21,7 +21,8 @@ from pathlib import Path ...@@ -21,7 +21,8 @@ from pathlib import Path
# python3 -m pip install cytoolz # python3 -m pip install cytoolz
from cytoolz import concat, groupby, unique from cytoolz import concat, groupby, unique
# To render mardown in a Jupyter notebook on gitlab # To render mardown in a Jupyter notebook on gitlab
from IPython.core.display import display, HTML from IPython.display import display
from IPython.core.display import HTML
# python3 -m pip install markdown # python3 -m pip install markdown
from markdown import markdown from markdown import markdown
# Basic plotting library for Python # Basic plotting library for Python
...@@ -67,6 +68,7 @@ fmt_metadata = { ...@@ -67,6 +68,7 @@ fmt_metadata = {
"Title": "Distribution of standardized codon usages biases (by aa), by chromosome"} "Title": "Distribution of standardized codon usages biases (by aa), by chromosome"}
} }
def render_md(md_str): def render_md(md_str):
""" """
Render a markdown string *md_str* in a Jupyter notebook. Render a markdown string *md_str* in a Jupyter notebook.
...@@ -112,7 +114,7 @@ nuc2colour = dict(zip(nuc_alphabet, nuc_colours)) ...@@ -112,7 +114,7 @@ nuc2colour = dict(zip(nuc_alphabet, nuc_colours))
def load_counts_table( def load_counts_table(
table_path, index_col="old_locus_tag", index_unique=True): table_path, index_col="old_locus_tag", index_unique=True):
""" """
Load a table or pre-computed codon counts at *table_path*. Load a table of pre-computed codon counts at *table_path*.
The lines correspond to genes. The lines correspond to genes.
Besides the columns containing the counts for each codon, Besides the columns containing the counts for each codon,
...@@ -933,7 +935,9 @@ def compare_clusterings( ...@@ -933,7 +935,9 @@ def compare_clusterings(
for (clust_1, clust_2) in combinations(cluster_names, 2): for (clust_1, clust_2) in combinations(cluster_names, 2):
# assert crosstabs[aa][clust_1][clust_2] == 0 # assert crosstabs[aa][clust_1][clust_2] == 0
try: try:
if crosstabs[aa][clust_1][clust_2] != 0: # if crosstabs[aa][clust_1][clust_2] != 0:
if (crosstabs[aa][clust_1][clust_2] != 0) \
or (crosstabs[aa][clust_2][clust_1] != 0):
same_clusters = False same_clusters = False
except KeyError: except KeyError:
# At least one cluster is absent. # At least one cluster is absent.
......
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