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

View of /FigKernelScripts/make_annotations_for_sprout.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Sep 21 22:56:50 2004 UTC (15 years, 6 months ago) by overbeek
Branch: MAIN
Dump annotations for import to the SPROUT. (Supersedes `make_FIG_annotations_for_sprout.pl`) -- /gdp

# -*- perl -*-

use FIG;
($fig = new FIG) || die "FIG constructor failed";

$usage = "make_FIG_annotations_for_sprout GenomeFile AnnotationsFile IsTargetOfFile MadeAnnotationFile";

(@ARGV
&& ($genomes_file     = shift) && (-s $genomes_file)
&& ($annotations_file = shift)
&& ($istarget_file    = shift)
&& ($makeannot_file   = shift)
) || die "usage: $usage";

@genomes = grep { m/^(\S+)/; $_ = $1 } `cut -f1 $genomes_file`;

open(ANNOT,  ">$annotations_file") || die "could not write-open $annotations_file";
open(TARGET, ">$istarget_file")    || die "could not write-open $istarget_file";
open(MAKEAN, ">$makeannot_file")   || die "could not write-open $makeannot_file";

$time = time();
$tick = 0;
foreach $org (@genomes)
{
    print STDERR "Processing $org " if $ENV{FIG_VERBOSE};
    
    @pegs = sort { &FIG::by_fig_id($a,$b) } $fig->pegs_of($org);
    warn "No pegs for $org" unless @pegs;
    
    foreach $peg (@pegs)
    {
	if ($ENV{FIG_VERBOSE} && ($tick >= 1000)) { print STDERR '.'; $tick = 0; } else {++$tick; }
	
	if ($func = $fig->function_of($peg))
	{
	    if (!$fig->hypo($func))
	    {
		print ANNOT  "$peg:$time\t$time\tFIG\\nSet FIG function to\\n$func\n";
		print TARGET "$peg\t$peg:$time\n";
		print MAKEAN "FIG\t$peg:$time\n";
	    }
	    
	    if (@aliases = $fig->mapped_prot_ids($peg))
	    {
		foreach $alias_record (@aliases)
		{
		    $alias = $alias_record->[0];
		    $func  = $fig->function_of($alias);
		    
		    $user  = $setname = "";
		    if ($alias =~ m/^fig\|/)
		    {
			next;
		    }
		    elsif ($alias =~ m/^kegg\|/)
		    {
			$user = $setname = 'KEGG';
		    }
		    elsif ($alias =~ m/^gi\|/)
		    {
			$user = $setname = 'NCBI';
		    }
		    elsif ($alias =~ m/^(sp|tr|tn)\|/)
		    {
			$user = $setname = 'SwissProt';
		    }
		    elsif ($alias =~ m/^uni\|/)
		    {
			$user = $setname = 'UniProt';
		    }
		    else
		    {
			warn "could not handle alias $alias";
			next;
		    }
		    
		    if ($user && $setname && $func)
		    {
			print ANNOT  "$alias:$time\t$time\t$user\\nSet $setname function to\\n$func\n";
			print TARGET "$alias\t$alias:$time\n";
			print MAKEAN "FIG\t$alias:$time\n";
		    }
		}
	    }
	}
    }
    
    print STDERR "\n" if $ENV{FIG_VERBOSE};
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3