Code:
Seq_List=open('test.trunc..txt','r')#uses tab files from uniprot copied into notepad 250 work
data = Seq_List.readlines()
N, P = [], []
for line in data:
values = [str(s) for s in line.split()]
N.append(values[0])
P.append(values[1])
N.remove('Entry')
P.remove('Sequence')
print(P)
Sequencedict = {}
for key in N:
for value in P:
Sequencedict[key] = value
#P.remove(value)
break
print(Sequencedict)
print(Sequencedict.values())
def idr (P):
for i in P:
x= i.replace('Q','e').replace('R','b').replace('S','e').replace('T','e').replace('Y','e')]
#print(x)#gives the converted sequences
#print(type(x))#output x is a list
for g in x:
v=g.count('h')
#print(v)
y=g.count('e')+g.count('a')+g.count('b')
#print(y)
z=len(i)
#print(values)
#print(y/z)
if y/z>.10: #and v/z<.10: #e/tot>.60=sumo
print(i)
print(Sequencedict.keys())#reprint i and swap based of dict
print(v)
print(y)
print(y/z)
print('Disorder Promoting=Yes')
#else:
#print('Disorder Promoting=No')
idr (P)
Output:
['MSRTIVALILLGLAALA', 'MARFLVALALFGVVAMTAA', 'MARLFVAVALFGVVAFAAAEK']
{'P0CU41': 'MSRTIVALILLGLAALA', 'P0CU39': 'MSRTIVALILLGLAALA', 'P0CU40': 'MSRTIVALILLGLAALA'}
dict_values(['MSRTIVALILLGLAALA', 'MSRTIVALILLGLAALA', 'MSRTIVALILLGLAALA'])
MSRTIVALILLGLAALA
dict_keys(['P0CU41', 'P0CU39', 'P0CU40'])
14
3
0.17647058823529413
Disorder Promoting=Yes
MARFLVALALFGVVAMTAA
dict_keys(['P0CU41', 'P0CU39', 'P0CU40'])
17
2
0.10526315789473684
Disorder Promoting=Yes
MARLFVAVALFGVVAFAAAEK
dict_keys(['P0CU41', 'P0CU39', 'P0CU40'])
18
3
0.14285714285714285
Disorder Promoting=Yes写了一个通用程序,它将获取蛋白质名称和序列的选项卡文件,对序列执行一个函数,然后给我一个指定的输出。我遇到困难的地方是试图将字典嵌入的名称与特定于每个单独处理序列的条件"if“输出联系起来。如有任何帮助或建议,将不胜感激。
发布于 2020-08-31 03:58:23
我认为你的代码有一些问题。首先,我猜您希望将列表N中的第一个键与列表P中的第一个值组合在一起,然后将N中的第二个键与P中的第二个值组合起来,依此类推?您实际拥有的代码不能做到这一点。目前它只适用于每个键,P的第一个值。我建议将这些值压缩在一起:
Sequencedict = dict(zip(N,P))接下来,您可以将整个字典传递给您的函数并迭代这些项:
def idr(your_dictionary):
for key, value in your_dictionary.items():
value = value.replace('Q','e').replace('R','b').replace('S','e').replace('T','e').replace('Y','e')
v = value.count('h')
y = value.count('e')+value.count('a')+value.count('b')
z = len(value)
if y/z>.10:
print(value)
print(key)
print(v)
print(y)
print(y/z)
print('Disorder Promoting=Yes')
idr(Sequencedict)https://stackoverflow.com/questions/63660803
复制相似问题