比较两个DNA序列以注释差异

时间:2016-10-18 14:42:02

标签: python alignment

我正在尝试采用两个DNA序列并尝试比较它们以确定差异(如果有的话),特别是缺失或插入。

我收到列表索引超出范围的错误。

  

错误:   Traceback(最近一次调用最后一次):     文件“/ Users / DiegoJaime / Desktop / MuSK_Fc Alignment_copy.py”,第59行,in       GeneSort('FL_MuSK.txt','FL_MuSK_Fc.txt')     在GeneSort中输入文件“/ Users / DiegoJaime / Desktop / MuSK_Fc Alignment_copy.py”,第49行       print('删除网站\ n开始:%s:结束:%s'%(string1 [0],string2 [-1]))   IndexError:列表索引超出范围

                def GeneSort(inFileName1, inFileName2):
                in1= inFileName1
                masterlist1 = open(in1, 'r')
                in2 = inFileName2
                masterlist2 = open(in2, 'r')

            # Output file of gene names for GO searches
                Overlap= 'OverlapGenes.txt'
                GeneListOutput= open(Overlap, 'w')

                nt1= ''
                nt2=''
                for line1 in masterlist1:
                    line1= line1.strip()
                    nt1+= line1


                for line2 in masterlist2:
                    line2=line2.strip()
                    nt2+=line2

                i = 0
                string1 = []
                while i < len(nt2)-1:
                    if nt1[i] != nt2[i]:
                        string1.append(i)


                    i += 1

                print('%d  :  %d' %(len(nt1), len(nt2)))


                j= len(nt2)-1
                i= len(nt1)-1
                string2 = []
                count=0
                while count < len(nt2)-1:

                    if nt1[i] == nt2[j]:

                        string2.append(i)

                        j = j-1
                        i = i-1
                    count +=1


                print( 'Site of deletion\nStart: %s : End: %s' %(string1[0],string2[-1]))



            GeneSort( 'FL_MuSK.txt', 'FL_MuSK_Fc.txt')

0 个答案:

没有答案