def test_plot_with_bokeh(tmpdir):
    gb_record = SeqIO.read(example_genbank, "genbank")
    record = BiopythonTranslator().translate_record(record=gb_record)
    plot = record.plot_with_bokeh(figure_width=8)
    target_file = os.path.join(str(tmpdir), "plot_with_bokeh.html")
    with open(target_file, "w+") as f:
        f.write(file_html(plot, CDN, "Example Sequence"))
    with open(target_file, "r") as f:
        assert len(f.read()) > 5000
def test_plot_with_bokeh_no_labels(tmpdir):
    """Bokeh has a problem with empty lists of labels."""
    gb_record = SeqIO.read(example_genbank, "genbank")
    record = BiopythonTranslator().translate_record(record=gb_record)
    for feature in record.features:
        feature.label = None
    plot = record.plot_with_bokeh(figure_width=8)
    target_file = os.path.join(str(tmpdir), "plot_with_bokeh.html")
    with open(target_file, "w+") as f:
        f.write(file_html(plot, CDN, "Example Sequence"))
    with open(target_file, "r") as f:
        assert len(f.read()) > 5000
Пример #3
0
"""Simple example with Bokeh output. Requires the Bokeh library installed.
"""

from dna_features_viewer import BiopythonTranslator
from bokeh.resources import CDN
from bokeh.embed import file_html

record = BiopythonTranslator().translate_record(record="example_sequence.gb")
plot = record.plot_with_bokeh(figure_width=8)

with open("plot_with_bokeh.html", "w+") as f:
    f.write(file_html(plot, CDN, "Example Sequence"))