def main(argv=None):
    """script main.

    parses command line options in sys.argv, unless *argv* is given.
    """

    if argv is None:
        argv = sys.argv

    parser = E.OptionParser(
        version="%prog version: $Id: go2plot.py 2782 2009-09-10 11:40:29Z andreas $")

    parser.add_option("-e", "--header-names", dest="headers", action="store_true",
                      help="first row is a header [ignored].")
    parser.add_option("-t", "--title", dest="title", type="string",
                      help="page title.")
    parser.add_option("-f", "--footer", dest="footer", type="string",
                      help="page footer.")
    parser.add_option("-c", "--column-titles", dest="titles", type="string",
                      help="comma separated list of column titles [default: use filenames].")
    parser.add_option("-p", "--pattern-filename", dest="pattern_filename", type="string",
                      help="pattern to map columns to filename.")

    parser.set_defaults(
        sortAlphabetically=True,
        headers=False,
        titles="",
        pattern_filename=None,
        title="",
        footer="",
    )

    (options, args) = E.Start(parser, add_pipe_options=True)

    if len(args) == 0:
        raise "Please supply at least one input file."

    if options.pattern_filename:
        input = []
        titles = args
        for x in titles:
            input.append(options.pattern_filename % x)
    else:
        input = args

        if options.titles:
            titles = options.titles.split(",")
            if len(titles) != len(input):
                raise "Number of titles and files different: %i != %i" % (
                    len(titles), len(input))
        else:
            titles = input

    if options.loglevel >= 2:
        options.stderr.write("# reading data from:\n")
        for x in range(len(input)):
            options.stderr.write("# %s: %s\n" % (titles[x], input[x]))

    data = []
    for filename in input:
        # collect all data
        try:
            values = collect(open(filename, "r"), with_headers=options.headers)
        except IOError:
            values = []
        data.append(values)

    # collect all annotations
    # Also filter for max pvalue
    annotations = {}
    for i in range(len(input)):
        for line in data[i]:
            if maxp < line[1]:
                annotations[line[3]] = 0

    # Filter for pvalues and relreps in first two columns
    for ann in annotations:
        annotations[ann] = [1.0, 1.0, 1.0, 1.0]

    # sort and filter annotations
    # (Code removed which did some filtering; the annotations data is not used)
    # By removing labels from annlist you can select the annotations you want
    # to display
    annlist = [ann for ann in annotations]
    if options.sortAlphabetically:
        annlist.sort()

    # now make table

    # Number of columns
    columns = 1 + int(len(annlist) * rowheight / maxheight)
    # Length of one column
    collen = int(maxheight / rowheight)
    # Max number of columns on a single page
    pagecols = int((maxwidth + maincolsep) / (posx(len(titles)) + maincolsep))
    if doEps:
        pagecols = columns
    # Number of pages needed
    numpages = 1 + int((columns - 1) / pagecols)

    makeheader(titles, annlist, min(pagecols, columns), numpages)

    for page in range(numpages):
        if page == numpages - 1:
            colsonpage = columns - page * pagecols
        else:
            colsonpage = pagecols

        makepageheader(page + 1)

        for column in range(colsonpage):
            globcolumn = page * pagecols + column
            colannlist = annlist[globcolumn * collen:
                                 min((globcolumn + 1) * collen, len(annlist))]
            print "gsave"
            print column * (posx(len(titles)) + maincolsep), " 0 translate"

            makecolheader(titles, colannlist,
                          title=options.title)

            for i in range(len(titles)):
                for j in range(len(colannlist)):
                    # find element
                    element = 0
                    for line in data[i]:
                        if line[3] == colannlist[j]:
                            element = line
                    if element != 0:
                        # show
                        makeps(i, j, element)

            print "grestore"

        if colsonpage > 1:
            makefooter(collen + 2, footer=options.footer)
        else:
            makefooter(len(colannlist) + 2, footer=options.footer)

        makepagetrailer(page + 1)

        if not doEps:
            print "showpage"

    E.Stop()
dataset/ETHPy150Open CGATOxford/cgat/scripts/go2plot.py/main/swapped operands of `<`