-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetAminoAcidCount.py
More file actions
54 lines (46 loc) · 1.42 KB
/
getAminoAcidCount.py
File metadata and controls
54 lines (46 loc) · 1.42 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#YuEnoch 30-07-2024
#getAminoAcidCount.py
#Purpose: takes in peptide data and calculates the Amino Acid Counts at each poition
#Changes across Experiments: please alter on parameters.txt
# 1. Location of Mutagenesis
# 2. Mutagenesis for 5 Amino Acids
import sys
import re
import mod575
import gzip
import os
from collections import defaultdict
#Opens the necessary files for Input and Output
number = sys.argv[1]
n_mer = int(sys.argv[2])
input = open(number+"_peptide", 'r')
AAFile = open(number+"_AACount", 'w')
AA_list=open('AA.txt','r')
AA=dict()
codons=dict()
for line in AA_list: #AA.txt -> Reference NNK Frequencies
line=line.strip()
row=line.split()
aa=str(row[0])
AA[aa]=0
codons[aa]=row[1]
for i in range(n_mer):
globals()['AA%s' % i] = AA.copy()
for line in input:
line=line.strip()
row=line.split()
peptide=row[0]
count=int(row[1])
for i in range(n_mer):
if peptide[i] in globals()['AA%s' % i]:
globals()['AA%s' % i][peptide[i]]+=count
else:
globals()['AA%s' % i][peptide[i]] = count
for aa in sorted(AA):
data=number+'\t'+aa
for i in range(n_mer):
data = data + '\t' + str(globals()['AA%s' % i][aa])
data = data + '\t' + str(codons[aa])
print(data, file=AAFile)
#The Frequency of Amino Acid A in Position 1, 2, 3, 4, 5, and the NNK standard
AAFile.close()