This function adds to a genetic map for each marker the number
    of significant QTLs found.

    :arg qtlfile, the output from MapQTL transformed to a csv file via
        'parse_mapqtl_file' which contains the closest markers.
    :arg mapfile, the genetic map with all the markers.
    :kwarg outputfile, the name of the output file in which the map will
        be written.

def add_qtl_to_map(qtlfile, mapfile, outputfile='map_with_qtls.csv'):
    """ This function adds to a genetic map for each marker the number
    of significant QTLs found.

    :arg qtlfile, the output from MapQTL transformed to a csv file via
        'parse_mapqtl_file' which contains the closest markers.
    :arg mapfile, the genetic map with all the markers.
    :kwarg outputfile, the name of the output file in which the map will
        be written.

    """
    qtl_list = read_input_file(qtlfile, ',')
    map_list = read_input_file(mapfile, ',')
    map_list[0].append('# QTLs')
    markers = []
    markers.append(map_list[0])
    qtl_cnt = 0
    for marker in map_list[1:]:
        markers.append(add_qtl_to_marker(marker, qtl_list[1:]))
        qtl_cnt = qtl_cnt + int(markers[-1][-1])
    LOG.info('- %s markers processed in %s' % (len(markers), mapfile))
    LOG.info('- %s QTLs located in the map: %s' % (qtl_cnt, outputfile))
    write_matrix(outputfile, markers)