예제 #1
0
    base_number = 0
    total_bases = 0
    no_bases = 0
    with gzip.open(directory + '/' + output) as genos:
        for line in genos:
            Data = line.decode().strip('\n')  # Convert bytes into string
            l = Data.split('\t')
            sampleDepth = int(l[4])
            n = int(l[2])  # sample number
            total_bases += int(l[4])

            p = []
            if 1 in ploidy:
                haploid = l[9:11]
                haploid_sum = generics.log_or_zero(
                    sum(map(lambda x: generics.exp_or_zero(float(x)),
                            haploid)))
                p.append(haploid_sum)
            if 2 in ploidy:
                diploid = l[11:14]
                diploid_sum = generics.log_or_zero(
                    sum(map(lambda x: generics.exp_or_zero(float(x)),
                            diploid)))
                p.append(diploid_sum)
            if 3 in ploidy:
                triploid = l[14:18]
                triploid_sum = generics.log_or_zero(
                    sum(map(lambda x: generics.exp_or_zero(float(x)),
                            triploid)))
                p.append(triploid_sum)
            if 4 in ploidy:
예제 #2
0
                                index_of_X.append(index)
                        myReads.base=myReads.base.replace('X','')
                        #Remove all corresponding base qualities
                        count=0
                        for i in index_of_X:
                            myReads.base_quality = myReads.base_quality[:i-count] + myReads.base_quality[i+1-count:]
                            count+=1
                        #find sample depth of filtered data    
                        sampleDepth = len(myReads.base)
                        p=[] # list to fill with probabilities for this base

                        

                        if 1 in ploidy:
                            haploid = generics.calcGenoLogLike1_MajorMinor(myReads,mySite,major,minor)
                            haploid_sum = generics.log_or_zero(sum(map(lambda x,y: generics.exp_or_zero(x)*y,haploid,HWE_Prob_hap)))
                            p.append(haploid_sum)
                            
                        if 2 in ploidy:
                            diploid = generics.calcGenoLogLike2_MajorMinor(myReads,mySite,major,minor)
                            diploid_sum = generics.log_or_zero(sum(map(lambda x,y: generics.exp_or_zero(x)*y,diploid,HWE_Prob_dip)))
                            p.append(diploid_sum)

                        if 3 in ploidy:
                            triploid = generics.calcGenoLogLike3_MajorMinor(myReads,mySite,major,minor)
                            triploid_sum = generics.log_or_zero(sum(map(lambda x,y: generics.exp_or_zero(x)*y,triploid,HWE_Prob_tri)))
                            p.append(triploid_sum)

                        if 4 in ploidy:
                            tetraploid = generics.calcGenoLogLike4_MajorMinor(myReads,mySite,major,minor)
                            tetraploid_sum = generics.log_or_zero(sum(map(lambda x,y: generics.exp_or_zero(x)*y,tetraploid,HWE_Prob_tetra)))
예제 #3
0
                            myReads = Reads(base, qualities)
                            #find sample depth of filtered data
                            sampleDepth = len(myReads.base)
                            if sampleDepth > args.max_x_meandepth * meandepths[
                                    n - 1]:
                                sampleDepth = 0
                                myReads = Reads("", "")
                            p = [
                            ]  # list to fill with probabilities for this base

                            if 1 in ploidy:
                                haploid = generics.calcGenoLogLike1_MajorMinor(
                                    myReads, mySite, major, minor)
                                haploid = list(
                                    map(
                                        lambda x, y: generics.log_or_zero(
                                            generics.exp_or_zero(x) * y),
                                        haploid, HWE_Prob_hap))

                            if 2 in ploidy:
                                diploid = generics.calcGenoLogLike2_MajorMinor(
                                    myReads, mySite, major, minor)
                                diploid = list(
                                    map(
                                        lambda x, y: generics.log_or_zero(
                                            generics.exp_or_zero(x) * y),
                                        diploid, HWE_Prob_dip))

                            if 3 in ploidy:
                                triploid = generics.calcGenoLogLike3_MajorMinor(
                                    myReads, mySite, major, minor)
                                triploid = list(