Run the plugin.

def run_mq2(plugin, folder, lod_threshold=None, session=None,
            outputfolder=None):
    """ Run the plugin. """

    qtls_file = 'qtls.csv'
    matrix_file = 'qtls_matrix.csv'
    map_file = 'map.csv'
    map_qtl_file = 'map_with_qtls.csv'
    qtls_mk_file = 'qtls_with_mk.csv'
    map_chart_file = 'MapChart.map'
    if outputfolder:  # pragma: no cover
        qtls_file = '%s/%s' % (outputfolder, qtls_file)
        qtls_mk_file = '%s/%s' % (outputfolder, qtls_mk_file)
        matrix_file = '%s/%s' % (outputfolder, matrix_file)
        map_file = '%s/%s' % (outputfolder, map_file)
        map_qtl_file = '%s/%s' % (outputfolder, map_qtl_file)
        map_chart_file = '%s/%s' % (outputfolder, map_chart_file)

    LOG.debug('Call the plugin to create the map, qtls and matrix files')
    if folder and os.path.isdir(folder):
        plugin.convert_inputfiles(folder=folder, session=session,
                                  lod_threshold=lod_threshold,
                                  qtls_file=qtls_file,
                                  matrix_file=matrix_file,
                                  map_file=map_file)
    else:
        plugin.convert_inputfiles(inputfile=folder, session=session,
                                  lod_threshold=lod_threshold,
                                  qtls_file=qtls_file,
                                  matrix_file=matrix_file,
                                  map_file=map_file)

    LOG.debug('Add the number of QTLs found on the matrix')
    _append_count_to_matrix(matrix_file, lod_threshold)

    LOG.debug('Append the closest marker to the peak')
    add_marker_to_qtls(qtls_file, map_file, outputfile=qtls_mk_file)

    LOG.debug('Put the number of QTLs found on each marker of the map')
    add_qtl_to_map(qtls_mk_file, map_file, outputfile=map_qtl_file)

    LOG.debug('Generate the mapchart file')
    flanking_markers = generate_map_chart_file(
        matrix_file, lod_threshold, map_chart_file=map_chart_file)

    LOG.debug('Append flanking markers to qtl list')
    flanking_markers = append_flanking_markers(
        qtls_mk_file, flanking_markers)

    if folder and os.path.isdir(folder) and os.path.exists(folder):
        shutil.rmtree(folder)
    return 0