-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmca_coding.py
executable file
·41 lines (30 loc) · 970 Bytes
/
mca_coding.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
41
#!/usr/bin/python
import os
import sys
import math
STANDARD_BASES = ['A', 'C', 'G', 'U']
BASE_EDGE_DECODE = {0: '', 1: 'W', 2: 'H', 3: 'S',
4: 'B', 5: 'O', 6: 'C'}
BPAIR_CONFIG_DECODE = {0: '', 1: 'cis', 2: 'trans'}
"""
def decode_contact(contact):
return BPAIR_CONFIG_DECODE[(contact>>1)&3] + \
BASE_EDGE_DECODE[(contact>>6)] + \
BASE_EDGE_DECODE[(contact>>3)&7]+ \
str(contact & 1)
"""
###
def decode_contact(contact):
return (BASE_EDGE_DECODE[contact >> 6],
BASE_EDGE_DECODE[(contact >> 3) & 7],
BPAIR_CONFIG_DECODE[(contact >> 1) & 3])
def decode_sequence(sequence):
return ''.join([STANDARD_BASES[(x>>6)-1] for x in sequence])
def is_std_contact(contact):
return (contact>>6) in [1,2,3] and \
((contact>>3)&7) in [1,2,3] and \
((contact>>1)&3) in [1,2]
###
def main(argv):
return None
if __name__ == '__main__': main(sys.argv[1:])