Esempio n. 1
0
 def for_interval(cls, interval):
     """ Return all snps within an interval """
     query = sql.and_(cls.table.c.chromStart >= interval.start,
                      cls.table.c.chromEnd <= interval.end,
                      cls.table.c.chrom == interval.chrom,
                      cls.table.c.bin == bin(interval.start, interval.end))
     return session.query(cls).filter(query).all()
Esempio n. 2
0
 def for_interval(cls, interval):
     """ Return all snps within an interval """
     query = sql.and_(cls.table.c.chromStart>=interval.start,
         cls.table.c.chromEnd<=interval.end,
         cls.table.c.chrom==interval.chrom,
         cls.table.c.bin==bin(interval.start, interval.end)
     )
     return session.query(cls).filter(query).all()
Esempio n. 3
0
    def clock(self):
        """Executes one clock cycle"""
        # choose the device that will write on the bus
        eligible = [x for\
                x in self.replying\
                if len(x) > 0 \
                and x not in self.waiting]
        eligible += [x for\
                x in self.requesting\
                if len(x) > 0 \
                and (x.read().function != "load"
                     or x.read().dst not in self.waiting)
                ]
        chosen = self.arbiter.choose(eligible)

        if chosen in self.requesting:
            # obtain the message to transmit
            self.message = chosen.request.read()

            # append the address of the device it comes from
            src = bin(self.requesting.index(chosen), self.src_len)
            for c in reversed(src):
                self.message.src.append(c)

            # obtain the address of the device that should receive it
            self.address = ""
            for i in xrange(self.dst_len):
                self.address += self.message.dst.pop()

            # now that the message is ready, we try to transmit it
            try:
                self.replying[int(self.address,2)].request.write(message)
            except:
                return # too bad, try again some other time !

            # the message is transmitted, we can update the arbiter and
            # add the device to the waiting queue
            self.waiting.extend([x for x in self.requesting]) # TODO
        else:
            # appending
            src = bin(self.replying.index(chosen), self.dst_len)
            for c in reversed(src):
                self.message.dst.append(c)
            # obtain the address
            for i in xrange(self.dst_len):
                self.address += self.message.src.pop()
Esempio n. 4
0
 def for_interval(cls, interval):
     """ return all links that overlap the specified interval"""
     clause = sql.and_(
         cls.bin==bin(interval.start, interval.end),
         cls.tStart <= interval.end,
         cls.tEnd >= interval.start,
         cls.tName == interval.chrom,
     )
     return session.query(cls).filter(clause).all()
Esempio n. 5
0
 def for_interval(cls, interval):
     """ return all links that overlap the specified interval"""
     clause = sql.and_(
         cls.bin == bin(interval.start, interval.end),
         cls.tStart <= interval.end,
         cls.tEnd >= interval.start,
         cls.tName == interval.chrom,
     )
     return session.query(cls).filter(clause).all()