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 :
buf
>>> 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
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
slas
On Thu, Aug 5, 2010 at 10:07 AM, Vikram K 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 enumerate(seq):
if
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 wrote:
> On Thu, Aug 5, 2010 at 1
On Thu, Aug 5, 2010 at 10:07 AM, Vikram K 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 what is the