# join_map_file_converter.pl: Convert Illumina SNP genotyping array data to Joinmap format. # Copyright (C) 2010 James Harriman # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . #!/usr/bin/perl ###Variables### #Enter Illumina ID of parent 1 below. $P1 = qw/ 4560195059_A /; #Enter Illumina ID of parent 2 below. $P2 = qw/ 4560195059_A /; #Enter Illumina IDs of offspring below, one per line. @O = qw/ 4560195150_A 4560195149_A 4560195142_A 4560195088_A 4560195099_A 4560195063_A 4560195058_C 4560195059_C 4560195150_C 4560195149_C 4560195142_C 4560195088_C 4560195099_C 4560195063_C 4560195058_E 4560195059_E 4560195150_E 4560195149_E /; ###Program Logic### #print header line @i =(1..$#O+1); print"SNPparentals," . join(",",@i), "\n"; @i=(); #load .csv file while(<>){ $_ =~ s/\r//g; chomp; push @data, [split(',',$_)]; } #Nested loop over SNPs (rows) and samples (columns). Store in HoA structure. for $snp (2..$#data){ for $sample(1..$#{$data[$snp]}){ if($verbose){print "$data[$sample][1]\t";} @snpinfo = split('\|', $data[$snp][$sample]); if($verbose){print "$snp,$sample = $snpinfo[0],$snpinfo[1]\t";} $allele{$data[$snp][0]}{$data[1][$sample]} = $snpinfo[0]; if($verbose){$confidence{$data[$snp][0]}{$data[1][$sample]} = $snpinfo[1]; } if($verbose){print "Stored $allele{$data[$snp][0]}{$data[1][$sample]} in $data[$snp][0], $data[1][$sample]\t";} if($verbose){print "Stored $confidence{$data[$snp][0]}{$data[1][$sample]} in $data[$snp][0], $data[1][$sample]\t";} } if($verbose){print "\n";} } if($verbose){print $allele{"VV\:1\:1002317"}{"4560195049_L"};} if($verbose){print join(",", keys %{$allele{1_10241041}});} for $curr_snp(keys %allele){ if($verbose){print "Moving to SNP $curr_snp.\n$allele{$curr_snp}{$P1}$allele{$curr_snp}{$P2}\n";} if($verbose){if($allele{$curr_snp}{$P1} =~ m/\-/ || $allele{$curr_snp}{$P2} =~ m/\-/){print "$allele{$curr_snp}{$P1}$allele{$curr_snp}{$P2}\n";next;}} @segregation_code =(); @allele_parent =(); @allele_offspring =(); @allele_parent = split('', join('',($allele{$curr_snp}{$P1},$allele{$curr_snp}{$P2}))); if($allele_parent[0] eq $allele_parent[1]){ if($allele_parent[2] ne $allele_parent[3]){ @segregation_code = ("n","n","n","p"); #2nd parent heterozygous }else{next;} #Both parents homozygous }else{ if($allele_parent[2] ne $allele_parent[3]){ @segregation_code = ("h","k","h","k"); #Both parents heterozygous }else{ @segregation_code = ("l","m","l","l"); #1st parent heterozygous } } for $curr_offspring(0..$#O){ @allele_offspring = split('', $allele{$curr_snp}{$O[$curr_offspring]}); if(join('',@segregation_code) =~ m/n/){ if($allele_offspring[0] eq $allele_offspring[1]){ $segregation_code_offspring[$curr_offspring]="nn"; }else{ $segregation_code_offspring[$curr_offspring]="np"; } } if(join('',@segregation_code) =~ m/h/){ if($allele_offspring[0] eq $allele_offspring[1]){ if($allele_offspring[0] eq $allele_parent[0]){ $segregation_code_offspring[$curr_offspring]="hh"; }else{ $segregation_code_offspring[$curr_offspring]="kk"; } }else{ $segregation_code_offspring[$curr_offspring]="hk"; } } if(join('',@segregation_code) =~ m/l/){ if($allele_offspring[0] eq $allele_offspring[1]){ $segregation_code_offspring[$curr_offspring]="ll"; }else{ $segregation_code_offspring[$curr_offspring]="lm"; } } #$segregation_code_offspring[$curr_offspring] = join('', ($segregation_code_offspring[$curr_offspring], "=",$allele_offspring[0],$allele_offspring[1])); } print "$curr_snp,\<$segregation_code[0]$segregation_code[1]x$segregation_code[2]$segregation_code[3]\>," . join(",", @segregation_code_offspring) . "\n"; }