0
我有一個用於創建序列的FASTA文件的程序。修改python中的字符列表
input=['ARIMALTHNAEYSDSFTAL','ARIMFLTHNFEYSESFTAL','AHIMNPTENAEYHESFTAL','AHIMNPTENTEYWDSFTAL','AHIMNDTHNFEYHDSFTAL','AHIMNDTNNTEYWESFTAL','ARIMFDTENAEYHDSFTAL','AHIMADTNNTEYWDSFTAL','ARIMFLTENTEYHESFTAL']
l = len(input[0])
my_residues = [set() for _ in xrange(l)]
for h in input:
for i, x in enumerate(h):
my_residues[i].add(x)
my_residues = [list(x) for x in my_residues]
print my_residues
這會給這樣
[['A'], ['H', 'R'], ['I'], ['M'], ['A', 'N', 'F'], ['P', 'L', 'D'], ['T'], ['H', 'E', 'N'], ['N'], ['A', 'T', 'F'], ['E'], ['Y'], ['H', 'S', 'W'], ['E', 'D'], ['S'], ['F'], ['T'], ['A'], ['L']]
輸出,但我想以這樣的方式,所有的氨基酸殘基有一組,如果它包含一個以上的殘留輸出。 所以輸出應該是這樣的:
[['A'], ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'], ['I'], ['M'], ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'], ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'], ['T'], ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'],...... ['F'], ['T'], ['A'], ['L']]
它不是充分殘留 – user2151414 2013-04-11 09:40:47
@ user2151414:你必須ENL讓我們知道如何獲得完整的殘留物;例如,您的輸入樣本不包含「C」。它只是一個我們可以硬編碼的列表嗎? – 2013-04-11 09:41:51
許多殘基將在輸入中不存在,但在輸出中,如果該位置是可變的,則每個殘基應該在那裏 – user2151414 2013-04-11 09:47:14