def main():
    """
    Main function. Takes all the inputs as arguments and runs the remaining
    functions of the program.
    """
    if len(argv) < 2:
        arg_list = ["-h"]
    else:
        arg_list = argv[1:]

    arg = argument_parser(arg_list)

    if arg.upstream == "baypass":
        present_covariates = fp.parse_baypass_envfile(arg.present_covars_file)
        future_covariates = fp.parse_baypass_envfile(arg.future_covars_file)
        RonaClass.POP_NAMES = fp.popnames_parser(arg.popnames_file)
        assocs = fp.baypass_summary_betai_parser(
            arg.baypass_summary_betai_file,
            arg.bayes_factor, arg.immutables)
        al_freqs = fp.baypass_pij_parser(arg.baypass_pij_file, assocs)
    elif arg.upstream == "lfmm":
        present_covariates = fp.parse_lfmm_envfile(arg.present_covars_file)
        future_covariates = fp.parse_lfmm_envfile(arg.future_covars_file)
        assocs = fp.lfmm_results_parser(arg.lfmm_assoc_file,
                                        arg.p_thres,
                                        arg.immutables)
        RonaClass.POP_NAMES, al_freqs = fp.lfmm_to_pop_allele_freqs(
            arg.allele_freqs_file,
            arg.present_covars_file,
            assocs,
            popnames=True)

    ronas = {}
    for assoc in assocs:
        marker, covar = assoc

        # Instanciate class
        if covar not in ronas:
            rona = RonaClass(covar)
        else:
            rona = ronas[covar]

        calculate_rona(marker, rona, present_covariates[int(covar) - 1],
                       future_covariates[int(covar) - 1],
                       al_freqs[marker],
                       arg.plots, arg.outliers, arg.rtype)

        ronas[covar] = rona

    ronas = ronas_filterer(ronas, arg.use_weights, arg.num_covars)

    results_summary(ronas, arg.use_weights)
    gp.draw_rona_plot(ronas, arg.outfile)

    if arg.map_filename is not None:
        # The map plotting module is only imported if a map plot is requested.
        # This is to be able to keep 'cartopy' as an optional dependency.
        try:
            import plotters.map_plotter as mapper
        except ImportError:
            import pyRona.plotters.map_plotter as mapper
        mapper.map_plotter(ronas, present_covariates[1], present_covariates[0],
                           arg.map_filename)