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

Diff of /FigKernelPackages/model.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23, Wed Nov 12 18:19:12 2008 UTC revision 1.24, Thu Nov 13 21:54:41 2008 UTC
# Line 38  Line 38 
38  use strict;  use strict;
39  use Scenario;  use Scenario;
40  use FIG;  use FIG;
 use FIGV;  
41  use Subsystem;  use Subsystem;
42  use File::Path;  use File::Path;
43    
44  our $fig= new FIG;  my $fig= new FIG;
   
45    
46  #global variables that make process_paths work  #global variables that make process_paths work
47  #These need to be cleared and reloaded frequently for process path and flux writing  #These need to be cleared and reloaded frequently for process path and flux writing
# Line 78  Line 76 
76      return bless $self, $type;      return bless $self, $type;
77  }  }
78    
   
   
79  sub get_ss_scenarios  sub get_ss_scenarios
80  {  {
81      my ($ss_name) = @_;      my ($ss_name) = @_;
# Line 153  Line 149 
149      }      }
150      else      else
151      {      {
152          my %reactions_for_genome = get_reactions_for_genome_subsystem($genome,$ss_name);          my %reactions_for_genome = get_reactions_for_genome_in_subsystem($genome,$ss_name);
153          map { $ss_reactions{$_} = 1 } keys %reactions_for_genome if defined %reactions_for_genome;          map { $ss_reactions{$_} = 1 } keys %reactions_for_genome if defined %reactions_for_genome;
154      }      }
155    
# Line 2714  Line 2710 
2710      }      }
2711      close(FILE);      close(FILE);
2712    
2713      return \%superset_to_ss      return \%ss_to_superset
2714  }  }
2715    
2716  # This function runs a given scenario that is defined the specified subsystem  # This function runs a given scenario that is defined the specified subsystem
# Line 2780  Line 2776 
2776      }      }
2777      else      else
2778      {      {
2779          my %reactions_for_genome = get_reactions_for_genome_subsystem($genome,$ss_name);          my %reactions_for_genome = get_reactions_for_genome_in_subsystem($genome,$ss_name);
2780          map { $ss_reactions{$_} = 1 } keys %reactions_for_genome if defined %reactions_for_genome;          map { $ss_reactions{$_} = 1 } keys %reactions_for_genome if defined %reactions_for_genome;
2781      }      }
2782    
# Line 3804  Line 3800 
3800      my %reaction_to_pegs;      my %reaction_to_pegs;
3801    
3802      my @ss_names;      my @ss_names;
3803      my %superset_to_ss = %{model::load_superset_file};      &load_superset_file;
3804      foreach (keys %superset_to_ss)      foreach (keys %superset_to_ss)
3805      {      {
3806          foreach my $subsys (@{$superset_to_ss{$_}})          foreach my $subsys (@{$superset_to_ss{$_}})
# Line 3817  Line 3813 
3813      {      {
3814          my $subsystem = $fig->get_subsystem($subsystem_name);          my $subsystem = $fig->get_subsystem($subsystem_name);
3815          next if(!defined $subsystem);          next if(!defined $subsystem);
3816          my %reactions_for_ss = $subsystem->get_hope_reactions_for_genome($genome_id);          my %reactions_for_ss = get_reactions_for_genome_in_subsystem($genome_id,$subsystem_name);
3817          next if(!defined %reactions_for_ss);          next if(!defined %reactions_for_ss);
3818          foreach my $reaction (keys %reactions_for_ss)          foreach my $reaction (keys %reactions_for_ss)
3819          {          {
# Line 3877  Line 3873 
3873      my $debug = 0;      my $debug = 0;
3874      my $unreachable = 0;      my $unreachable = 0;
3875      chomp $genome_id;      chomp $genome_id;
     my $fig = new FIGV;  
3876    
3877      my @transports = split ("_", $transports);      my @transports = split ("_", $transports);
3878      my @biomass = split ("_", $biomass);      my @biomass = split ("_", $biomass);
# Line 4276  Line 4271 
4271      }      }
4272  }  }
4273    
4274  sub get_reactions_for_genome_subsystem  sub get_reactions_for_genome_in_subsystem
4275  {  {
4276      my ($genome_id, $ss_name) = @_;      my ($genome_id, $ss_name) = @_;
4277        my $subsystem = $fig->get_subsystem($ss_name);
4278        my %genome_reactions = ();
4279    
4280        my @roles = $subsystem->get_roles;
4281        my %hope_reactions = $subsystem->get_hope_reactions;
4282        my $index = $subsystem->get_genome_index($genome_id);
4283    
4284        if (defined $index)
4285        {
4286            foreach my $role (@roles)
4287            {
4288                my @peg_list = $subsystem->get_pegs_from_cell($genome_id,$role);
4289    
4290                if (defined $hope_reactions{$role} && scalar @peg_list > 0)
4291                {
4292                    foreach my $reaction (@{$hope_reactions{$role}})
4293                    {
4294                        push @{$genome_reactions{$reaction}}, @peg_list;
4295                    }
4296                }
4297            }
4298        }
4299        else
4300        {
4301            # the genome is not in the subsystem, but we can check for role assignments anyhow
4302            my $seqs = $fig->seqs_with_roles_in_genomes([$genome_id], \@roles);
4303    
4304            if (exists $seqs->{$genome_id})
4305            {
4306                foreach my $role (keys %{$seqs->{$genome_id}})
4307                {
4308                    my $peg_tuples = $seqs->{$genome_id}->{$role};
4309                    my @peg_list = map {$_->[0]} @{$peg_tuples};
4310    
4311                    if (defined $hope_reactions{$role} && scalar @peg_list > 0)
4312                    {
4313                        foreach my $reaction (@{$hope_reactions{$role}})
4314                        {
4315                            push @{$genome_reactions{$reaction}}, @peg_list;
4316                        }
4317                    }
4318                }
4319            }
4320        }
4321    
4322      # assume that the hope_supersets.txt has been loaded      # assume that the hope_supersets.txt has been loaded
4323      my $superset = $ss_to_superset{$ss_name};      my $superset = $ss_to_superset{$ss_name};
4324      my $pathdir_org = get_scenario_directory($genome_id);      my $pathdir_org = get_scenario_directory($genome_id);
4325      my $file_path = "$pathdir_org/Curation/PathInfo/$superset/$ss_name/included_reactions_for_org";      my $file_path = "$pathdir_org/Curation/PathInfo/$superset/$ss_name/included_reactions_for_org";
     my $subsystem = $fig->get_subsystem($ss_name);  
   
     my %reactions_for_genome = $subsystem->get_hope_reactions_for_genome($genome_id);  
4326      if (open (INCLUDEDRXNS, $file_path))      if (open (INCLUDEDRXNS, $file_path))
4327      {      {
4328          my @included_reactions = (<INCLUDEDRXNS>);          my @included_reactions = (<INCLUDEDRXNS>);
4329          close INCLUDEDRXNS;          close INCLUDEDRXNS;
4330          chomp (@included_reactions);          chomp (@included_reactions);
4331          map { $reactions_for_genome{$_} = 1 } @included_reactions;          map { $genome_reactions{$_} = 1 } @included_reactions;
4332      }      }
4333    
4334      return %reactions_for_genome;      return %genome_reactions;
4335  }  }
4336    
4337  sub get_scenario_directory  sub get_scenario_directory

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3