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

View of /FigKernelScripts/make_assignments_fit_initial_css.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri May 6 18:41:04 2005 UTC (15 years ago) by overbeek
Branch: MAIN
add make_assignments_fig_initial_css

use FIG;
my $fig = new FIG;

$usage = "usage: make_assignments_fit_initial_css Prefix RecommenedAssignments Abbr1 Abbr2 ....";

(
 ($prefix = shift @ARGV) &&
 ($assF    = shift @ARGV) && open(ASSF,">$assF") &&
 (@ARGV > 0)
)
    || die $usage;

%change = map { $_ => 1 } @ARGV;

$/ = "\n//\n";
$_ = <STDIN>;
print $_;

($roles = <STDIN>) || die "bad input file";
chomp $roles;
@roles = map { $_ =~ /^(\S+)\t(\S.*\S)/; [$1,$change{$1} ? "$prefix: $2" : $2] } split(/\n/,$roles);
for ($i=0; ($i < @roles); $i++)
{
    ($abbr,$role) = @{$roles[$i]};
    print "$abbr\t$role\n";
}
$/ = "\n";

while (defined($_ = <STDIN>) && ($_ !~ /^\/\//))
{
    print $_;
    chop;
    @flds = split(/\t/,$_);
    $genome = $flds[0];

    undef %must_be;
    for ($i=2; ($i < @flds); $i++)
    {
	if ($flds[$i])
	{
	    foreach $peg (split(/,/,$flds[$i]))
	    {
		push(@{$must_be{$peg}},$roles[$i-2]->[1]);
	    }
	}
    }

    foreach $pegN (keys(%must_be))
    {
	$peg = "fig|$genome.peg.$pegN";
	$func  = $fig->function_of($peg);
	@funcs = split(/ [\@\/] |;\s+/,$func);
	@needed = @{$must_be{$pegN}};

	for ($i=0,$ok=1; ($i < @needed) && $ok; $i++)
	{
	    for ($j=0; ($j < @funcs) && ($funcs[$j] ne $needed[$i]); $j++) {}
	    $ok = ($j < @funcs);
	}
	if (! $ok)
	{
	    print ASSF "$peg\t",join(" / ",@needed),"\n";
	}
    }
}
close(ASSF);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3