Re: [BangPypers] string to list query

2010-08-05 Thread Nitin Kumar
Below answer from Navin if good one, to make it more complex :) you can use z 'AT/CG' re.split('[A-Z]/[A-Z]',z) ['A', 'G'] re.search('[A-Z]/[A-Z]',z).group() 'T/C' using these two you can get your answer On Thu, Aug 5, 2010 at 10:15 AM, Navin Kabra navin.ka...@gmail.com wrote: On Thu, Aug

Re: [BangPypers] string to list query

2010-08-05 Thread Baiju M
On Thu, Aug 5, 2010 at 10:07 AM, Vikram K kpguy1...@gmail.com wrote: Suppose i have this string: z = 'AT/CG' How do i get this list: zlist = ['A','T/C','G'] One solution, please verify: def group_seq(seq): seq_out = [] skip = 0 seq_len = len(seq) for i,char in

Re: [BangPypers] string to list query

2010-08-05 Thread Baiju M
Simplified: def group_seq(seq): seq_out = [] slash_found = False for char in seq: if slash_found: seq_out[-1] = seq_out[-1]+char slash_found = False continue if char == '/': seq_out[-1] = seq_out[-1]+char

Re: [BangPypers] string to list query

2010-08-05 Thread Anand Balachandran Pillai
s='AT/CG' m=re.compile(r'([A-Z]+)([A-Z]/[A-Z])([A-Z]+)', re.IGNORECASE) m.match(s).groups() ('A', 'T/C', 'G') --Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] string to list query

2010-08-05 Thread Dhananjay Nene
Here's a slightly different approach def splitter(input): buffer = [] slash = False for char in input : if len(buffer) == 0 : buffer.append(char) elif char == '/' : buffer.append(char) slash = True elif slash :

[BangPypers] string to list query

2010-08-04 Thread Vikram K
Suppose i have this string: z = 'AT/CG' How do i get this list: zlist = ['A','T/C','G'] ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] string to list query

2010-08-04 Thread Navin Kabra
On Thu, Aug 5, 2010 at 10:07 AM, Vikram K kpguy1...@gmail.com wrote: Suppose i have this string: z = 'AT/CG' How do i get this list: zlist = ['A','T/C','G'] This is a very poorly specified question. And in absence of any information about what exactly are the constraints on the input, and