搜索SAM文件时,运算符大于和小于运算符

时间:2017-02-17 01:54:47

标签: python compare mapping bioinformatics

我似乎遇到了一些我正在处理的代码问题。

基本上我试图将SAM文件中的一堆读取映射到我从gff3文件中获取的各自功能。

我正在浏览sam文件中的每一行并拉出染色体并开始读取,然后将其与我试图将其映射到的功能的开头和结尾进行比较(在这种情况下) ORFs)。

这一切都在for循环中完成,其中包含许多if语句和for循环。

我遇到的主要问题是由于某种原因,我的位置工作不正常。我正在查看sam的行并逐行检查,如果读取的起始位置在功能的开始和结束之间,并且是否正在执行其他一些操作。

但是,根据我的操作,代码不会返回任何位于要素中的内容,也不会随意将内容分配给要素。它似乎没有正确地比较它们。

我尝试了几种不同的方法来比较数字,甚至强迫它们在不同的位置ints,它给了我以下两个中的一个(出现在代码之后)。

我希望有人能帮助我弄清楚我做错了什么。

这是我的代码

sam=open("qiseqalignCGD.sam", "r")

for sam:

#print line

if "M0" in line:

    if "ChrA" in line:

        chrom=line.split()[2]#is it in chrom

        startlocation=line.split()[3] #where it is mapping to start

        if startlocation in ChromAcountingStorage: #look for duplicates
            count=0
        else:

            if chrom == "ChrA_C_glabrata_CBS138":  #for this one if it is in chrom A
                for i in featureschromA: #cycles through the features
                    countchromAfeaturekey+=1
                    insert=int(startlocation)
                    beginning=int(featureschromA[i][1])
                    end=int(featureschromA[i][0])
                    #print type(end)

                    if beginning <= insert and insert <= end: #checks if it is between that gene
                        #print "true" + "\t" + (featureschromA[i][0]) + "\t" + startlocation +"\t"+featureschromA[i][1]

                        if i in ChromAcountingUnique:
                            ChromAcountingUnique[i]+=1

                        else:
                            ChromAcountingUnique.update({i:01}) #counts how many times that key has appeared before then adds it to that keys value""

                        ChromAcountinglist.append(i)


                        ChromAcountingStorage.append(startlocation)
                        #print ChromAcountingStorage
                        count=0
                    else:
                         #print "false" + "\t" + featureschromA[i][0] + "\t" + startlocation +"\t"+featureschromA[i][1]
                         stall=0
                    countchromAfeaturekey=0  #resets the counter

结果示例 中间数字是我想要映射的读数。左边的数字是开始,右边的数字是特征的结尾

false 67119 78299 70367

false 69627 78299 70612

false 70937 78299 71320

false 73333 78299 73623

false 74737 78299 76560

false 77494 78299 81497

false 80753 78299 85553

false 84864 78299 86594

false 86383 78299 87887

false 87716 78299 90471

false 90297 78299 92857

粗体的那个应该是真的,但仍然是假的

其他时候,如果我尝试将它们转换为其他地方的int,我会得到类似的东西

false 465618 77756 469181

false 469405 77756 472212

false 470353 77756 480145

true 1608 78299 2636

false 2671 78299 4809

false 11697 78299 13042

看似随机的一个被称为真

有人有任何可能的解释吗?

0 个答案:

没有答案
相关问题