[Biopython-dev] slicing in Bio.PDB.Chain.__getitem__() ?
Peter Cock
p.j.a.cock at googlemail.com
Mon Dec 5 10:45:29 UTC 2011
2011/12/2 Hongbo Zhu 朱宏博 <macrozhu at gmail.com>:
> Hi, Joao,
>
> thanks for the response. When I spoke of slicing Bio.PDB.Chain, I meant to
> slice it using residue id, not list index. And these two ways are
> fundamentally different.
>
> For instance :
>
> not only slicing like this:
> or
> chain.child_list[2:12] # slice using list index
>
> but also slicing like this:
>
> chain[2:12] # slice using residue sequence id, not feasible at the moment
> # NOTE: this is fundamentally different from
> chain.child_list[2:12]
> or even:
> chain[(' ', 2, ' ') : (' ', 12, ' ')] # slice using residue full id, even
> better
>
> Of course one can play with child_list and obtain the same outcome. But I
> think it would be very convenient to implement it in the __getitem__()
> function.
>
> cheers,hongbo
Hi Hongbo,
I agree defining integer based slicing of Chain objects sounds like a good idea.
Could you write a couple of unit tests for the new slicing please (in
file Tests/test_PDB.py)? You can just give code snippets, a patch, or
create a branch on github it you would prefer.
Does it make sense to consider __add__ for the Chain as well?
Peter
More information about the Biopython-dev
mailing list