[Bio] / FigKernelPackages / UnvSubsys.pm Repository:
ViewVC logotype

View of /FigKernelPackages/UnvSubsys.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sun Sep 11 23:44:46 2005 UTC (14 years, 4 months ago) by overbeek
Branch: MAIN
add UnvSubsys.pm

package UnvSubsys;

use Carp;
use FIG;

use Data::Dumper;
use strict;

sub new
{
    my($class, $ssa, $fig, $colors, $aliases) = @_;

    $ssa =~ s/ /_/g;


	### format for one_sub = [Roles,ToRoleIndexHash,ColSubsets,Genomes,ToGenomeIndexHash,PegHash,ColorHash,AliasHash]
	### 
	### Roles = pointer to a list of [Role,Abbrev,[ReactionURLs]]
	###
	### ToRoleIndexHash = a pointer to a hash: key=Role Value=RoleIndex
	###
	### ColSubsets = pointer to a list of [SubsetName,[RoleIndexesFrom0]]
	### 
	### Genomes is a pointer to a list of [Genome,Variant]
	###
	### ToGenomeIndexHash = a pointer to a hash: key=Genome value=GenomeIndex
	###
	### PegHash = a pointer to a hash of hashes such that $peg_hash->{$genome_index}->{$role_index} = a
	###           pointer to a list of PEGs
	###
	### ColorHash is a hash: key=PEG value=color
	###
	### AliasHash is a hash: key=PEG value=aliases
	###

    if (ref($fig) eq "FIG")
    {
	my $subsystem = new Subsystem($ssa,$fig,0);

	my @roles = $subsystem->get_roles;
	my $reactions = $subsystem->get_reactions;
	my @genomes = $subsystem->get_genomes;
        my @col_subsets = $subsystem->get_subset_namesC;

	my $role_info = [];
	my $roleH     = {};

	my($i,$j,$subset,$peg);
	for ($i=0; ($i < @roles); $i++)
	{
	    my $role = $roles[$i];
	    my $abbrev = $subsystem->get_role_abbr( $subsystem->get_role_index( $role ) );
	    my $react = $reactions ? join(",", map { &HTML::reaction_link($_) } @{$reactions->{$role}}) : [];
	    push(@$role_info,[$role,$abbrev,$react]);
	    $roleH->{$role} = $i;
	}

	my $subset_info = [];
	foreach $subset (@col_subsets)
	{
	    if ($subset ne 'All')
	    {
		push(@$subset_info,[$subset,[$subsystem->get_subsetC_roles($subset)]]);
	    }
	}

	my $genomes_info = [];
	my $genomeH      = {};
	for ($i=0; ($i < @genomes); $i++)
	{
	    my $genome  = $genomes[$i];
	    my $variant = $subsystem->get_variant_code( $subsystem->get_genome_index( $genome ) );
	    push(@$genomes_info,[$genome,$variant]);
	    $genomeH->{$genome} = $i;
	}

	my $pegH = {};
	for ($i=0; ($i < @genomes); $i++)
	{
	    my $genome = $genomes[$i];
	    for ($j=0; ($j < @roles); $j++)
	    {
		my $role = $roles[$j];
		my @pegs = $subsystem->get_pegs_from_cell($genome,$role);
		$pegH->{$i}->{$j} = [@pegs];
	    }
	}
	
	my $colorsH  = $colors  ? &set_colors($fig,$pegH)  : {};
	my $aliasesH = $aliases ? &set_aliases($fig,$pegH) : {};
	    
	my $self = [$role_info,$roleH,$subset_info,$genomes_info,$genomeH,$pegH,$colorsH,$aliasesH];
	bless($self, $class);
	return $self;
    }
    else
    {
	return undef;
    }
}

1;



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3