結果ファイルの重複を排除するようにコードを書き込もうとしています。これは、「N/A」の行とその下の行です。これが私が持っているものです:
with open('false_'+uniprotID+'.txt','w') as fileinput:
for index, (start, end) in enumerate(searchPFAM(fname)):
for item in lookup[uniprotID]:
for names in wholelookup[uniprotID]:
if re.search(r'\d+',names).group(0)==item and start <= int(item) <= end:
result = str(int(item) - start + 1)
try:
fileinput.write(">{0} | at position {1} | start= {2}, end= {3} | description: {4}\n".format(uniprotID, result, start, end, names))
fileinput.write(''.join(makeList[start-1:end]))
textwrap.wrap(''.join(makeList[start-1:end]),width = 60)
fileinput.write('\n')
except ErrorIO as e:
break
else:
fileinput.write(">{0} | N/A | start= {1}, end= {2} | description: {3} \n".format(uniprotID, start, end, names))
fileinput.write(''.join(makeList[start-1:end]))
textwrap.wrap(''.join(makeList[start-1:end]),width = 60)
fileinput.write('\n')
結果ファイルは次のようになります。
Q14591 | 位置4で| start = 174、end = 196 | 説明:A177T
YQCRHCSKSFSQRSDLVKHQRIH
Q14591 | 該当なし| start = 174、end = 196 | 説明:M418T
YQCRHCSKSFSQRSDLVKHQRIH
Q14591 | 21位| start = 398、end = 420 | 説明:M418T YACSDCTKSFSRRSDLVKHQRIH
Q14591 | 該当なし| start = 398、end = 420 | 説明:M418T
YACSDCTKSFSRRSDLVKHQRIH