#!/usr/bin/perl
while (<>) {
    if (/RD:\s+(GO:\d+).*subClassOf (GO:\d+)/) {
        $rd{$1}->{$2} = 1;
    }
    if (/^format/) {
        print;
        last;
    }
}
while (<>) {
    if (/^id: (GO:\d+)/) {
        $id = $1;
    }

    if (/is_a: (GO:\d+)/ && $rd{$id}->{$1}) {
        print STDERR "Removing: $id is_a $1\n";
    }
    else {
        print;
    }
}
