0
こんにちは私は現在、学校のための小さなプロジェクトに取り組んでいます。仕事は、DNA鎖と位置をとり、DNAが選択された位置の前後で補完的であるかどうかをチェックする関数を書くことです。 これは私がこれまでに思い付いたコードです。 translate関数は単に相補性をチェックするだけで、うまく機能します。 私はlis関数にDNAを供給しようとすると、エラーが発生します。TypeError: 'int'オブジェクトが呼び出し可能でないwhatsが間違っていますか?
File "xxx", line 37, in lis
while translate(dna[pos(1-i)],dna[pos(1+i)])=="TRUE":
TypeError: 'int' object is not callable
誰かが間違っていることを知っていますか?
def translate(seq, comp):
#matchlist and checklist
basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
baselist = ["A","T","G","C"]
#check wether the input is a DNA
if seq not in baselist:
print("FALSE")
elif comp not in baselist:
print("FALSE")
#check if the two (or more) bases are complements
else:
aaseq = []
comp = [comp]
for character in seq:
aaseq.append(basecomplement[character])
print(aaseq)
#print result
if aaseq == comp:
print("TRUE")
else:
print("FALSE")
def lis(dna, pos):
#make a list from DNA input
dna = [dna]
#go to pos in DNA list
for pos in range(len(dna)):
i=1
#check if position before and after pos are complements
#and advance a position if true else stop
while translate(dna[pos(1-i)],dna[pos(1+i)])=="TRUE":
i+=1
return(pos-i + pos+i)
break