Exemple #1
0
 def BinsFromBigWig(bwfile,binsize):
     ''' Read bins from BigWig file.'''
     Bins={}
     chroms=Utils.getBigWigChroms(bwfile)
     for chrom in chroms:
         Bins[chrom]=numpy.zeros(chroms[chrom]/binsize)
         for start,stop,val in IO.BigWigReader(bwfile,chrom):
             Bins[chrom][start/binsize]=val
     return Bins
Exemple #2
0
# ------------------------------------
# Classes
# ------------------------------------

# ------------------------------------
# Main
# ------------------------------------

if __name__ == "__main__":
    # Get parameters
    args = argParser()
    # genome={}
    # for line in IO.ColumnReader(args.genome):
    #    genome[line[0]]=int(line[1])
    genome = Utils.genomeSize(args.genome)
    counts = {}
    gsize = float(sum(genome.values()))
    # number of Beds in each chrom
    for chrom in genome:
        counts[chrom] = int(genome[chrom] / gsize * args.number + 0.5)
    # check number
    diff = sum(counts.values()) - args.number
    chroms = counts.keys()
    chroms.sort()
    if diff != 0:
        for i in diff > 0 and range(diff) or range(diff, 0):
            j = randint(1, len(counts))
            counts[chroms[j - 1]] += diff > 0 and -1 or 1
    # generate Beds
    cnt = 1