#!/usr/bin/perl -w
#	
# Written by Jennifer Deegan on the 12 October, 2007.
#
# This script is made to help deal with the situation where you discover that a term is gone from the ontology 
# file and you are sure you put it in and are wondering if a cvs comit accidentally deleted it. 
#
# You tell the script the current version number in cvs (write it in as the value of $b). The script will then 
# do a cvs diff command between the latest version and the previous version and will grep the diff with any search
# term that you give it. For example if you think you put in a term with the word 'pulmonary' in the name and it is
# now gone, then you can grep on that.  You should write your grep terms on any of the rows where the system call starts 
# "grep".
#
# The script will print the two version numbers of the files in the diff, and then it will print any lines of the diff containing your
# grep terms. 
#
# The script will then work back through the versions of the file in cvs for as many sets as you tell it. If you want to go back through the last 30
# versions of the file then you should set $count to 30. 
#
# After printing the grep results, the script prints the number of versions it has gone back, then the next two version number for the
# next diff and on to the next grep results and so on. 
#
# The routine is:
# print version
# do cvs diff
# grep diff
# print results
# print number of loops
# start again
#
# You can also get lists of terms changed by greping on "GO:".
#
#
#


use strict;

# Latest version number.
my $b = 1.59;
# Previous version number.
my $a = $b - 0.01;
# Scalar to let you say how many versions back to check.
my $count = 0;
# The to which the diff is printed. 
my $file = "file.txt";

# Here you can set the number of versions back to go.
while ($count <= 30) {

# Print the version number of the files to diff. 
		print "$a $b\n";
		# Do the diff and send to a file. 
		system "cvs -qz3 -d :ext:jenclark\@ext.geneontology.org:/share/go/cvs diff -r $a -r $b go/scratch/gene_ontology_cardio.obo > $file";
#		system "ls";
       # Grep for your search terms.
		system "grep pulmonary $file";
		system "grep lung $file";
#		system "grep GO:00 $file";
	    # Print the number of versions we have gone back. 
		print "$count\n";
		# Increment the counter for number of versions we have gone back. 
		$count ++;
		# Increment the scalars that remember which version we are on. 
		$a = $a - 0.01;
		$b = $b - 0.01;
	
}
