Hello BioLion,
Basically I followed your code,
use warnings;
use strict;
my %bow1 = ();
my $file1 = shift;
open (FILE1, "$file1"); # Open first file
while (<FILE1>) {
my ($ID1, undef, undef, undef, $Seq1) = split;
$bow1{$ID1} = $ID1;
$bow1{$Seq1} = $Seq1;
print STDERR "$bow1{$ID1}\t$bow1{$Seq1}\n";
}
close FILE1;
my %bow2 = ();
my $file2 = shift;
open (FILE2, "$file2"); # Open second file
while (<FILE2>) {
my ($ID2, undef, undef, undef, $Seq2) = split;
$bow2{$ID2} = $ID2;
$bow2{$Seq2} = $Seq2;
print STDERR "$bow2{$ID2}\t$bow2{$Seq2}\n";
}
close FILE2;
foreach my $ID1 (keys %bow1){ # can use (sort keys %hash) to put items
+ in a specified order
if ( exists $bow2{$ID2} ){
if ( $bow1{$ID1} eq $bow2{$ID2} ){
## id and sequence are stored as key value pairs
print "$bow1{$ID1} exists in $file1 and $file2 and the sequen
+ces match $bow1{$Seq1} $bow2{$Seq2} \n";
}
else{
print "$bow1{$ID1} exists in $file1 and $file2 but sequences D
+O NOT match $bow1{$Seq1} $bow2{$Seq2} \n";
}
}
else {
print "$bow1{$ID1} only exists in $file1 .\n";
}
}
exit;
However I get some errors
Global symbol "$ID2" requires explicit package name at /home/choia2/sc
+ripts/BowtieCompare.pl line 50.
Global symbol "$ID2" requires explicit package name at /home/choia2/sc
+ripts/BowtieCompare.pl line 51.
Global symbol "$Seq1" requires explicit package name at /home/choia2/s
+cripts/BowtieCompare.pl line 53.
Global symbol "$Seq2" requires explicit package name at /home/choia2/s
+cripts/BowtieCompare.pl line 53.
Global symbol "$Seq1" requires explicit package name at /home/choia2/s
+cripts/BowtieCompare.pl line 56.
Global symbol "$Seq2" requires explicit package name at /home/choia2/s
+cripts/BowtieCompare.pl line 56.
Execution of /home/choia2/scripts/BowtieCompare.pl aborted due to comp
+ilation errors.
Basically the foreach loop.. I never used hash for other programming languages (I wasn't professional though) but this hash concept is confusing.. could you help me one more time? >.<