parameters: (chromOrder, chromSizes, segmentSize, genomeRegion = None)
docstring: generate chromosome intervals no greater than segmentSize
  
      @param chromOrder - iterable object of chromosome names
      @param chromSizes - a hash of chrom sizes
      @param genomeRegion - optionally restrict chrom intervals to only cover a list of specified chromosome regions
  
      return chromIndex,chromLabel,start,end,chromSegment
      where start and end are formatted for use with samtools
      chromSegment is 0-indexed number of segment along each chromosome
docstring_summary: generate chromosome intervals no greater than segmentSize
docstring_tokens: generate chromosome intervals no greater than segmentSize
function: def getChromIntervals(chromOrder, chromSizes, segmentSize, genomeRegion = None) :
      """
      generate chromosome intervals no greater than segmentSize
  
      @param chromOrder - iterable object of chromosome names
      @param chromSizes - a hash of chrom sizes
      @param genomeRegion - optionally restrict chrom intervals to only cover a list of specified chromosome regions
  
      return chromIndex,chromLabel,start,end,chromSegment
      where start and end are formatted for use with samtools
      chromSegment is 0-indexed number of segment along each chromosome
      """
  
      for (chromIndex, chromLabel) in enumerate(chromOrder) :
          chromStart=1
          chromEnd=chromSizes[chromLabel]
  
          # adjust for the custom genome subsegment case:
          if genomeRegion is not None :
              if genomeRegion["chrom"] is not None :
                  if genomeRegion["chrom"] != chromLabel : continue
                  if genomeRegion["start"] is not None :
                      chromStart=genomeRegion["start"]
                  if genomeRegion["end"] is not None :
                      chromEnd=genomeRegion["end"]
  
          chromSize=(chromEnd-chromStart+1)
          chromSegments=1+((chromSize-1)/segmentSize)
          segmentBaseSize=chromSize/chromSegments
          nPlusOne=chromSize%chromSegments
          start=chromStart
          for i in xrange(chromSegments) :
              segSize=segmentBaseSize
              if i<nPlusOne : segSize += 1
              end=min(start+(segSize-1),chromStart+chromSize)
              yield (chromIndex,chromLabel,start,end,i,genomeRegion)
              start=end+1
function_tokens: def getChromIntervals ( chromOrder , chromSizes , segmentSize , genomeRegion = None ) : for ( chromIndex , chromLabel ) in enumerate ( chromOrder ) : chromStart = 1 chromEnd = chromSizes [ chromLabel ] # adjust for the custom genome subsegment case: if genomeRegion is not None : if genomeRegion [ "chrom" ] is not None : if genomeRegion [ "chrom" ] != chromLabel : continue if genomeRegion [ "start" ] is not None : chromStart = genomeRegion [ "start" ] if genomeRegion [ "end" ] is not None : chromEnd = genomeRegion [ "end" ] chromSize = ( chromEnd - chromStart + 1 ) chromSegments = 1 + ( ( chromSize - 1 ) / segmentSize ) segmentBaseSize = chromSize / chromSegments nPlusOne = chromSize % chromSegments start = chromStart for i in xrange ( chromSegments ) : segSize = segmentBaseSize if i < nPlusOne : segSize += 1 end = min ( start + ( segSize - 1 ) , chromStart + chromSize ) yield ( chromIndex , chromLabel , start , end , i , genomeRegion ) start = end + 1