예제 #1
0
 def testPow(self):
     x = interval.Interval([-1, 2])
     z = x ** 3
     self.assertEqual(z.x, [-1,8])
     z = x ** 4
     self.assertEqual(z.x, [0,16])
예제 #2
0
 def testSin(self):
     x = interval.Interval([-math.pi/6, 2])
     z = interval.sin(x)
     for i in range(len(z.x)):
         self.assertAlmostEqual(z.x[i], [-0.5,1][i])
예제 #3
0
 def testAdd(self):
     x = interval.Interval([-1, 2])
     y = interval.Interval([1, 2])
     z = x + y
     self.assertEqual(z.x, [0, 4])
예제 #4
0
 def testSub(self):
     x = interval.Interval([-1, 2])
     y = interval.Interval([1, 2])
     z = y - x
     self.assertEqual(z.x, [-1, 3])
예제 #5
0
    intronic[chrom].difference_update( pc_exons[chrom] )
    intronic[chrom].difference_update( other_ens[chrom] )

UTRs = pc_exons
for chrom in chroms:
    UTRs[chrom].difference_update( CDS[chrom] )

old_idi_id=""; cuff_coords=interval(); firsttime=True; cuff_present=False
for line in cuff:
    la = line.rstrip('\n').split('\t')
    idi_id = la[8].split('";')[0].split('"')[1]
    if (not firsttime) and (not idi_id == old_idi_id):
        old_idi_id = idi_id
        if ens_here and cuff_present:
            cuff_exons[chrom].update( cuff_coords )
            cuff_introns_here = interval.IntervalSet([interval.Interval( cuff_exons[chrom].lower_bound(), cuff_exons[chrom].upper_bound() )])
            cuff_introns_here.difference_update( cuff_exons[chrom] )
            cuff_introns[chrom].update(cuff_introns_here)
        cuff_coords=interval.IntervalSet([])
        ens_here = False
        cuff_present = False
    firsttime = False
    chrom = la[0]
    if la[1] == "Cufflinks":
        cuff_coords.add( interval.Interval(min( map(int,la[3:5]) ), max( map(int,la[3:5]) )) )
        cuff_present=True
    else:
        ens_here = True
if ens_here and cuff_present:   # accounting for the final iteration
    cuff_exons[chrom].update( cuff_coords )
    cuff_introns_here = interval.IntervalSet([interval.Interval( cuff_exons[chrom].lower_bound(), cuff_exons[chrom].upper_bound() )])
예제 #6
0
 'ab1': binary.Ab1(),
 'axt': sequence.Axt(),
 'bam': binary.Bam(),
 'bed': interval.Bed(),
 'binseq.zip': binary.Binseq(),
 'blastxml': xml.BlastXml(),
 'coverage': coverage.LastzCoverage(),
 'customtrack': interval.CustomTrack(),
 'csfasta': sequence.csFasta(),
 'fasta': sequence.Fasta(),
 'fastq': sequence.Fastq(),
 'fastqsanger': sequence.FastqSanger(),
 'gff': interval.Gff(),
 'gff3': interval.Gff3(),
 'genetrack': tracks.GeneTrack(),
 'interval': interval.Interval(),
 'laj': images.Laj(),
 'lav': sequence.Lav(),
 'maf': sequence.Maf(),
 'pileup': tabular.Pileup(),
 'qualsolid': qualityscore.QualityScoreSOLiD(),
 'qualsolexa': qualityscore.QualityScoreSolexa(),
 'qual454': qualityscore.QualityScore454(),
 'sam': tabular.Sam(),
 'scf': binary.Scf(),
 'sff': binary.Sff(),
 'tabular': tabular.Tabular(),
 'taxonomy': tabular.Taxonomy(),
 'txt': data.Text(),
 'txtseq.zip': data.Txtseq(),
 'wig': interval.Wiggle()
예제 #7
0
 def __init__(self, value, x):
     Expr.__init__(self)
     self.L = 0
     self.value = value
     self.range = interval.Interval([value, value])
     self.x = x
예제 #8
0
 def getbnd(self):
     hl = 0.5 * (self.x[1] - self.x[0])
     bnd = interval.Interval(
         [self.value - self.L * hl, self.value + self.L * hl])
     self.range.intersec(bnd)
     return bnd
예제 #9
0
def pijav_bnb(problem, eps, solinfo, maxsteps):
    """
    Pijavsky method enhanced with slopes
    :param problem: problem to solver
    :param eps: tolerance
    :param solinfo: obtained solution
    :return: actual steps performed
    """
    class Sub:
        def __init__(self, s1, s2, ival):
            self.s1 = s1
            self.s2 = s2
            self.ival = ival
            a = ival[0]
            b = ival[1]
            La = s1.S[0]
            Lb = s2.S[1]
            va = s1.value
            vb = s2.value
            self.c = (vb - va + La * a - Lb * b) / (La - Lb)
            self.bound = va + La * (self.c - a)
            boundcheck = vb + Lb * (self.c - b)
            if abs(self.bound - boundcheck) > 0.01:
                print("bound = ", self.bound, ", check ", boundcheck)
                print("a = ", a, ", b = ", b, ", va = ", va, ", vb = ", vb,
                      ", La = ", La, ", Lb = ", Lb)
                print("s1 = ", s1)
                print("s2 = ", s2)

        def bnd(self):
            return self.bound

        def __repr__(self):
            return "s1 = " + str(self.s1) + ", s2 = " + str(self.s2) + ", interval = " + str(self.ival)\
                    + "c =" + str(self.c) + ", bound = " + str(self.bound)

    f = smp.lambdify(problem.xvar, problem.fexpr)
    fslp = smp.lambdify(problem.xvar, problem.fexpr, slp)
    P = []
    ival = interval.Interval(problem.range)
    s1 = fslp(slp.Slope(ival, ival[0]))
    s2 = fslp(slp.Slope(ival, ival[1]))
    P.append(Sub(s1, s2, ival))
    fr = solinfo.value
    steps = 0

    # Expr.flagRecompRange = True
    while len(P) > 0 and steps <= maxsteps:
        steps = steps + 1
        sub = P.pop(0)
        if fr - sub.bnd() > eps:
            x1 = interval.Interval([sub.ival[0], sub.c])
            x2 = interval.Interval([sub.c, sub.ival[1]])

            # ns = fslp(slp.Slope(sub.ival, sub.c))
            # ns1 = ns
            # ns2 = ns

            ns1 = fslp(slp.Slope(x1, sub.c))
            ns2 = fslp(slp.Slope(x2, sub.c))

            # print("at ", sub.c, " ns = ", ns)
            if ns1.value < fr:
                fr = ns1.value
                xr = sub.c
            P.append(Sub(sub.s1, ns1, x1))
            P.append(Sub(ns2, sub.s2, x2))
    solinfo.value = fr
    solinfo.x = xr
    return steps
예제 #10
0
def intervalize(par):
    return [ival.Interval(e) for e in par]
예제 #11
0
파일: r5.py 프로젝트: mposypkin/paving
def mkconst(val):
    return ival.Interval([val, val])