def iterateMacsPeaks(infile):

    for line in infile:
        if line.startswith("#"):
            continue
        if line.startswith("chr\tstart"):
            continue
        # skip empty lines
        if line.startswith("\n"):
            continue

        data = line[:-1].split("\t")

        if len(data) == 9:
            # convert % fdr
            data[8] = float(data[8]) / 100.0
        elif len(data) == 8:
            # if no fdr given, set to 0
            # data.append( 0.0 )
            # Steve - I don't understand this so I'm commenting it out and
            # raising an error
            raise ValueError("FDR value not set line %s" % line)
        else:
            raise ValueError("could not parse line %s" % line)

        # these are 1-based coordinates
        # macs can have negative start coordinates
        # start
        data[1] = max(int(data[1]) - 1, 0)
        # end
        data[2] = int(data[2])
        # length
        data[3] = int(data[3])
        # summit
        data[4] = int(data[4])
        # ntags
        data[5] = int(data[5])
        # -10log10(pvalue)
        data[6] = float(data[6])
        # fold
        data[7] = float(data[7])

        yield MacsPeak._make(data)
iterate over peaks.xls file and return parsed data.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/WrapperMACS.py/iterateMacsPeaks