[Biopython-dev] slicing in Bio.PDB.Chain.__getitem__() ?
Peter Cock
p.j.a.cock at googlemail.com
Mon Dec 5 12:15:55 UTC 2011
On Mon, Dec 5, 2011 at 11:46 AM, Hongbo Zhu 朱宏博 <macrozhu at gmail.com> wrote:
> Hi, Peter,
>
> I just realized a special issue concerning slicing Bio.PDB.Chain.
> Normally, in python a slice is given by three arguments: start, stop and
> step, where the element at position *stop* is not included in the output.
> For example,
>
> mylist[2:40:1] would return: [ mylist[2],mylist[3], ...., mylist[39] ]
>
Yes,
> But in CATH and SCOP, sequence segments composing domains
> are given as start and end position. And the residue at the end
> position is also included in the domain definition.
OK. I'd have to double check what our parsers return (and if
they convert the start/end into C/Python style).
> e.g. if a domain
> is defined to be from residue (' ', 1, ' ') to residue (' ', 40, ' '), a slicing
> like this mychain[(' ', 2, ' '): (' ', 40, ' ')] or mychain[2:40] would not
> include residue (' ',40,' ').
Perhaps I misunderstood - I would not want to allow the syntax
mychain[(' ', 2, ' '): (' ', 40, ' ')] which is unclear, rather only allow
the user to use mychain[2:41] which requires Python counting.
Peter
More information about the Biopython-dev
mailing list