Skip to content

Commit

Permalink
Fix DeprecationWarning
Browse files Browse the repository at this point in the history
Remove `alpha` parameter.
  • Loading branch information
veghp committed Dec 17, 2022
1 parent 1ba99fd commit 58321ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
28 changes: 9 additions & 19 deletions dnachisel/reports/optimization_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

try:
import pandas

PANDAS_AVAILABLE = True
except ImportError:
PANDAS_AVAILABLE = False
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
15 changes: 3 additions & 12 deletions docs/_static/images/genbank_annotations/generate_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -28,7 +24,6 @@ def graphic_features_from_row(row):
else:
color = "#ededa7"
fontdict = dict(size=14, color="black", family="Ubuntu")


return [
dfv.GraphicFeature(
Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 58321ce

Please sign in to comment.