Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_n(file):
- """
- amount of N
- """
- f = open(file, 'r')
- text = f.read()
- text = text.replace('\r', '')
- text = text.replace('\n', '')
- f.close()
- l = len(text)
- n = text.count('N')
- print('total length =', l)
- print('#N =', n)
- print("it's", round(n / l * 100, 3), '%')
- def count_repeatitions(file):
- """
- повторы длины >= 1000
- """
- f = open(file, 'r')
- text = f.read()
- text = text.replace('\r', '')
- text = text.replace('\n', '')
- f.close()
- ans = 0
- l_curr = 0
- for ch in text:
- if ch != 'N':
- if l_curr >= 1000:
- ans += 1
- l_curr = 0
- else:
- l_curr += 1
- if l_curr >= 1000:
- ans += 1
- print('amount of repetitions with len >= 1000 is', ans)
- file = 'sequence.fasta'
- count_n(file)
- count_repeatitions(file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement