我想輸出makeList [start]的索引到makeList [end]。我有所有正確的開始和結束值,總共約11對。但是,我沒有得到正確的輸出,因爲它沒有打印出所有可能的輸出。爲什麼會發生?我輸出文件中的數據沒有打印出應該有的所有結果
def searchPFAM(fname):
with open(fname,'rb') as f:
root = etree.parse(f)
for lcn in root.xpath("/protein/match[@dbname='PFAM']/lcn"):
try:
start = int(lcn.get("start"))
end = int(lcn.get("end"))
yield start, end
except (TypeError , ValueError) as e:
pass
uniprotID ='Q14591'
def createRef():
fileInput = open(uniprotID +'.txt','r')
readAA = fileInput.read()
store_value = (readAA.partition('\n'))
aaSequence = store_value[2].replace('\n', '')
makeList = list(aaSequence)
return makeList
makeList = createRef()
for start, end in searchPFAM(fname):
print start, end
if start <= end:
with open('newfile.txt','w') as fileinput:
while start <= end:
result = makeList[start]
fileinput.write(result)
start += 1
這個作品謝謝 – 2012-07-12 19:58:49
沒問題。樂意效勞。有時候,這些簡單的東西坐在那裏盯着你,他們很難看到/跟蹤。祝你好運。 – mgilson 2012-07-12 19:59:46