#!/usr/bin/perl -w 
use strict; 
my $file = "scrambleyeast.txt"; 
my $totallength = 0; 
my %nucleotidepair = ();                                                                 #line5
 
open (SEQUENCE, $file) or die "Can't open the DNA sequence file $file\n"; 
my(@lines) = <SEQUENCE>; 
close (SEQUENCE); 
                                                                                         #line10
my($big_line); 
my($current_line); 

foreach $current_line (@lines) 
	{                                                                                #line15
		if ($current_line !~ m/^>/ ) {
			chomp ($current_line);
			$big_line = $big_line.$current_line;
		} 
	} 
                                                                                         #line20
my $length = length($big_line);                                                                                         #line20
for (my $i=0; $i < $length-1; $i++) 
	{ 
		my $nucpair = substr($big_line, $i, 2);
		$nucleotidepair{$nucpair}++                                              #line25
	} 
                                                               
open(OUTPUT,">yeastditypes.txt") or die "I can't open your output file\n";
my @ditypes;
@ditypes = sort(keys %nucleotidepair);
foreach my $nucpair (@ditypes)	
	{
		print "The nucleotide pair $nucpair occurs $nucleotidepair{$nucpair} times.\n";
		my $fraction = $nucleotidepair{$nucpair}/length($big_line);
		print OUTPUT "$nucpair: $fraction\n";
	}
print OUTPUT "\n";
close(OUTPUT);















