Entering edit mode
8.6 years ago
nchuang
▴
260
Hi,
How do I initialize an empty MultipleSeqAlignment object?
from Bio import AlignIO, SeqIO from Bio.Seq import Seq empty_align = MultipleSeqAlignment([])
Gives me "not defined" error
this whole library import thing is a little bit confusing.
How come I can't do
also according to their documentation they do it completely differently including only calling MultipleSeqAlignment without the Bio.Align in front?
oh yea and it works thank you!
Well spotted - the
Bio.Align
example didn't make it explicit we expected you to do:That's been fixed ready for the next release: https://github.com/biopython/biopython/commit/009d913ac2d8ed010db20aa43eab489e0031d9dd
So the short version is that to use a class or function you either need to define it in the same file or import it from somewhere else. In this case class MultipleSeqAlign is defined in module Bio.Align. So you can get it two ways
which then allows you to use MultipleSeqAlign (and only MultipleSeqAlign) from that module with no prefix, or
which gives you access to everything defined in Bio.Align, but you need to use the full name, like Bio.Align.MultipleSeqAlign.
So that's why my version was different from the others. I think in that example you found, though, they are missing the correct import statement. They either forgot or it's implied that you've already imported MultipleSeqAlign.
thank you! really appreciate you guys teaching me little things like this!
I also realized that the MultipleSeqAlignment object is not compatible with AlignIO's read object. I can't add them to each other.