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
Post a Comment