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

Jan Kosinski kosa at genesilico.pl
Fri Jul 27 10:47:10 UTC 2007


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.

Several examples of usage and proposed outputs:

[:][:] - returns an alignment or its copy (as Alignment object)

[:][x:y] - returns slice of the alignment (as Alignment object; aln of
all sequences and residues corresponding to columns from x and y)

[a:b][:] - returns the aln of seqs from a to b (as Alignment object)

[a:b][x:y] - returns the slice and subalignment (as Alignment object)

[a:a][x:y] - returns slice of the single sequence (residues x to y of
sequence a) (as Alignment object)
[a][x:y] - returns slice of the single sequence (residues x to y of
sequence a) (as a String)

[a:][x:y] and similar combinations - returns the slice and subalignment,
sequences from a to the last are included (as Alignment object)

[:][x] - returns single column (as a String object? string here could be
very useful)

[:][x:x] - returns single column (as Alignment object)

[a] - returns single sequence (as a SeqRecord object)
[a:a] and [a:a][:] - returns single sequence (as Alignment object)

[m][n] - returns n-th element of sequence m (as a String)

Disputable could be that different but similar sets of indices return
different types of objects (ex. [:][x] would return a column as string
while [:][x:x] would return a column as Alignment object, but in my
opinion it would just extend the usability).

The only problem is an implementation of such calls but it depends on 
what type of object the Alignment object will be.

What do you think?

Cheers,
Jan Kosinski
Grzegorz Papaj


:.




More information about the Biopython-dev mailing list