def get_genome_coordinates(fnwig=None,resolution=100):
    """Get genome locations from a wig file to annotate"""
    
    #for Celegans
    standard_chroms={'I':'chrI','II':'chrII','III':'chrIII','IV':'chrIV','V':'chrV','M':'chrM','X':'chrX'}
    
    fwig=open(fnwig,'r')
    chrom=''
    coordinates={}
    for line in fwig.xreadlines():
        if re.search(r'track',line): continue
        if re.search(r'chrom=([A-Za-z0-9]+)\s',line):
            chrom=re.search(r'chrom=([A-Za-z0-9]+)\s',line).group(1)
            try:
                chrom=standard_chroms[chrom]
            except KeyError:
                pass
                
            coordinates[chrom]=array('l',[])
            continue
        # get the nearest loction and compare it with the last element of locs. If not the same, add it
        coordinate=(int(round(1.0*resolution/int(line.strip().split()[0]))))*resolution+1
        if not coordinates[chrom] or coordinate!=coordinates[chrom][-1]:
            coordinates[chrom].append(coordinate)
    
    fwig.close()
    return coordinates
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/get_genome_coordinates/swapped operands of `/`