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

View of /FigKernelScripts/sort_by_function.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Jun 30 18:34:27 2011 UTC (8 years, 7 months ago) by disz
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_release_3_1_1, rast_rel_2011_0928, mgrast_dev_10262011
Write annotations by function

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

#
# be sure to source the config for the SEED you want to check these annotations against.
# 

if (scalar @ARGV != 1) {
	 die "Usage: sort_by_function seed\n";
 }

my %pegs;
my @annos;
my $seed = shift;
my $fig = new FIG;

    local $/ = "//\n";

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

    while (my $ann = <>)
    {
        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)) )
        {
		chop($fn);
		my $genome = $fig->genome_of($fid);
		my $old_fn = find_old_fn($fid);
		push (@annos, [$fid, $genome, $fn, $old_fn]);
		push (@{$pegs{$old_fn}{$fn}}, $fid);
		
	}
    }
    my %count;

for my $anno (@annos) {
	my ($peg, $genome, $new, $old) = @$anno;
	$count{$old}{$new}{$genome}++;
}

my $i = 0;
for my $old (sort (keys %count)){ 
	for my $new (keys %{$count{$old}}) {
		open (TMP, ">/vol/public-pseed/FIGdisk/FIG/Tmp/DAILY/$i");
		print TMP "<html><body>\n";
		print TMP "OLD: $old<br>NEW: $new<br>\n";
		for my $fid (@{$pegs{$old}{$new}}) {
			my $link = make_link($fid, $seed);
			print TMP "$link<br>\n";
	       }	
		print TMP "</body></html>\n";
	       close(TMP);
#		print "<dt>\n";
		my $g = $count{$old}{$new};
		my @c = values(%$g);
		my $c = scalar(@c);
		$old = $old ? $old : "None";
		my $msg = $c > 1 ? "In $c genomes" : "In $c genome";
		my $page_link = make_page_link($i, $msg); 
		print "<center>$page_link</center>\n<B><I>OLD:</I></B>&nbsp;$old<br>\n";
		print "<B><I>NEW:</I></B>&nbsp;$new<br><br>\n";
	       $i++;
	}
}
#print "</dl>\n";

sub find_old_fn {
	my ($peg) = @_;
	my $old = "none";
	my @annos = $fig->feature_annotations($peg);
	for (my $i = scalar(@annos) - 2; $i > 0; $i--) {
		my $ann = $annos[$i][3];
		if ($ann =~ /Set master function to\n(.*)/s) {
			$old = $1;
			$old =~ s/\n/ /g;
			last;
		}
	}
	return $old;
}


sub make_page_link {
	my ($page_num, $title) = @_;
	return "<a href='http://pubseed.theseed.org/FIG-Tmp/DAILY/$page_num' target='_blank'>$title</a>";
}
sub make_link {
	my ($id, $seed) = @_;
	return "<a href='http://$seed.theseed.org/linkin.cgi?id=$id' target='_blank'>$id</a>";
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3