title: Perl sequence alignment score calculation error
body: <p>Hello I'm writing this program for my Bioinformatics class, where I get a sequence from a text file and then mutate the sequence. After that I'm suppose to do a comparison to make a score by comparing the base pairs. I have all the code written, but I do not understand why I keep getting the score of 0. I'm assuming that the part of my code that deals with this is wrong because I initialized the <code>$sum = 0;</code> I was wondering if I could get some help to fix this issue so that my code works properly. Here is the sequence I'm using. </p>
  
  <pre><code>AGGGCACCTCTCAGTTCTCATTCTAACACCACATAATTTTTATTTGTATTATTCAGATTTTTCATGAACTTTTCCACAT
  AGAATGAAGTTGACATTGTTATTTCTCAGGGTCTCGGTTCACCAGTATTTGACAAACTTGAAGCTGAACTAGCTAAAGC
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>use strict;
  
  my $sum = 0;
  my @seq;
  my $seqString;
  my $seqShuf;
  my $line;
  
  unless(open FILE, "test_seq.txt")
  {
      print "Cannot open file!";
      exit; 
  }
  
  while (chomp($line = &lt;FILE&gt;))
  {
      next if (/^&gt;/);
      @seq = &lt;FILE&gt;;
  }
  
  $seqString = join("",@seq);
  chomp($seqShuf = shuffle_string($seqString));
  $seqShuf =~ s/\s+//g;
  #print "Original sequence is:\n";
  #print "$seqString\n";
  #print "Mutated Sequence is:\n";
  #print "$seqShuf\n";
  
  my @shufSeq = split("", $seqShuf, length($seqShuf));
  
  my %test = (
              AA =&gt; 0,
              AG =&gt; -1,
              AT =&gt; -2,
              AC =&gt; -2,
              GA =&gt; -1,
              GG =&gt; 0,
              GT =&gt; -2,
              GC =&gt; -2,
              TA =&gt; -2,
              TG =&gt; -2,
              TT =&gt; 0,
              TC =&gt; -1,
              CA =&gt; -2,
              CG =&gt; -2,
              CT =&gt; -1,
              CC =&gt; 0
              );
  
  my @base_pairs = make_base_pairs(@seq, @shufSeq);
  foreach my $bp (@base_pairs)
  {
      $sum += $test{$bp};
  }
  
  print "@base_pairs\n";
  print "The score is ", $sum, "\n";
  
  # Shuffles original sequence
  sub shuffle_string
  {
      my ($string) = @_;
      my $length = length $string;
      for (my $i = 0; $i &lt; $length-1; $i++)
      {
          my $j = random_int ($i, $length-1);
          my $tmp = substr($string, $i, 1);
          substr($string, $i, 1) = substr($string, $j, 1);
          substr($string, $j, 1) = $tmp;
      }
      return $string;
  }
  
  # created random int between two parameters
  sub random_int
  {
      (my $par1, my $par2) = @_;
      my $num = (1+$par1) +  int(rand($par2 - $par1));
  }
  
  # aligns base pairs based on index location
  sub make_base_pairs
  {
      (my @orig, my @shuf) = @_;
      my $idx = 0;
      my @bps;
      foreach my $base (@orig)
      {
          push @bps, $base , $shuf[$idx];
          $idx++;
      }
      return @bps;
  }
  </code></pre>