From 58321ce018318935ee28f448b2c051d4b00f370e Mon Sep 17 00:00:00 2001 From: Peter Vegh Date: Sat, 17 Dec 2022 20:00:14 +0000 Subject: [PATCH] Fix DeprecationWarning Remove `alpha` parameter. --- dnachisel/reports/optimization_reports.py | 28 ++++++------------- .../generate_annotations.py | 15 ++-------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/dnachisel/reports/optimization_reports.py b/dnachisel/reports/optimization_reports.py index afd04fc..627363c 100644 --- a/dnachisel/reports/optimization_reports.py +++ b/dnachisel/reports/optimization_reports.py @@ -20,6 +20,7 @@ try: import pandas + PANDAS_AVAILABLE = True except ImportError: PANDAS_AVAILABLE = False @@ -78,9 +79,7 @@ def ReportWriter(*a, **kw): ) -def write_no_solution_report( - target, problem, error, file_content=None, file_path=None -): +def write_no_solution_report(target, problem, error, file_content=None, file_path=None): """Write a report on incompatibility found in the problem's constraints. The report comprises a PDF of plots of the sequence (global constraints, @@ -129,18 +128,15 @@ def write_no_solution_report( if error.location is None: raise error start, end, strand = error.location.to_tuple() - ax.fill_between( - [start, end], -10, 10, zorder=-1000, facecolor="#ffcccc" - ) + ax.fill_between([start, end], -10, 10, zorder=-1000, facecolor="#ffcccc") title = "\n".join( textwrap.wrap( - "No solution found in zone [%d, %d]:%s" - % (start, end, str(error)), + "No solution found in zone [%d, %d]:%s" % (start, end, str(error)), width=120, ) ) ax.set_title(title, fontdict=TITLE_FONTDICT) - pdf_io.savefig(ax.figure, bbox_inches="tight", alpha=0.5) + pdf_io.savefig(ax.figure, bbox_inches="tight") plt.close(ax.figure) # CREATE AND SAVE THE LOCAL CONSTRAINTS BREACHES RECORD @@ -166,9 +162,7 @@ def is_in_focus(location): label_prefix="BREACH", locations_filter=is_in_focus ) SeqIO.write( - record, - root._file("local_constraints_breaches.gb").open("w"), - "genbank", + record, root._file("local_constraints_breaches.gb").open("w"), "genbank", ) # CREATE A FIGURE OF THE LOCAL CONSTRAINTS BREACHES AS A NEW PDF PAGE @@ -184,7 +178,7 @@ def is_in_focus(location): fontdict=TITLE_FONTDICT, ) ax.set_ylim(top=ax.get_ylim()[1] + 1) - pdf_io.savefig(ax.figure, bbox_inches="tight", alpha=0.5) + pdf_io.savefig(ax.figure, bbox_inches="tight") plt.close(ax.figure) root._file("logs.txt").write(problem.logger.dump_logs()) @@ -373,9 +367,7 @@ def write_optimization_report( problem=problem, constraints_evaluations=constraints_evaluations ) filename = "constraints_before_and_after.csv" - constraints_before_after.to_csv( - root._file(filename).open("w"), index=False - ) + constraints_before_after.to_csv(root._file(filename).open("w"), index=False) # GENERATE AND SAVE THE OBJECTIVES SUMMARY @@ -415,9 +407,7 @@ def write_optimization_report( label_prefix="Breach from", merge_overlapping=True ) record.features += breaches_locations - SeqIO.write( - record, root._file("final_sequence_with_edits.gb").open("w"), "genbank" - ) + SeqIO.write(record, root._file("final_sequence_with_edits.gb").open("w"), "genbank") # CREATE THE "FINAL SEQUENCE" REPORT diff --git a/docs/_static/images/genbank_annotations/generate_annotations.py b/docs/_static/images/genbank_annotations/generate_annotations.py index fa14f60..0f5b4f6 100644 --- a/docs/_static/images/genbank_annotations/generate_annotations.py +++ b/docs/_static/images/genbank_annotations/generate_annotations.py @@ -14,11 +14,7 @@ def parse_locations(s): if "," not in s: start, end = map(int, s.strip().strip("+").split("-")) return [(start, end, 1 if s.endswith("+") else 0)] - return [ - location - for sub in s.split(",") - for location in parse_locations(sub) - ] + return [location for sub in s.split(",") for location in parse_locations(sub)] def graphic_features_from_row(row): @@ -28,7 +24,6 @@ def graphic_features_from_row(row): else: color = "#ededa7" fontdict = dict(size=14, color="black", family="Ubuntu") - return [ dfv.GraphicFeature( @@ -58,9 +53,7 @@ def plot_row_feature(row): if row.highlights != "none": for (start, end, _) in parse_locations(row.highlights): - ax.fill_between( - [start - 0.5, end - 0.5], -0.9, -0.5, facecolor="r", alpha=0.15 - ) + ax.fill_between([start - 0.5, end - 0.5], -0.9, -0.5, facecolor="r") ax.set_ylim(top=0.7) ax.figure.set_figheight(1) return ax @@ -69,7 +62,5 @@ def plot_row_feature(row): data = pandas.read_csv("./examples.csv") for i, row in tqdm.tqdm(list(data.iterrows())): ax = plot_row_feature(row) - ax.figure.savefig( - "./%s.png" % row.filename, bbox_inches="tight", dpi=120 - ) + ax.figure.savefig("./%s.png" % row.filename, bbox_inches="tight", dpi=120) plt.close(ax.figure)