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

View of /FigKernelScripts/generate_subsys_tables_for_sprout.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sat Dec 4 22:16:06 2004 UTC (15 years, 4 months ago) by overbeek
Branch: MAIN
add code for generrating sprout tables

$usage = "usage: generate_subsys_tables_for_sprout RelationsDir;

($dir = shift @ARGV)
    || die $usage;

(-d $dir) || mkdir($dir,0777) || die "could not make $dir";

open(SUBSYS,">$dir/Subsystem") || die "could not open $dir/Subsystem";
open(OCCURSIN,">$dir/OccursInSubsystem") || die "could not open $dir/OccursInSubsystem";
open(OCCURSIN2,">$dir/ParticipatesIn") || die "could not open $dir/ParticipatesIn";
open(SSCELL,">$dir/SSCell") || die "could not open $dir/SSCell";
open(CONTAINSFEATURE,">$dir/ContainsFeature") || die "could not open ContainsFeature";
open(ISROLEOF,">$dir/IsRoleOf") || die "$dir/IsRoleOf";
open(ISGENOMEOF,">$dir/IsGenomeOf") || die "$dir/IsGenomeOf";

use FIG;
my $fig = new FIG;

%genomes = map { $_ =~ /^(\d+\.\d+)/; $1 => 1 } `cat genomes`;

@sub = $fig->all_subsystems;
for ($subN=0; ($subN < @sub); $subN++)
{
    $sub = $sub[$subN];
    print SUBSYS "$sub\n";
    @genomes = map { $_->[0] } grep { $genomes{$_->[0]} } @{$fig->subsystem_genomes($sub)};
    @roles = $fig->subsystem_to_roles($sub);

    foreach $genome (@genomes)
    {
        print OCCURSIN2 join("\t",($genome,$sub)),"\n";
    }

    foreach $role (@roles)
    {
        print OCCURSIN join("\t",($role,$sub)),"\n";
    }

    for ($genomeN=0; ($genomeN < @genomes); $genomeN++)
    {
        $genome = $genomes[$genomeN];

        for ($roleN=0; ($roleN < @roles); $roleN++)
        {
            $role = $roles[$roleN];
            @pegs = $fig->pegs_in_subsystem_cell($sub,$genome,$role);
            if (@pegs > 0)
            {
                $id = join(":",($subN,$genomeN,$roleN));
                print SSCELL "$id\n";
                print ISROLEOF "$role\t$id\n";
                print ISGENOMEOF "$genome\t$id\n";

                foreach $peg (@pegs)
                {
                    print CONTAINSFEATURE "$id\t$peg\n";
                }
            }
        }
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3