-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrecode_suskoroger6.py
More file actions
32 lines (31 loc) · 960 Bytes
/
recode_suskoroger6.py
File metadata and controls
32 lines (31 loc) · 960 Bytes
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
#recode a FASTA alignment with 6-state Dayhoff
#bin1 = list('AGNPST')
#print bin1
import sys
from Bio import AlignIO
alignment = AlignIO.read(open(sys.argv[1]), "fasta")
for record in alignment:
seq = str(record.seq).upper()
recoded_seq = ''
for char in seq:
if char == '-':
recoded_seq += '-'
elif char in list('APST'):
recoded_seq += '1'
elif char in list('CW'):
recoded_seq += '2'
elif char in list('DEGN'):
recoded_seq += '3'
elif char in list('FHY'):
recoded_seq += '4'
elif char in list('ILMV'):
recoded_seq += '5'
elif char in list('KQR'):
recoded_seq += '6'
elif char == 'X':
recoded_seq += '-'
else:
print "Error: unrecognised aa in alignment: " + str(char)
quit()
print ">" + str(record.id) + "\n" + recoded_seq
#APST CW DEGN FHY ILMV KQR