[Biopython-dev] Improving the Alignment object

Michiel de Hoon mdehoon at c2b2.columbia.edu
Sat Jul 28 03:10:06 UTC 2007


Peter wrote:
> Perhaps we could have a "dictionary like" sub class of Alignment where 
> the __getitem__ method would allow a record identifier in place of a row 
> index:
> 
> print aln["P3454"]
> print aln["P3454", 20]
> 
> instead or as well as:
> 
> print aln[10]
> print aln[10, 20]

"as well as" would break if a user decides to use an integer as a key in 
the dictionary. A safer approach would be to define a method 
specifically for dictionary-like access. Something like:

print aln[10]
print aln[10,20]

for list-like access, and

print aln.get("P3454")

for dictionary-like access.

--Michiel.



More information about the Biopython-dev mailing list