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

View of /FigKernelScripts/make_timestamps.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Tue Nov 21 18:20:53 2006 UTC (13 years ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.3: +2 -2 lines
add initial version of FIGO.pm - OO services

use FIG;
my $fig = new FIG;

$usage = "usage: make_timestamps SubsystemAssignments SubsystemConnections";

(
 ($assignF  = shift @ARGV) && open(ASSIGN,">$assignF") &&
 ($connF    = shift @ARGV) && open(CONN,">$connF")
)
    || die $usage;

foreach $sub (grep { $fig->usable_subsystem($_) } $fig ->all_subsystems)
{   
    undef %pegH;
    my $genomes = $fig->subsystem_genomes($sub);
    foreach $role ($fig->subsystem_to_roles($sub))
    {
        foreach $genome (map { $_->[0] } @$genomes)
        {
            foreach $peg ($fig->pegs_in_subsystem_cell($sub,$genome,$role))
            {
                $pegH{$peg} = 1;
                $curr_func = $fig->function_of($peg);
                @annotations = $fig->feature_annotations($peg,"raw");
                for ($i=$#annotations; ($i >= 0) && ($annotations[$i]->[3] !~ /^Set /); $i--) {}
                if (($i >= 0) && ($annotations[$i]->[3] =~ /^Set master function to\n(\S.*\S)/s))
                {
                    $ann_func = $1;
                    if (($curr_func eq $ann_func) && ($annotations[$i]->[2] !~ /auto|assign|repair|last|saved|cleanup/i))
                    {
			$annotations[$i]->[2] =~ s/^master://;
                        print ASSIGN join("\t",$annotations[$i]->[0],$annotations[$i]->[1],$annotations[$i]->[2],"assigned",$ann_func),"\n";
                    }
                }
            }
        }
    }
    &process_ss($fig,$sub,\%pegH);
}


sub process_ss {
    my($fig,$sub,$pegH) = @_;

    opendir(BACKUP,"$FIG_Config::data/Subsystems/$sub/Backup")
        || return ();

    my $curator = $fig->subsystem_curator($sub);
    $curator =~ s/^master://;

    my @spreadsheets = sort { $b <=> $a }
                       map { $_ =~ /^spreadsheet.(\d+)/; $1 }
                       grep { $_ =~ /^spreadsheet/ }
                       readdir(BACKUP);
    closedir(BACKUP);

    my $ts_last = time;
    foreach my $ts (@spreadsheets)
    {
	my $hash = {};
	my $file = "$FIG_Config::data/Subsystems/$sub/Backup/spreadsheet.$ts";
	if (open(SS,"<$file"))
	{
	    $/ = "//\n";
	    $_ = <SS>;
	    $_ = <SS>;
	    if (defined($_ = <SS>))
	    {
		chomp;
		@lines = split(/\n/,$_);
		foreach $_ (@lines)
		{
		    if ($_ =~ /^(\S+)\t\S+\t(.*)/)
		    {
			my $genome = $1;
			my @cells = split(/\t/,$2);
			foreach my $cell (@cells)
			{
			    foreach my $pegN (split(/,/,$cell))
			    {
				my $peg = "fig|$genome.peg.$pegN";
				if ($pegH->{$peg})
				{
				    $hash->{$peg} = 1;
				}
			    }
			}
		    }
		}
	    }

	    foreach $peg_in (keys(%$pegH))
	    {
		if (! $hash->{$peg_in})
		{
		    print CONN join("\t",($peg_in,$ts_last,$curator,"connected",$sub)),"\n";
		    delete($pegH->{$peg_in});
		}
	    }
	    close(SS);
	}
	$ts_last = $ts;
    }

    foreach $peg_in (keys(%$pegH))
    {
	    print CONN join("\t",($peg_in,$ts_last,$curator,"connected",$sub)),"\n";
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3