Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions nanoplotter/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import sys
import logging

# bring in kaleido and ensure Chrome is installed
import kaleido
# this will download a small headless Chrome build the first time you run it
kaleido.get_chrome_sync()

from kaleido import write_fig_sync

# Use Plotly's Chrome bootstrapper instead of kaleido
import plotly.io as pio
try:
# This should find or install a compatible Chrome in a user-writable location
pio.get_chrome()
except Exception as e:
logging.warning(
"Plotly could not fetch or find Chrome automatically. "
"Static exports may fail unless BROWSER_PATH is set. Details: %s", e
)

class Plot(object):
"""A Plot object is defined by a path to the output file and the title of the plot."""
Expand Down Expand Up @@ -56,7 +59,7 @@ def save(self, settings):
p = os.path.splitext(self.path)[0] + ".png"
if os.path.exists(p):
os.remove(p)
logging.warning("No static plots are saved due to some kaleido problem:")
logging.warning("No static plots are saved due to an export problem:")
logging.warning(e)

elif self.fig:
Expand Down Expand Up @@ -84,13 +87,13 @@ def show(self):

def save_static(self, figformat):
"""
Export a Plotly figure via Kaleido v1’s write_fig_sync.
Export a Plotly figure using Plotly's image writer.
"""
output_path = self.path.replace(".html", f".{figformat}")
try:
write_fig_sync(self.fig, path=output_path)
pio.write_image(self.fig, output_path, format=figformat)
logging.info(f"Saved {output_path} as {figformat}")
except Exception as e:
logging.warning("No static plots are saved due to some kaleido problem:")
logging.warning("No static plots are saved due to an export problem:")
logging.warning(e)

16 changes: 16 additions & 0 deletions scripts/agm_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

#SBATCH --time=04-00:00:00
#SBATCH --partition=defq
#SBATCH --mail-user=myemail@email.org
#SBATCH --mail-type=BEGIN,END,FAIL
#SBATCH --ntasks-per-node=64
#SBATCH --mem=128GB
#SBATCH --nodes=1
#SBATCH --job-name=nplot
#SBATCH --comment=nplot

source /path/to/nanoplot_env/bin/activate

# test fresh nanoplot with update
python /path/to/NanoPlot/nanoplot/NanoPlot.py --fastq /path/to/test_file.fastq.gz --verbose --minqual 4 --color red -o scripts/agm_tests
2 changes: 2 additions & 0 deletions scripts/agm_tests/LengthvsQualityScatterPlot_dot.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions scripts/agm_tests/LengthvsQualityScatterPlot_kde.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading