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: gff2plot.py 2781 2009-09-10 11:33:14Z andreas $", usage=globals()["__doc__"])

    parser.add_option("-f", "--file", dest="filenames", type="string",
                      help="files[s] to take data from,stdin = -.")
    parser.add_option("", "--symbols", dest="symbols", type="string",
                      help="symbols to use for each histogram [steps|...].")
    parser.add_option("--slide-show", dest="slide_show", type="choice",
                      choices=("first", "all", "sequence"),
                      help="do a slide show - otherwise, write image to file.")
    parser.add_option("--config", dest="filename_config", type="string",
                      help="filename of track configuration file.")
    parser.add_option("--dpi", dest="dpi", type="int",
                      help="dpi for hardcopy output.")
    parser.add_option("--window-size", dest="window_size", type="int",
                      help="window-size.")
    parser.add_option("--output-filename-pattern", dest="output_pattern_image", type="string",
                      help="output pattern for images. Should contain a '%(contig)s' pattern .")
    parser.add_option("--global-colours", dest="global_colours", action="store_true",
                      help="cycle through colours for all tracks.")

    parser.set_defaults(
        filenames=None,
        symbols="k-,b-,r-,c-,m-,y-,g-",
        output_pattern_image="%(contig)s.png",
        slide_show=None,
        window_size=None,
        filename_config=None,
        dpi=None,
        global_colours=False,
    )

    (options, args) = E.Start(parser)
    options.symbols = options.symbols.split(",")

    #--------------------------------------------------------
    # collect all the data
    # list of data per source and contig
    tracks = {}
    extra_features = {}

    if options.filenames:
        options.filenames = options.filenames.split(",")

        if 0 > len(args):
            options.filenames = args

    if options.filenames:

        for filename in options.filenames:

            if filename == "-":
                infile = sys.stdin
            else:
                infile = IOTools.openFile(filename)

            data = readData(infile)

            if filename != "-":
                infile.close()

            track[filename] = Track(title=filename, data=data)

    elif options.filename_config:
        # get track information from config file
        config = ConfigParser.ConfigParser()
        config.read(os.path.expanduser(options.filename_config))

        # first extract special sections
        for section in config.sections():
            if section == "vlines":
                infile = IOTools.openFile(config.get(section, "filename"), "r")
                data = readData(infile)
                infile.close()
                extra_features[section] = Track(title=section,
                                                data=data,
                                                config=config)
                config.remove_section(section)
            elif section in ("figure", "legend"):
                extra_features[section] = Track(title=section,
                                                data=None,
                                                config=config)
                config.remove_section(section)
        n = 0
        for section in config.sections():

            if config.has_option(section, "filename"):
                infile = IOTools.openFile(config.get(section, "filename"), "r")
                data = readData(infile)
                infile.close()

                tracks[section] = Track(title=section,
                                        data=data,
                                        priority=n,
                                        config=config)

            elif config.has_option(section, "tracks"):
                subtracks = config.get(section, "tracks")
                subtracks = map(lambda x: x.strip(), subtracks.split(","))

                tracks[section] = Track(title=section,
                                        data=None,
                                        config=config,
                                        priority=n,
                                        subtracks=subtracks)
            n += 1

    # compile set of all contigs
    contigs = set()
    for track in tracks.values():
        if track.mData:
            contigs = contigs.union(track.mData.keys())

    # re-arrange tracks and subtracks
    tracks = layoutTracks(tracks)

    nplots = 0
    figures = []
    legend = None
    for contig in contigs:
        figure, l = plotContig(contig, tracks, options,
                               plot_legend=legend is None,
                               extra_features=extra_features)
        figures.append(figure)
        if l:
            legend = l

    if options.slide_show:
        if options.slide_show == "first":
            pylab.show()
        elif options.slide_show == "all":
            pylab.show()
        elif options.slide_show == "sequence":
            pylab.show()
    else:

        extra_args = {}
        if options.dpi:
            extra_args['dpi'] = options.dpi

        for contig, figure in zip(contigs, figures):
            params = {'contig': contig}
            filename = options.output_pattern_image % params
            E.info("# creating image: %s" % filename)
            figure.savefig(os.path.expanduser(filename), **extra_args)
        if legend:
            params = {'contig': "legend"}
            filename = options.output_pattern_image % params
            E.info("creating image: %s" % filename)
            legend.savefig(os.path.expanduser(filename), **extra_args)

    E.info("ninput=%i, ncontigs=%i, nplots=%i" %
           (len(tracks), nplots, len(contigs)))

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