Exemplo n.º 1
0
def Main():
    args=ArgParse()

    # initiate genome object from UCSC genome browser
    chromInfo=Genome(db=args.genome).chromInfo
    
    chroms={}
    sum_size=0
    sum_size_list=[]
    #store chromInfo 
    for i in range(chromInfo.count()):
        try: 
            if "random" in chromInfo[i].chrom: continue
            chroms[chromInfo[i].chrom]=chromInfo[i].size
            sum_size+=chromInfo[i].size
            sum_size_list.append((chromInfo[i].chrom,sum_size))
        except:
            break
    print >> sys.stderr, sum_size_list[-1][1]
    print >> sys.stderr, chroms
    
    print >>sys.stderr, "Chromosome information readed, %d chromosomes"%(len(chroms))
    i=0
    while i < args.num:
        # randomly select one chromosome and a region in this chromosome
        chrom=random_chr(sum_size_list)
        size=chroms[chrom]
        length=int(gauss(args.mean,args.sd))
        start=randrange(1,size-length-1)
        end=start+length-1
        strand=choice(['+','-'])
        print "\t".join(str(f) for f in [chrom,start,end,i+1,0,strand])
        i=i+1
Exemplo n.º 2
0
def Main():
    args = ArgParse()

    # initiate genome object from UCSC genome browser
    chromInfo = Genome(db=args.genome).chromInfo

    chroms = {}
    sum_size = 0
    sum_size_list = []
    #store chromInfo
    for i in range(chromInfo.count()):
        try:
            if "random" in chromInfo[i].chrom: continue
            chroms[chromInfo[i].chrom] = chromInfo[i].size
            sum_size += chromInfo[i].size
            sum_size_list.append((chromInfo[i].chrom, sum_size))
        except:
            break
    print >> sys.stderr, sum_size_list[-1][1]
    print >> sys.stderr, chroms

    print >> sys.stderr, "Chromosome information readed, %d chromosomes" % (
        len(chroms))
    i = 0
    while i < args.num:
        # randomly select one chromosome and a region in this chromosome
        chrom = random_chr(sum_size_list)
        size = chroms[chrom]
        length = int(gauss(args.mean, args.sd))
        start = randrange(1, size - length - 1)
        end = start + length - 1
        strand = choice(['+', '-'])
        print "\t".join(str(f) for f in [chrom, start, end, i + 1, 0, strand])
        i = i + 1