[Biopython-dev] syntax of indices for future Alignment object

Peter biopython-dev at maubp.freeserve.co.uk
Fri Jul 27 08:18:21 EDT 2007


Jan Kosinski wrote:
> Hi,
> 
>  From the viewpoint of the enduser we would like python Alignment object
> to behave outside as an array so we could get slices, columns,
> sequences, their fragments, whatever we want etc. The most intuitive and
> clear (certainly much better than not very clear indexes like
> [xxx:yyy:zzz]) for the  user is the following.
> 
> [A:B][X:Y] - general syntax of indices. This supports almost everything.

I think Michiel and I were suggesting [A:B,X:Y] or rather [A:B:C,X:Y:Z] 
to be fully general, rather than [A:B][X:Y] or [A:B:C][X:Y:Z]

i.e. [arg1, arg2] rather than [arg1][arg2]

This is an important point, as in the first case the __getitem__ method 
of the alignment is called once (with both arguments). In the second 
case, the __getitem__ method is called with arg1, and may return a 
SeqRecord or an alignment - and this object's __getitem__ method is 
called with arg2.

As written, many of your cases appear to be impossible - but using the 
[arg1,arg2] we can get close.

I've got a working bit of code put together now which I'll attached to 
bug 1944 soon.

http://bugzilla.open-bio.org/show_bug.cgi?id=1944

Peter



More information about the Biopython-dev mailing list