#!perl -w #parses output of ms for analysis of divergence in windows #need to manually reset the window size by alterting $k if simulating a segment of different size my $file = shift(@ARGV); chomp $file; open IN, $file or die "wrong format for infile\n"; my $countermac=0; my $counterhel=0; my $counterclem=0; my @data=(); my @values=(); my @mac=(); my @hel=(); my @clem=(); my @macval=(); my @helval=(); my @clemval=(); my $divclemhel=0; my $divmachel=0; my $divclemmac=0; my $start=0; while (my $line = ) { chomp $line; my @data = split(/\t/, $line); push(@mac,$data[0]); push(@hel,$data[1]); push(@clem,$data[2]); #(my $mac, my $other)=split(/\t/, $data); my @macval = split(//,$data[0]); my @helval = split(//,$data[1]); my @clemval = split(//,$data[2]); #print "$mac[0]\t$hel[0]\t$clem[0]\n"; #print "$macval[0]\t$helval[0]\t$clemval[0]\n"; my $stop =(scalar(@macval))/10; for $k (0..9){ $divclemmac=0;$divclemhel=0;$divmachel=0; for $i ($start..$stop){ if ($macval[$i] ne $clemval[$i]){ $divclemmac++ }#divergent sites between clem & mac if ($macval[$i] ne $helval[$i]){ $divmachel++ }#divergent sites between hel and mac if ($clemval[$i] ne $helval[$i]){ $divclemhel++ }#divergent sites between hel and clem if (($macval[$i] eq 1) & ($macval[$i] ne $helval[$i]) & ($macval[$i] ne $clemval[$i])){ $countermac++ }#mac unique sites if (($helval[$i] eq 1) & ($helval[$i] ne $macval[$i]) & ($helval[$i] ne $clemval[$i])){ $counterhel++ }#hel unique sites if (($clemval[$i] eq 1) & ($clemval[$i] ne $macval[$i]) & ($clemval[$i] ne $helval[$i])){ $counterclem++ }#clem unique sites }#for i sites print "$divclemmac\t$divclemhel\t$divmachel\t$countermac\t$counterhel\t$counterclem\n"; $start=$start+((scalar(@macval))/10); $stop=$stop+((scalar(@macval))/10); } #for k windows }#for the whole file close IN;