Mercurial > repos > cpt > cpt_linear_genome_plot
changeset 4:318248986ee7 draft
planemo upload commit 4c7a6921e41a04d27f3ac202732bb5fb86801904-dirty
author | cpt |
---|---|
date | Fri, 28 Jun 2024 04:16:12 +0000 |
parents | b79e98299a78 |
children | a3d67997b07a |
files | dna_features_viewer/GraphicRecord/GraphicRecord.py |
diffstat | 1 files changed, 18 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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,