Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with biopython 1.8.0 and bokeh 3 #74

Merged
merged 1 commit into from
Dec 17, 2022
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
4 changes: 2 additions & 2 deletions dna_features_viewer/GraphicRecord/BokehPlottableMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def plot_with_bokeh(self, figure_width=5, figure_height="auto", tools="auto"):

# BUILD THE PLOT ()
plot = figure(
plot_width=width,
plot_height=height,
width=width,
height=height,
tools=tools,
x_range=Range1d(0, self.sequence_length),
y_range=Range1d(-1, max_y + 1),
Expand Down
16 changes: 12 additions & 4 deletions dna_features_viewer/biotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ def reverse_complement(sequence):
return complement(sequence)[::-1]


aa_short_to_long_form_dict = {
_aa1: _aa3[0] + _aa3[1:].lower() for (_aa1, _aa3) in zip(aa1 + "*", aa3 + ["*"])
}
if type(aa1) is str and type(aa3) is list:
# biopython before 1.8.0
aa_short_to_long_form_dict = {
_aa1: _aa3[0] + _aa3[1:].lower() for (_aa1, _aa3) in zip(aa1 + "*", aa3 + ["*"])
}
else:
# biopython 1.8.0 and later
# relevant commit: https://github.com/biopython/biopython/commit/257143be9196b77619d3d8cadc22039212681e08
aa_short_to_long_form_dict = {
_aa1: _aa3[0] + _aa3[1:].lower() for (_aa1, _aa3) in zip(aa1 + ('*',), aa3 + ('*',))
}


def translate(dna_sequence, long_form=False):
Expand Down Expand Up @@ -123,7 +131,7 @@ def load_record(path, filetype=None):


def annotate_biopython_record(
seqrecord, location="full", feature_type="misc_feature", margin=0, **qualifiers
seqrecord, location="full", feature_type="misc_feature", margin=0, **qualifiers
):
"""Add a feature to a Biopython SeqRecord.

Expand Down