### CREATE TWO SAMPLE DNA SEQUENCES ### @nucleotides=('A','T','G','C'); foreach(1..1000) { $seq1.=$nucleotides[int(rand(3))]; } foreach(1..1000) { $seq2.=$nucleotides[int(rand(3))]; } ### SETTINGS FOR THE DOTPLOT ### $window_size=5; $max_mismatch=1; @seq1=split('',$seq1); foreach(1..$window_size) { shift@seq1; } @seq2=split('',$seq2); foreach(1..$window_size) { shift@seq2; } open(OUT,">ID_matrix.txt"); $number_of_windows_1=((length$seq1)-$window_size)+1; $number_of_windows_2=((length$seq2)-$window_size)+1; $time_start=time; foreach$window_no(0..$number_of_windows_1-1) { @seq2_temp=@seq2; if($window_no==0) { $current_window=substr($seq1,0,$window_size); @current_window=split('',$current_window); } else { shift@current_window; $next_character=shift@seq1; push(@current_window,$next_character); } foreach$query_no(0..$number_of_windows_2-1) { if($query_no==0) { $query_window=substr($seq2,0,$window_size); @query_window=split('',$query_window); } else { shift@query_window; $next_character=shift@seq2_temp; push(@query_window,$next_character); } $count_matches=0; foreach(0..$window_size-1) { if($current_window[$_]eq$query_window[$_]) { $count_matches++; last if($_-$count_matches>$max_mismatch); } } if($count_matches>=$window_size-$max_mismatch) { print OUT "1"; } else { print OUT "0"; } } print OUT"\n"; } $time_end=time; $time_used=$time_end-$time_start; close OUT; print"Time used: $time_used seconds.\n"; system("pause"); exit;