[Tutor] Splitting text

Apparao Anakapalli appara_akp at yahoo.com
Thu Jun 29 21:45:06 CEST 2006


hello all:

I have a question and I do not know how I can work it
out. 


I have a file of sequences
>a
TCCCTGCGGCGCATGAGTGACTGGCGTATTTAGCCCGTCACATTTA'
>b
CCTGCGGCGCATGAGTGACTGGCGTATTTAGCCCGTCACAATTTAA'
....

(10 K)


pattern = 'ATTTA'

I want to find the pattern in the sequence and count.

For instance in 'a' there are two 'ATTTA's. 

How can I do that. 

One approach tried:
import re

pat = 'ATTTA'
if re.search(pat,a): 
         print 'yes'

By counting number of yeses I thought I can answer the
question. However, the above approach only looks for
the first instance of pat and says yes and moves to
next. 


The other way:
a.find(pat)

This also looks for first one and reports the position
of chracter. 


Could any one suggest the best way to cound the number
of patterns. 


Thank you
appu         


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list