[Biopython-dev] Improving the Alignment object

Peter biopython-dev at maubp.freeserve.co.uk
Sat Jul 28 13:14:43 UTC 2007


Michiel de Hoon wrote:
> Peter wrote:
>>> For instance, the Alignment object should
>>> support changing characters in the alignment without a need of copying 
>>> it (using  aln[a,x] = "D"). Can it be done now with Alignment which is 
>>> a list of SeqRecord objects with sequences implemented as immutable Seq 
>>> objects ?
> ....
>> To me the obvious way to handle this is to have a MutableAlignment 
>> sub-class, where editing individual elements with aln[r,c] = "D" would 
>> be supported (possibly implemented using the MutableSeq class internally 
>> rather than the immutable Seq class).
>>
> I don't think we'd need a separate MutableAlignment for that. An 
> Alignment is a list of sequences and is therefore mutable. If we add a 
> __setitem__ method to the Alignment class, then this method can take 
> care of constructing a new sequence and put it in the appropriate row.
> 
So rather than editing one character of a MutableSeq, we could replace 
one immutable Seq object with a new immutable Seq object where one 
character was different? That would work - sounds a little slow, but 
certainly possible.

Peter




More information about the Biopython-dev mailing list