-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGivenAll2outputReturnSequenceVariability.py
executable file
·66 lines (56 loc) · 2 KB
/
GivenAll2outputReturnSequenceVariability.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 20 September 2021
# Author : Rafael Borges
# Objective: Given Dubious and Resolved log files from SLIDER_VENOM with residues and their RSCC,
# return variability of sequences
# USAGE: GivenDubiousResolvedResiduesReturnSequenceVariability.py Dubious.log Resolved.log OutputFile
# OutputFile should be a new path
# RETURNS: a file with amino acid possibilities (line) by residue number (column)
from __future__ import print_function
import sys,os #,time
inputAll2 = sys.argv[1]
outfile = sys.argv[2]
with open (inputAll2) as f: frAll2=f.readlines()
dicall={}
vrscc1=0.0
for l in frAll2[1:]:
l=l.split()
if len(l)>1:
if l[3]!='BaselineMainChain':
#print(l)
# try:
ch=l[0]
resn=int(l[1])
restype=l[2][0]
vrscc2=float(l[3])
#print (vrscc1,vrscc2)
if ch not in dicall: dicall[ch]={}
if resn not in dicall[ch]: dicall[ch][resn]=[]
if vrscc1<vrscc2: vrscc1=float(vrscc2)
if restype not in dicall[ch][resn] and vrscc1-vrscc2<3.0:
dicall[ch][resn].append(restype)
#print (dicall[ch])
#time.sleep(1)
# except:
# pass
# exit()
else: vrscc1=0.0
if len(dicall)>1:
dicall['all']={}
for ch in dicall:
for resn in dicall[ch]:
if resn not in dicall['all']: dicall['all'][resn]=[]
for restype in dicall[ch][resn]:
if restype not in dicall['all'][resn]: dicall['all'][resn].append(restype)
with open(outfile,'w') as fo:
for ch in dicall:
if len(dicall)>1: fo.write('>'+ch+'\n')
variabN=0
for resn in dicall[ch]:
if len(dicall[ch][resn])>variabN: variabN=len(dicall[ch][resn])
for i in range(variabN):
for resn in sorted(dicall[ch]):
try: fo.write(dicall[ch][resn][i])
except: fo.write(' ')
fo.write('\n')