def sample(self,bed=None,resolution=600):
        """Doing sampling"""
        
        try:
            chroms=bed.get_chroms()
        except AttributeError:
            raise Exception("Argument 'bed' must be given")
        
        coordinates={}
        for chrom in chroms:
            try:
                standardchrom=self.standard_chroms[chrom]
            except __HOLE__:
                standardchrom=chrom
            coordinates[standardchrom]=[]
            ChIP=zip(bed[chrom]['start'],bed[chrom]['end'],map(lambda x,y,:(x+y)/2,bed[chrom]['start'],bed[chrom]['end']))
            howmanyChIPs=len(ChIP)
            for i in xrange(0,howmanyChIPs):
                
                # get the begining, end, and center of a peak
                beg,end,center=ChIP[i]

                ### When using the real locations of beg
                Ns=range(center,max(0,beg-1),-1*resolution)
                Ns.reverse()
                Ns+=range(center+resolution,end+1,resolution)
                
                if Ns: coordinates[standardchrom].extend(Ns)
            
            coordinates[standardchrom].sort()
        
        return coordinates
dataset/ETHPy150Open taoliu/taolib/Assoc/sampler.py/ChIPSampler.sample