def sample(self, wig, resolution):
        """Sample a wig file at the given resolution. 
        
        Parameters:
        1. wig: a wig object (see inout.py)
        2. resolution: sampling resolution
        
        Return:
        sampWig: the sampled wig object
        
        """
        
        # parameter checking
            
        try:
            chroms=wig.get_chroms()
        except __HOLE__:
            raise Exception("Argument 'wig' must be given")
        
        sampWig=Wig()
        for chrom in chroms:
            try:
                standardchrom=self.standard_chroms[chrom]
            except KeyError:
                standardchrom=chrom
            
            samp=[array('l',[]),array('d',[])]
            for wc,val in itertools.izip(wig[chrom][0],wig[chrom][1]):
                coordinate=(int(round(1.0*wc/resolution)))*resolution+1
                
                if len(samp[0])==0:
                    samp[0].append(coordinate)
                    samp[1].append(val)
                    continue
                if coordinate!=samp[0][-1]:
                    samp[0].append(coordinate)
                    samp[1].append(val)
            
            #added to sampWig only if there are some point(s)
            if samp[0]: sampWig.wig[standardchrom]=samp
                
        return sampWig
dataset/ETHPy150Open taoliu/taolib/Assoc/sampler.py/WigSampler.sample