﻿#!usr/bin/perl -w
#	
#	By Jennifer Deegan, May 2008.
#
# This script takes the output file from FindTaxonLinkedTerms.pl and processes it
# to remove all lines except these:
#
# [Term]
# id: .*
# relationship: never_in_taxon .*
#	
# This file can then be loaded into OBO-Edit with the taxon slim and the 
# GO file and OBO-Edit displays the links from the GO terms to the taxon terms.
# 

use strict;
my $line;
 
open (FILE, "TaxonLinkedTerms.obo") || die "Can’t open TaxonLinkedTerms.obo.\n";
open (OUTPUT, ">TaxonGOLinksFile.obo") || die "Can’t open TaxonGOLinksFile.obo.\n";

    while (my $line=<FILE>){
            $line =~ s/subset.*\n//;
            $line =~ s/def.*\n//;
            $line =~ s/namespace.*\n//;
            $line =~ s/name.*\n//;
            $line =~ s/synonym.*\n//;
            $line =~ s/relationship\:\sreg.*\n//;
            $line =~ s/relationship\:\spart_of.*\n//;
            $line =~ s/is_a.*\n//;
            $line =~ s/xref.*\n//;
            $line =~ s/alt_id.*\n//;
            $line =~ s/is_obsolete.*\n//;
            $line =~ s/comment.*\n//;
            $line =~ s/relationship\:\spos.*\n//;
            $line =~ s/relationship\:\sneg.*\n//;
            $line =~ s/replaced_by.*\n//;
            $line =~ s/consider.*\n//;
            $line =~ s/alt_id.*\n//;
            print OUTPUT $line;
    }

print OUTPUT "[Typedef]\n";
print OUTPUT "id: never_in_taxon\n";
print OUTPUT "name: 	never_in_taxon\n";
print OUTPUT "is_transitive: true\n";
print OUTPUT "\n";
print OUTPUT "[Typedef]\n";
print OUTPUT "id: 	only_in_taxon\n";
print OUTPUT "name: 	only_in_taxon\n";
print OUTPUT "is_transitive: true\n";


close FILE;
close OUTPUT;


