python - how to : multiline to oneline by removing newlines -


i'm newbie in python starting learn it.

i wanted make script count same letter pattern in text file. problem text file has multiple lines. couldn't find of patterns went on next line.

my file , pattern dna sequence.

example:

'attctcgatcagtctctctagtgtgtgagagactctagctagatcgtccactcactgac**ga  tc**agtcagt**gatc**tctcctactacaaggtgacatgagtgtaaattagtgtgagtgagtgaa' 

i'm looking 'gatc'. second 1 counted, first wasn't.

so, how can make file 1 line text file?

you can join lines when read pattern file:

    fd = open('dna.txt', 'r')     dnatext = ''.join(fd.readlines())     dnatext.count('gatc') 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -