my ($left_of_boundary, $intron_from_boundary, $new_left, $seq, $col7, $col_alt, $matchID); my $i = 0; open (INTRONS_five, '>fasta_introns_five_non'); open (INTRONS_three, '>fasta_introns_three_non'); foreach $col7(@col7) { ##50bp seq in var file $seq = ''; $col7[$i] =~ s/\[[ACTG]\]/$col_ref[$i]/i; if ($intron_from_boundary[$i] =~ m/\-/) { &three_prime; } elsif ($intron_from_boundary[$i] =~ m/\+/) { &five_prime; } my $length = length($seq); if ($length == 9) { print INTRONS_five (">" . "$match{$col_NM[$i]}" . "\n", lc($seq),"\n"); } elsif ($length != '') { print INTRONS_three (">" . "$col_NM[$i]" . "\n", lc($seq),"\n"); } ++$i; } close (INTRONS_five); close (INTRONS_three); sub three_prime { if ($strands{$ID[$i]} =~ m/\+/) { ## !!!PROBLEM!!! - $seq prints to file INTRONS_three when $strands{$ID[$i]} = + or - ### ### BUT if I print out $ID[$i] here, it only pulls out + (shows the hash is working) ### $left_of_boundary = 20; ##$right_of_boundary = 3; $left_of_boundary = $left_of_boundary + $intron_from_boundary[$i]; $new_left = 51 - $left_of_boundary; $seq = substr( $col7[$i], $new_left, 23); } elsif ($strands{$ID[$i]} =~ m/\-/) { if ($intron_from_boundary[$i] >= -6) { $left_of_boundary = 3; #$right_of_boundary = 6; $left_of_boundary = $left_of_boundary - $intron_from_boundary[$i]; $new_left = 51 - $left_of_boundary; $seq = substr( $col7[$i], $new_left, 9); $matchID = $ID[$i] . "\t" . $intron_from_boundary[$i] . "\t" . "on the negative strand"; } } }