Advertisement
beautifulnofer

Untitled

Mar 2nd, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. gen = ''
  2. f = open('sequence.fasta', 'r')
  3. f = f.readlines()
  4. for i in range(0,len(f)):
  5.     if (i % 10000 == 0):
  6.         print(f'{i} strings passed')
  7.     f[i] = f[i][:len(f[i])-1]
  8.     gen += f[i]
  9. print(f'Total len is {len(gen)}')
  10. print(f'Amount of N is {gen.count("N")}')
  11.  
  12. e = []
  13. gen += 'g'
  14. last = 0
  15. for i in range(1, len(gen)):
  16.     if (gen[i] == 'N' and gen[i-1] != 'N'):
  17.         last = i
  18.     elif (gen[i] != 'N' and gen[i-1] == 'N'):
  19.         e.append(i - last)
  20. e.sort()
  21. ans = 0
  22. min_len = 1000
  23. for i in e:
  24.     if i >= min_len:
  25.         ans += 1
  26. print(f'{ans} strings of N are longer than {min_len}')
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement