#!usr/bin/perl -w
use strict;

system 'clear';

# determine mapped ChEBI molecules listed in arabidopsis but not in rice, 
# and vice-versa

my $dir = "/home/preecej/Documents/projects/reactome/aracyc_to_reactome_conversion/ara_rice_exclusive_sets/";
my @rice;
my @ara;

open(IN_FILE, $dir . "Rice_ReferenceNameToChEBIId.txt") or die;
while (<IN_FILE>) {
    my $line = $_;
    chomp $line;
    push(@rice,$line);
}
close IN_FILE;

open(IN_FILE, $dir . "Ara_ReferenceNameToChEBIId.txt") or die;
while (<IN_FILE>) {
    my $line = $_;
    chomp $line;
    push(@ara,$line);
}
close IN_FILE;

my %ara_seen; # lookup tbl
my @rice_only; #exclusive to rice

# build lookup tbl
@ara_seen{@ara} = ();

foreach my $item (@rice) {
    push(@rice_only, $item) unless exists $ara_seen{$item};
}

my %rice_seen; # lookup tbl
my @ara_only; #exclusive to rice

# build lookup tbl
@rice_seen{@rice} = ();

foreach my $item (@ara) {
    push(@ara_only, $item) unless exists $rice_seen{$item};
}

my $exc_rice_count = 0; 
print "-- [EXCLUSIVE RICE MOLECULES] --\n";
foreach my $item (@rice_only) {
    $exc_rice_count++;
     print "$exc_rice_count: $item\n";
}

#print "$exc_rice_count\n\n";

my $exc_ara_count = 0; 
print "-- [EXCLUSIVE ARABIDOPSIS MOLECULES] --\n";
foreach my $item (@ara_only) {
    $exc_ara_count++;
    print "$exc_ara_count: $item\n";
}

print "$exc_ara_count\n\n";

# clean up
exit;
