#!usr/bin/perl -w
#	
# By J. Clark and T. Deegan
# January 2005
#
# This script can be used to add a subset line for each term that is to be part of the GO subset. 
# To run it you need to have a file called 'numbers' with the list of term numbers that you want to be in the subset, and 
# you need an up to date copy of the ontologies in obo format.
# Before running the script you need to alter line 83 to show what the subset line is to say.
# after running the script you need to add a line to the header section of the ontology file
# to show that there is a new subset that has been added.

use strict;

#invent a hash table for all the numbers in the numbers file 
#and initialise it.
my %hash_of_numbers = ();      

#In this state the computer is interested in the go term it's reading about.
my $interested;
#!usr/bin/perl -w
#	
# This script takes the intersection file and the stripped live GO file and prints out a file just like the intersection file, 
# but with the definitions of the quoted GO terms written underneath each line. 
#
# Works with output of stripGOfile.pl
#
# By Jennifer Deegan, November 2008.


my $line;
my $GOid;

open (GOFILE, "<strippedGOfile.obo") || die "Can't open strippedGOfile.obo.\n";  

	while(<GOFILE>){	
    	chomp;
    	$line = $_;
		if ($line=~m/(.*)\t(.*)/) {
    	$hash_of_numbers{ $1 } = $2;    
		}	
	}

close GOFILE;	


open (XPFILE, "biological_process_xp_self.obo") || die "Can't open biological_process_xp_self.obo.\n";
open (XPOUT, ">biological_process_xp_self_with_defs.obo") || die "Can't open biological_process_xp_self_with_defs.obo.\n";

	while(<XPFILE>){
    	$line = $_;
       	print XPOUT $line;

       	if (($line=~m/.*(GO:[0-9]+).*/) && (defined $hash_of_numbers{$1})) {     
		    
			print XPOUT $hash_of_numbers{$1};
			print XPOUT "\n\n";
			}
    	}
   
   close XPOUT;
    	

    


