my ($value, $col, $col2, $l_o_b, $left, $matchedID, $diff_three_prime, $diff_five_prime, $sequence); open (EXONS_five, '>fasta_exons_five'); open (EXONS_three, '>fasta_exons_three'); my $i = 0; foreach my $match(@exonic_matches) { $value = $exon_ID[$i]; $col = $exon_left{$value}; $col2 = $exon_right{$value}; my @three_prime_ss = split(",", $col); my @five_prime_ss = split(",", $col2); my @reverse_three = reverse(@three_prime_ss); my @reverse_five = reverse(@five_prime_ss); if ($strands{$value} =~ m/\+/) { $diff_three_prime = $LBP[$i] - $three_prime_ss[$exons2{$value} - 1]; $diff_five_prime = $LBP[$i] - $five_prime_ss[$exons2{$value} - 1]; $matchedID = $ID{$LBP[$i]}; if ($diff_three_prime !~ m/\-/ && $diff_three_prime <= 3) { $BP{$LBP[$i]} =~ s/\[[ACTG]\]/$alt[$i]/i; $l_o_b = 20; ##$right_of_boundary = 3; $l_o_b = $l_o_b + $diff_three_prime; $left = 51 - $l_o_b; $sequence = substr($BP{$LBP[$i]}, $left, 23); ## print $sequence, "\n"; ## POINT ONE: prints out correct sequence for condition ## } elsif ($diff_five_prime =~ m/\-/ && $diff_five_prime >= -3) { $BP{$LBP[$i]} =~ s/\[[ACTG]\]/$alt[$i]/i; $l_o_b = 3; ##$right_of_boundary = 6; $l_o_b = $l_o_b + $diff_five_prime; $left = 51 - $l_o_b; $sequence = substr( $BP{$LBP[$i]}, $left, 9); ## print $sequence, "\n"; ## POINT TWO: prints out what I want for this condition plus some repeats ## } } ## print $sequence, "\n"; ## POINT THREE: prints out multiple sequences of the above ## my $seq_length = length($sequence); if ($seq_length == 9) { print EXONS_five (">" . "$match_exon{$matchedID}" . "\n", lc($sequence),"\n"); } else { print EXONS_three (">" . "$match_exon{$matchedID}" . "\n", lc($sequence),"\n"); } $i++; } close (EXONS_five); close (EXONS_three);