#!/usr/bin/perl

use strict;

for( my $chr=1;$chr<=20;$chr++) {
    my $ch = $chr<20 ? $chr : "X";
    my $afile = "chr$ch.MEGA+MDA+MUGA.alleles";
    open(ALLELES,$afile) || die "Could not read $afile\n";
    my $mfile = "chr$ch.MEGA+MDA+MUGA.map";
    open(MAP, ">$mfile") || die "Could not write $mfile\n";
    print MAP "marker\tchromosome\tbp\n";
    while(<ALLELES>) {
	chomp;
	if ( /^marker\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ ) {
	    print MAP "$1\t$3\t$5\n";
	}
    }
    close(ALLELES);
    close(MAP);
}
