def main():
    'It reads the map data and writes it'
    base_path       = '/home/peio/melonomics/datos_originales/mapa_genetico'
    markers_path    = 'mapa_icugi/melon_markers.csv'
    merged_map_path = 'mapa_icugi/framework_merged_map.csv'
    irta_maps_path  = 'mapa_genetico_irta.csv'
    icugi_qtls      = 'mapa_icugi/all_qtls.csv'

    bin_map_path    = 'mapa_icugi/bin_mapping.csv'

    out_path        = 'out.gff3'
    mcf_path        = 'out.mcf'


    correl_fpath    = os.path.join(base_path, 'mapa_icugi/markers.dat')
    markers_path    = os.path.join(base_path, markers_path)
    merged_map_path = os.path.join(base_path, merged_map_path)
    irta_maps_path  = os.path.join(base_path, irta_maps_path)
    out_path        = os.path.join(base_path, out_path)
    mcf_path        = os.path.join(base_path, mcf_path)
    bin_map_path    = os.path.join(base_path, bin_map_path)
    qtls_path       = os.path.join(base_path, icugi_qtls)
    #qtls_fix_path   = os.path.join(base_path, icugi_fix_qtls)

    cmap = create_empty_cmap()

    #Correlations file
    marker_corr = parse_markersfile(open(correl_fpath))

    #get Monforte marker data
    read_markers(open(markers_path), cmap, marker_corr)

    #get irta maps
    cmap_fhand = open(irta_maps_path)
    read_maps(cmap_fhand, cmap, marker_corr)

    #get data from icugi map
    read_icugi_map(open(merged_map_path), cmap, marker_corr)

    #fix the marker types
    fix_marker_types(cmap)


    #get icugi qtls
    read_qtls(open(qtls_path), cmap, marker_corr)

    #read bin map
    read_bin_map(open(bin_map_path), cmap, marker_corr)
#    import pprint
#    pprint.pprint(cmap)
#    return

    #write gff3 file
    gff_fhand  = open(out_path, 'w')
    cmap_to_gff(cmap, gff_fhand)

    #write mcf file
    mcf_fhand  = open(mcf_path, 'w')
    cmap_to_mcf(cmap, mcf_fhand)
def main():
    'The main part'
    # set parameters
    infhands, markersfname, name_cor, type_cor, sequence_cor = set_parameters()

    #read markes file if exists
    if os.path.exists(markersfname):
        markersfhand = open(markersfname)
        markers = parse_markersfile(markersfhand)
        markersfhand.close()
    else:
        markers = {}

    # add files to marker structure
    for infhand in infhands:
        add_markers(infhand, markers, name_cor, type_cor, sequence_cor)

    # write markers to file:
    markersfhand = open(markersfname, 'w')
    write_markers(markersfhand, markers)
    markersfhand.close()