-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmch.py
executable file
·40 lines (30 loc) · 870 Bytes
/
mmch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/python3
import sys
import argparse
import signal
import math
import tools
def main(args):
_, rna = next(tools.io.read_fasta(sys.stdin))
rna = ''.join(rna)
a = rna.count('A')
u = rna.count('U')
c = rna.count('C')
g = rna.count('G')
# if there are n, m bonding bases (n <= m)
# then there are n! / (n-m)! different basepairs
#
def cnt(m, n):
m, n = sorted([m, n])
return math.factorial(n) // math.factorial(n-m)
print(cnt(a, u) * cnt(c, g))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='description',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
args = parser.parse_args()
try:
main(args)
except BrokenPipeError:
sys.exit(128 + signal.SIGPIPE)
except KeyboardInterrupt:
sys.exit(128 + signal.SIGINT)