def read(self,fnwig=''):
        """Read a wig file.
        
        Parameters:
        1. fnwig: wig file name
        """
        
        # for C elegans
        standard_chroms={'I':'chrI','II':'chrII','III':'chrIII','IV':'chrIV','V':'chrV','M':'chrM','X':'chrX'}
        
        fwig=open(fnwig,'r')
        chrom=''
        wig={}
        for line in fwig.xreadlines():
            if re.search(r'track',line): 
                try:
                    description=re.search(r'description="([A-Za-z0-9]+)"\s',line).group(1)
                    if not self.description: self.description=description
                except AttributeError:
                    pass
                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 __HOLE__:
                    pass
                
                wig[chrom]=[array('l',[]),array('d',[])]
                continue
            # get the nearest loction and compare it with the last element of locs. If not the same, add it
            l=line.strip().split()
            wig[chrom][0].append(int(l[0]))
            wig[chrom][1].append(float(l[1]))
                
        fwig.close()
        self.wig=wig
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/Wig.read