Fix AttributeError: 'SeqFeature' object has no attribute 'strand' (Biopython >1.80 compatibility) #55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I've been using ISMapper for a large-scale analysis and encountered a crash when running it on a fresh conda installation.
Summary Recent versions of Biopython (v1.80+) have removed the .strand shortcut attribute from SeqFeature objects, causing ISMapper to crash with an AttributeError. The strand information must now be accessed via .location.strand.
I've performed a test with the documentation test genomes and the pipeline and strand column is now correct.
Environment
ISMapper Version: Installed from the bioconda channel.
BioPython Version: >1.80 (Automatically installed with fresh environment).
The Error When create_output.py attempts to read the strand of flanking genes, it fails because the SeqFeature object no longer exposes .strand directly.
AttributeError: 'SeqFeature' object has no attribute 'strand'Analysis
Initially, I attempted to patch this using getattr(feature, 'strand', None). While this prevented the crash, it resulted in data loss (all strand columns in the output table became None).
Further investigation confirmed that the attribute has been deprecated and moved. To maintain functionality and ensure correct output (1 for forward, -1 for reverse), the code must be updated to access the attribute from the feature's location.
Proposed Solution (Implemented)
I have updated create_output.py script to correctly access the strand information compatible with modern Biopython versions.
Original (Broken): self.left_strand = left_feature.strand
Fix: self.left_strand = left_feature.location.strand
This restores the correct 1 / -1 values in the final output table.