Skip to content

Commit

Permalink
Implement a custom PlotException when a plot fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Colelyman committed Sep 30, 2024
1 parent e5abdc3 commit 2bb9ae5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -5174,6 +5174,10 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
print_stacktrace_if_debug()
error('Filtering error, please check your input.\n\nERROR: %s' % e)
sys.exit(13)
except CRISPRessoShared.PlotException as e:
print_stacktrace_if_debug()
error(e)
sys.exit(14)
except Exception as e:
print_stacktrace_if_debug()
error('Unexpected error, please check your input.\n\nERROR: %s' % e)
Expand Down
5 changes: 4 additions & 1 deletion CRISPResso2/CRISPRessoMultiProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import pandas as pd
import traceback

from CRISPResso2.CRISPRessoShared import PlotException


def get_max_processes():
return mp.cpu_count()

Expand Down Expand Up @@ -315,6 +318,6 @@ def run_plot(plot_func, plot_args, num_processes, process_futures, process_pool,
except Exception as e:
if halt_on_plot_fail:
logger.critical(f"Plot error, halting execution \n")
raise e
raise PlotException(f'There was an error generating plot {plot_func.__name__}.')
logger.warn(f"Plot error {e}, skipping plot \n")
logger.debug(traceback.format_exc())
1 change: 0 additions & 1 deletion CRISPResso2/CRISPRessoPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,6 @@ def prep_alleles_table(df_alleles, reference_seq, MAX_N_ROWS, MIN_FREQUENCY):
"""
dna_to_numbers={'-':0,'A':1,'T':2,'C':3,'G':4,'N':5}
seq_to_numbers= lambda seq: [dna_to_numbers[x] for x in seq]

X=[]
annot=[]
y_labels=[]
Expand Down
6 changes: 6 additions & 0 deletions CRISPResso2/CRISPRessoShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ class OutputFolderIncompleteException(Exception):
class InstallationException(Exception):
pass


class InputFileFormatException(Exception):
pass


class PlotException(Exception):
pass


#########################################

class StatusFormatter(logging.Formatter):
Expand Down

0 comments on commit 2bb9ae5

Please sign in to comment.