def read_entry(self):
     # Find our current lowest range
     output = []
     for i in self.buffers:
         output.append([])
     rngs = [x.get_range() for x in self.buffers if x]
     #print rngs
     if len(rngs) == 0: return None
     srngs = sorted(rngs, key=lambda x: (x.chr, x.start, x.end))
     mrngs = merge_ranges(srngs)
     current_range = mrngs[0]
     #print current_range.get_range_string()
     got_overlap = True
     while got_overlap == True:
         got_overlap = False
         for i in range(0, len(self.buffers)):
             if not self.buffers[i]: continue  #end of this one
             v = self.buffers[i].get_range().cmp(current_range)
             if v == 0:
                 got_overlap = True
                 if self.buffers[i].get_range().overlaps(current_range):
                     current_range = current_range.merge(
                         self.buffers[i].get_range())
                 output[i].append(self.buffers[i])
                 self.buffers[i] = self.streams[i].read_entry()
                 #print str([len(x) for x in output])+"\t"+current_range.get_range_string()
             #print str(i)+":"+str(v)
     current_range.set_payload(output)
     return current_range
Ejemplo n.º 2
0
 def read_entry(self):
     # Find our current lowest range
     output = []
     for i in self.buffers:
         output.append([])
     rngs = [x.get_range() for x in self.buffers if x]
     # print rngs
     if len(rngs) == 0:
         return None
     srngs = sorted(rngs, key=lambda x: (x.chr, x.start, x.end))
     mrngs = merge_ranges(srngs)
     current_range = mrngs[0]
     # print current_range.get_range_string()
     got_overlap = True
     while got_overlap == True:
         got_overlap = False
         for i in range(0, len(self.buffers)):
             if not self.buffers[i]:
                 continue  # end of this one
             v = self.buffers[i].get_range().cmp(current_range)
             if v == 0:
                 got_overlap = True
                 if self.buffers[i].get_range().overlaps(current_range):
                     current_range = current_range.merge(self.buffers[i].get_range())
                 output[i].append(self.buffers[i])
                 self.buffers[i] = self.streams[i].read_entry()
                 # print str([len(x) for x in output])+"\t"+current_range.get_range_string()
             # print str(i)+":"+str(v)
     current_range.set_payload(output)
     return current_range
Ejemplo n.º 3
0
 def union(self,tx2): # keep direction and name of self
   all = []
   for rng1 in [x.rng for x in self.exons]:
     for rng2 in [y.rng for y in tx2.exons]:
       u = rng1.union(rng2)
       if u: all.append(u)
   if len(all) == 0: return None
   rngs = merge_ranges(all)
   tx = Transcript()
   tx.set_exons_and_junctions_from_ranges(rngs)
   tx._direction = self._direction
   tx._transcript_name = self._transcript_name
   tx._gene_name = self._gene_name
   return tx
 def union(self, tx2):  # keep direction and name of self
     self._initialize()
     all = []
     for rng1 in [x.rng for x in self.exons]:
         for rng2 in [y.rng for y in tx2.exons]:
             u = rng1.union(rng2)
             if u: all.append(u)
     if len(all) == 0: return None
     rngs = merge_ranges(all)
     tx = Transcript()
     tx.set_exons_and_junctions_from_ranges(rngs)
     tx._direction = self._direction
     tx._transcript_name = self._transcript_name
     tx._gene_name = self._gene_name
     return tx