代码末尾的Python语法错误

代码末尾的Python语法错误,python,syntax-error,Python,Syntax Error,对于以下代码,我不断收到相同的错误: 如果我要删除print语句,则会出现类似的错误 File "./MIcalc.py", line 31 ^ SyntaxError: invalid syntax 我知道文件末尾有语法错误,但我不知道如何更正:/ 我使用的是Python2.7,第31行的任何代码都会出现错误 #!/usr/local/bin/python DIR = '/home/sbird/lobST

对于以下代码,我不断收到相同的错误:

如果我要删除print语句,则会出现类似的错误

File "./MIcalc.py", line 31

                                           ^
SyntaxError: invalid syntax
我知道文件末尾有语法错误,但我不知道如何更正:/

我使用的是Python2.7,第31行的任何代码都会出现错误

#!/usr/local/bin/python
DIR = '/home/sbird/lobSTR/output/output.txt'

def makeAlleleList(ALLREADS):
    alleleList = []
    ALLREADS_split = ALLREADS.split(";")
    allele = [x.split("|") for x in ALLREADS_split]
    [alleleList.append(x[0]) for x in allele]
    return alleleList

def makeCovThresh(ALLREADS):
    covThreshList = 0
    ALLREADS_split = ALLREADS.split(";")
    allele = [x.split("|") for x in ALLREADS_split]
    for x in allele:
            covThreshHold += int(x[1])
    return covThreshList

f = open("write_MI_out.txt","w")

for line in open(DIR):
    column = line.split("\t")
    ALLREADS = column[2].split("'")
    motherList = makeAlleleList(ALLREADS[1])
    fatherList = makeAlleleList(ALLREADS[3])
    sonList = makeAlleleList(ALLREADS[5])
    covThresh = makeCovThresh(ALLREADS[5])
    if len(sonList) < 3:
            if set(motherList) & set(fatherList) & set(sonList):
                    f.write("{0} \n".format(covThresh)
                    print "wrote to file"
f.close()
print "Fin."
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~    
#/usr/local/bin/python
DIR='/home/sbird/lobSTR/output/output.txt'
def列表(所有读取):
等位基因列表=[]
ALLREADS_split=ALLREADS.split(“;”)
等位基因=[x.split(“|”)表示ALLREADS_split中的x]
[等位基因列表。为等位基因中的x追加(x[0])]
返回等位基因列表
def makeCovThresh(所有读数):
covThreshList=0
ALLREADS_split=ALLREADS.split(“;”)
等位基因=[x.split(“|”)表示ALLREADS_split中的x]
对于x等位基因:
covThreshold+=int(x[1])
返回列表
f=打开(“write_MI_out.txt”,“w”)
对于打开的线路(DIR):
列=行。拆分(“\t”)
ALLREADS=列[2]。拆分(“”)
motherList=MakeAllegeList(所有读取[1])
父列表=生成等位基因列表(ALLREADS[3])
sonList=makeAllegeList(所有读取[5])
covThresh=makeCovThresh(ALLREADS[5])
如果len(sonList)<3:
如果设置(母列表)&设置(父列表)&设置(子列表):
f、 写入(“{0}\n.”格式(covThresh)
打印“写入文件”
f、 关闭()
打印“Fin”
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~    
这里缺少一个括号

                f.write("{0} \n".format(covThresh))

这就是你的问题-
做点什么
不是有效的Python代码。我曾经遇到过这样的情况:捕获到的错误说它们在某一行上,而实际上它们在上面所说的某一行或两行上。包括你的所有代码,至少从错误说Sam I缺少一个闭合括号的地方开始10行。我在vim中工作,是不是ust需要将代码重新写入另一个保存的文件中
                f.write("{0} \n".format(covThresh))