#!/usr/bin/perl open(FILE1, "$ARGV[0]") || die "Can not open $ARGV[0]!!\n"; open(FILE2, "$ARGV[1]") || die "Can not open $ARGV[1]!!\n"; open(OUT, ">$ARGV[2]") || die "Can not open $ARGV[2]!!\n"; #%hs_o2_qual = (); %hs_o2 = (); %hs_filter = (); while(){ chomp($_); my @field = split(" ", $_); if($field[0]){ my $value = $field[0]."-".$field[1]; my $key = $field[2]."-".$field[3]; if($hs_o2{$key}){ #print "$key\t$value\t",$hs_o2{$key},"\n"; $hs_filter{$key}++; }else{ #print "$value\t$key\n"; $hs_o2{$key} = $value; #$hs_o2_qual{$key} = $field[4]; } $enum_hs++; } } #print "$enum_hs\n"; #$count_hs = keys %hs_o2; #$count_filt = keys%hs_filter; #print "$count_hs\t$count_filt\n"; while ( my ($key, $value) = each(%hs_o2) ) { if($hs_filter{$key}){ delete ($hs_o2{$key}); #print "$key\t$value\n"; #$count++; } # $count_o2++; } #$count_hs = keys %hs_o2; #$count_filt = keys%hs_filter; #print "$count_hs\t$count\n"; #$o2_hs_qual = (); %o2_hs = (); %o2_filter = (); while(){ chomp($_); my @field = split(" ", $_); if($field[0]){ my $value = $field[0]."-".$field[1]; my $key = $field[2]."-".$field[3]; #print "$key->$value\n"; if($o2_hs{$key}){ #print "$key\t$value\t",$o2_hs{$key},"\t",$o2_hs_qual{$key},"\n"; $o2_filter{$key}++; } else{ $o2_hs{$key} = $value; #$o2_hs_qual{$key} = $field[4]; } $enum_o2++; } } while ( my ($key, $value) = each(%o2_hs) ) { if($o2_filter{$key}){ delete ($o2_hs{$key}); #print "$key\t$value\n"; $count++; } #$count_o2++; } #$count_hs = keys %hs_o2; #$count_filt_h = keys%hs_filter; #$count_o2 = keys %o2_hs; #$count_filt_o = keys%o2_filter; #print "$count_hs\t$count_filt_h\t$count_o2\t$count_filt_o\n"; #print "$enum_o2\n"; while ( my ($key, $value) = each(%o2_hs) ) { #print "$key\t$value\n"; if($hs_o2{$value}){ print OUT "$value\t$key\n"; $count++; } $count_o2++; } print "FILE 1=$enum_hs\tUnique=$count_hs\nFILE 2=$enum_o2\tUnique=$count_o2\nTotal common =$count\n";