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

Add markdown rendered for Jupyter notebook.

parent afe708f0
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@ from .libcodonusage import (
aa2colour,
columns_by_aa,
load_bias_table,
render_md,
violin_usage,
violin_usage_vertical,
violin_usage_by_clusters,
......
......@@ -17,6 +17,10 @@
import json
from operator import itemgetter
from pathlib import Path
# To render mardown in a Jupyter notebook on gitlab
from IPython.core.display import display, HTML
# python3 -m pip install markdown
from markdown import markdown
# Basic plotting library for Python
# python3 -m pip install matplotlib
# See https://matplotlib.org/
......@@ -39,6 +43,16 @@ import pandas as pd
# python3 -m pip install cytoolz
from cytoolz import groupby
def render_md(md_str):
"""
Render a markdown string *md_str* in a Jupyter notebook.
More direct rendering is not possible on gitlab for security reasons.
"""
display(HTML(markdown(md_str)))
codon2aa = CodonTable.load(11).codon_dict()
# Column headers made from (aa, codon) pairs
codon_headers = pd.MultiIndex.from_tuples(
......@@ -62,6 +76,8 @@ with Path(bgraphs.colorschemes._scheme_dir).joinpath(
# value: hexadecimal html colour code
aa2colour = {**colscheme["colors"], "*": '#000000'}
def load_counts_table(table_path, index_col="old_locus_tag"):
codon_counts = pd.read_table(table_path, index_col=index_col)
def load_bias_table(table_path, nb_cluster_series=2):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment