#!/usr/bin/perl

use strict;

my $ids;

my $transcriptome = shift; # 1st command line argument
my $grn = shift; # 2nd command line argument

# LOAD GENE IDs HAVING EXPRESSION PROFILES
open F, $transcriptome;
my $foo = <F>; # skip 1st line (header)
while (<F>) {
	my ($id) = split '\t';
	$ids->{$id} = 1;
}
close F;

open F, $grn;
while (<F>) {
	if ($_ =~ /^#/) { # skip comments
		print $_;
	}
	else {
		my ($tf, $gene) = split, '\t';
		next unless defined $ids->{ uc($tf) } && defined $ids->{ uc($gene) };
		next if uc($tf) eq uc($gene);
		print $_;
	}
}
close F;


