finding homopolymers in both directions

2010-08-03 Thread Lee Sander
Hi, Suppose I have a string such as this 'aabccefghiiijkr' I would like to print out all the positions that are flanked by a run of symbols. So for example, I would like to the output for the above input as follows: 2 b 1 aa 2 b -1 cc 10 e -1 cc 11 f 1 g 17 h 1 iii 17

slicing a list but in downward fashion

2008-03-19 Thread Lee Sander
hi, i have a list and i can get elements form it via slicing L[start:stop] but sometimes the start is > stop i.e. I want to go in the opposite direction,eg L[10:2], mattab lets you do L(10:-1:2) to achive this, is there a way to do this in python? thanks L -- http://mail.python.org/mailman/listin

removing all instances of a certain value from a list

2008-03-19 Thread Lee Sander
Hi, I have a float array ( eg [-1.3, 1.22, 9.2, None, 2.3] ) but there are many missing vlaues which are represented as None. I would like to remove all such instances in one go. There is a remove function but it removes only the first instance, is there a delete/remove all function? thanks -- htt

regex that is equivalent to perl's syntax

2007-11-12 Thread Lee Sander
hi, does python's re library have a similar capability of the perls regular expression to search for pattern that appears a variable number of times within the lower and upper bounds given? For example, what is the python's equivalent to the following perl's search string? m/^\S{1,8}\.\S{0,3}/ whic

programmatically define a new variable on the fly

2007-08-09 Thread Lee Sander
Hi, I would like to define a new variable which is not predefined by me. For example, I want to create an array called "X%s" where "%s" is to be determined based on the data I am processing. So, for example, if I the file I'm reading has g 99 on the first line, I want to create a new variable cal

Re: mapping subintervals

2007-06-14 Thread Lee Sander
Dear Matteo and Nis, Thankyou very much for your help. I wasn't aware of the bisect library but it's really useful. thank you both once again Lee On 13 Jun, 23:21, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > Matteo skrev: > > > OK - I'm going to assume your intervals are inclusive (i.e. 34-51 > > c

mapping subintervals

2007-06-13 Thread Lee Sander
hi, I have the following problem which is turning out to be non-trivial. I realize that this is not exactly a python problem but more of an algorithm problem -- but I post it here because I want to implement this in python. I want to write a code that given an interval (integer tuple: start,stop)

Re: file reading by record separator (not line by line)

2007-05-31 Thread Lee Sander
I wanted to also say that this file is really huge, so I cannot just do a read() and then split on ">" to get a record thanks lee On May 31, 1:26 pm, Lee Sander <[EMAIL PROTECTED]> wrote: > Dear all, > I would like toreada really hugefilethat looks like this: > > &g

file reading by record separator (not line by line)

2007-05-31 Thread Lee Sander
Dear all, I would like to read a really huge file that looks like this: > name1 line_11 line_12 line_13 ... >name2 ... line_21 line_22 ... etc where line_ij is just a free form text on that line. how can i read file so that every time i do a "read()" i get exactly one record up to the next "