Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread Sebastian Bassi
On 19 Sep 2005 12:25:16 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> >>> rs='AUGCUAGACGUGGAGUAG'
> >>> rs[12:15]='GAG'
> Traceback (most recent call last):
>   File "", line 1, in ?
> rs[12:15]='GAG'
> TypeError: object doesn't support slice assignment

You should try Biopython (www.biopython.org). There is a sequence
method you could try.





-- 
http://www.spreadfirefox.com/?q=affiliates&id=24672&t=1";>La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread jbperez808
right, i forgot about that...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote:
 rs='AUGCUAGACGUGGAGUAG'
 rs[12:15]='GAG'
> Traceback (most recent call last):
>   File "", line 1, in ?
> rs[12:15]='GAG'
> TypeError: object doesn't support slice assignment
> 
> You can't assign to a section of a sliced string in
> Python 2.3 and there doesn't seem to be mention of this
> as a Python 2.4 feature (don't have time to actually try
> 2.4 yet).

Strings are immutable in Python, which is why assignment to
slices won't work.

But why not use lists?

rs = list('AUGC...')
rs[12:15] = list('GAG')

Reinhold
-- 
http://mail.python.org/mailman/listinfo/python-list


slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread jbperez808
>>> rs='AUGCUAGACGUGGAGUAG'
>>> rs[12:15]='GAG'
Traceback (most recent call last):
  File "", line 1, in ?
rs[12:15]='GAG'
TypeError: object doesn't support slice assignment

You can't assign to a section of a sliced string in
Python 2.3 and there doesn't seem to be mention of this
as a Python 2.4 feature (don't have time to actually try
2.4 yet).

Q1. Does extended slicing make use of the Sequence protocol?
Q2. Don't strings also support the Sequence protcol?
Q3. Why then can't you make extended slicing assignment work
when dealing with strings?

This sort of operation (slicing/splicing of sequences represented
as strings) would seem to be a very fundamental oepration when doing
rna/dna/protein sequencing algorithms, and it would greatly enhance
Python's appeal to those doing bioinformatics work if the slicing
and extended slicing operators worked to their logical limit.

Doing a cursory search doesn't seem to reveal any current PEPs
dealing with extending the functionality of slicing/extended
slicing operators.

Syntax and feature-wise, is there a reason why Python can't kick
Perl's butt as the dominant language for bioinformatics and
eventually become the lingua franca of this fast-growing and
funding-rich field?

-- 
http://mail.python.org/mailman/listinfo/python-list