# HG changeset patch # User cpt # Date 1719548172 0 # Node ID 318248986ee7264fe4a19ed7394ac52f4394ec5e # Parent b79e98299a78e3c0ba64f4c0854664780518c3e8 planemo upload commit 4c7a6921e41a04d27f3ac202732bb5fb86801904-dirty diff -r b79e98299a78 -r 318248986ee7 dna_features_viewer/GraphicRecord/GraphicRecord.py --- a/dna_features_viewer/GraphicRecord/GraphicRecord.py Fri Jun 28 03:17:21 2024 +0000 +++ b/dna_features_viewer/GraphicRecord/GraphicRecord.py Fri Jun 28 04:16:12 2024 +0000 @@ -3,7 +3,15 @@ from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord from Bio.SeqFeature import FeatureLocation, SeqFeature -from Bio.Alphabet import DNAAlphabet + +try: + # Biopython <1.78 + from Bio.Alphabet import DNAAlphabet + + has_dna_alphabet = True +except ImportError: + # Biopython >=1.78 + has_dna_alphabet = False from .MatplotlibPlottableMixin import MatplotlibPlottableMixin from .BokehPlottableMixin import BokehPlottableMixin @@ -123,7 +131,10 @@ for f in self.features ] if not isinstance(sequence, Seq): - sequence = Seq(sequence, alphabet=DNAAlphabet()) + if has_dna_alphabet: + sequence = Seq(sequence, alphabet=DNAAlphabet()) + else: + sequence = Seq(sequence) return SeqRecord(seq=sequence, features=features) def crop(self, window): @@ -138,9 +149,11 @@ new_features.append(cropped_feature) return GraphicRecord( - sequence=self.sequence[start - first_index : end - first_index] - if self.sequence is not None - else None, + sequence=( + self.sequence[start - first_index : end - first_index] + if self.sequence is not None + else None + ), sequence_length=end - start, features=new_features, feature_level_height=self.feature_level_height,