[Bio] / FigKernelScripts / annotation_counts.pl Repository:
ViewVC logotype

View of /FigKernelScripts/annotation_counts.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri Apr 29 16:54:25 2011 UTC (8 years, 6 months ago) by disz
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_06072011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, rast_rel_2014_0729, mgrast_dev_05262011, mgrast_release_3_1_2, mgrast_release_3_1_1, rast_rel_2011_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_10262011, mgrast_release_3_1_0, HEAD
Changes since 1.1: +7 -0 lines
Check in coming dates

use File::stat;
use Data::Dumper;
use FileHandle;
use strict;
use FIG;
use Time::localtime;

#run this on anno-3, sourcing ~fig/FIGdisk/config/... to get anno-3 user stats
my $fig = new FIG;

#
# %anno is a hash counter by who, date
#
my %anno;
my %total;

#input is lines of y/m (like this: 2010/12), one per line
#put them in the order you want the output columns, leaving blank lines where you want 
#space between columns - if you leave the last line blank, it puts a blank column before
#the total column, which is usually good for graphing in excel
#
#enter consecutive dates for a linear scale of progress, enter same months year apart
#to do same month compares
#
#run it like this:
#perl annotation_counts.pl < dates | svr_file_to_spreadsheet -f stats.xls
#

my @columns = <STDIN>;
chomp @columns;

for my $date (@columns) {
	if ($date !~ /^20\d\d\/(01|02|03|04|05|06|07|08|09|10|11|12)/) {
		if ($date ne "") {
			die "BAD $date\n";
		}
	}	
}
my %dates = map{ $_ => 1} @columns;;

my @genomes = $fig->genomes('complete');
for my $genome (@genomes) {
    my $fh = new FileHandle("<$FIG_Config::organisms/$genome/annotations");

    if (!$fh)
    {
        die "Cannot open annotations for $genome: $!\n";
    }

    local $/ = "//\n";

    my ($fid, $anno_time, $who, $anno_text, $anno_who, $fn);

    while (my $ann = <$fh>)
    {
        chomp $ann;

        if ((($fid, $anno_time, $who, $anno_text, undef, $anno_who, $fn) =
             ($ann =~ /^(fig\|\d+\.\d+\.peg\.\d+)\n(\d+)\n(\S+)\n(Set(\s+(FIG|master))?\s+function\s+to[ \t]*\n(.*))/s)) )
        {
		$anno_time = time_at($anno_time);
		if ($dates{$anno_time}) {
			$anno{$who}{$anno_time}++;
			$total{$who}++;
		}
            } else {
		    #  	print STDERR $ann;
		}
    }
    close($fh);

}        

print "Annotator\t";
print join("\t", @columns);
print "\tTotal\n";

for my $i (sort { $total{$b} <=> $total{$a} } keys(%total)) {
	print "$i";
	    for my $c (@columns) {
		    print "\t$anno{$i}{$c}";
	}
	print "\t$total{$i}\n";
}

sub time_at {
       my($ts) = @_;
	  my $tm = localtime($ts);
	  return sprintf("%04d/%02d",$tm->year+1900,$tm->mon+1);
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3