[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.18, Mon Mar 31 19:17:09 2008 UTC revision 1.19, Wed Oct 15 21:21:33 2008 UTC
# Line 128  Line 128 
128    
129  sub process_init  sub process_init
130  {  {
131      my ($ss_name,$scenario_name,$genome,$assembly,$additional_reactions_for_org) = @_;      my ($ss_name,$scenario_name,$genome,$assembly) = @_;
132      my (%sc_inputs, %sc_outputs);      my (%sc_inputs, %sc_outputs);
133    
134      if ($genome eq "")      if ($genome eq "")
# Line 152  Line 152 
152      }      }
153      else      else
154      {      {
155          my %reactions_for_genome = $subsystem->get_hope_reactions_for_genome($genome);          my %reactions_for_genome = get_reactions_for_genome_subsystem($genome,$ss_name);
156          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;
         map { $ss_reactions{$_} = 1 } @$additional_reactions_for_org if defined $additional_reactions_for_org;  
157      }      }
158    
159      map { $sc_inputs{$_} = 1 } @{$scenario_data->{inputs}};      map { $sc_inputs{$_} = 1 } @{$scenario_data->{inputs}};
# Line 186  Line 185 
185      }      }
186    
187      #for now we do this outside of the if statment, but that might need to change      #for now we do this outside of the if statment, but that might need to change
188      &load_substrate_and_product_arrays(\%sc_reactions,$scenario_data->{map_ids});      &load_substrate_and_product_arrays(\%sc_reactions,$scenario_data->{map_ids}, \%sc_inputs);
189    
190    
191    
# Line 408  Line 407 
407    
408  sub load_substrate_and_product_arrays  sub load_substrate_and_product_arrays
409  {  {
410      my ($reactions, $map_ids) = @_;      my ($reactions, $map_ids, $sc_inputs) = @_;
411    
412      # determine whether the reaction is in one of the maps, and get directionality accordingly      # determine whether the reaction is in one of the maps, and get directionality accordingly
413      my (%reactions_in_maps, %reactions_not_in_maps, %reactions_not_in_any_map);      my (%reactions_in_maps, %reactions_not_in_maps, %reactions_not_in_any_map);
# Line 604  Line 603 
603          {          {
604              if (defined $cpd_array)              if (defined $cpd_array)
605              {              {
606                    my $at_least_one_is_main = 0;
607    
608                  foreach my $cinfo (@{$cpd_array})                  foreach my $cinfo (@{$cpd_array})
609                  {                  {
610                      my $cpd = $cinfo->[0];                      my $cpd = $cinfo->[0];
611                      if ($all_compounds_to_main{$cpd})                      if ($all_compounds_to_main{$cpd} || exists $sc_inputs->{$cpd})
612                      {                      {
613                          print STDERR "\t Setting $cpd to main\n";                          print STDERR "\t Setting $cpd to main\n" if $debug;
614                          $cinfo->[2] = 1;                          $cinfo->[2] = 1;
615                            $at_least_one_is_main = 1;
616                        }
617                    }
618    
619                    if ($at_least_one_is_main == 0)
620                    {
621                        foreach my $cinfo (@{$cpd_array})
622                        {
623                            my $cpd = $cinfo->[0];
624                            print STDERR "\t Setting $cpd to provisional main\n" if $debug;
625                            $cinfo->[2] = 2;
626                      }                      }
627                  }                  }
628              }              }
629          }          }
   
630      }      }
631  }  }
632    
# Line 725  Line 736 
736              {              {
737                  my $cpd = @{$substr}[0];                  my $cpd = @{$substr}[0];
738                  my $stoich = @{$substr}[1];                  my $stoich = @{$substr}[1];
739                  my $main = @{$substr}[2] || @all_compounds_to_main{$cpd}; #main either way                  my $is_it_main = @{$substr}[2];
740                  $main_substrates{$cpd} = 1 if $main;                  my $main = $is_it_main == 1 || @all_compounds_to_main{$cpd}; #main either way
741    
742                    if ($is_it_main == 2)
743                    {
744                        # provisionally main - need to see if there is a token that has visited
745                        # this compound
746    
747                        foreach my $token_id (keys %{$compounds_to_tokens{$cpd}})
748                        {
749                            my %visited_compounds = %{$tokens{$token_id}->{visited_compounds}};
750                            $main = 1 if exists $visited_compounds{$cpd};
751                        }
752                    }
753    
754                    $main_substrates{$cpd} = 1 if $main;
755                  print STDERR "\t\tSubstrate: $cpd\tstoich: $stoich\tmain: $main\n" unless !$debug;                  print STDERR "\t\tSubstrate: $cpd\tstoich: $stoich\tmain: $main\n" unless !$debug;
756    
757                  if (! $main)                  if (! $main)
# Line 2706  Line 2730 
2730    
2731  sub load_scenario  sub load_scenario
2732  {  {
2733      my ($genome,$ssa,$scenario,$additional_reactions_for_org) = @_;      my ($genome,$ssa,$scenario) = @_;
2734    
2735      #load up the arrays with the info we need      #load up the arrays with the info we need
2736      process_init($ssa,$scenario,$genome,0,$additional_reactions_for_org);      process_init($ssa,$scenario,$genome,0);
2737    
2738      #assume all path inputs and outputs are main      #assume all path inputs and outputs are main
2739      map { $all_compounds_to_main{$_} = 1 } keys %all_inputs;      map { $all_compounds_to_main{$_} = 1 } keys %all_inputs;
# Line 2719  Line 2743 
2743    
2744  sub internal_scenario  sub internal_scenario
2745  {  {
2746      my ($genome,$ssa,$scenario,$find_first,$additional_reactions_for_org) = @_;      my ($genome,$ssa,$scenario,$find_first) = @_;
2747    
2748      print STDERR "\nIn internal_scenario with '$genome', '$ssa', '$scenario', '$find_first'\n" if $debug;      print STDERR "\nIn internal_scenario with '$genome', '$ssa', '$scenario', '$find_first'\n" if $debug;
2749    
2750      load_scenario($genome,$ssa,$scenario,$additional_reactions_for_org);      load_scenario($genome,$ssa,$scenario);
2751    
2752      return execute_paths([],$find_first,[],[]);      return execute_paths([],$find_first,[],[]);
2753  }  }
2754    
2755  sub run_scenario  sub run_scenario
2756  {  {
2757      my($genome,$superset,$subsystem,$scenario,$find_first,$additional_reactions_for_org) = @_;      my($genome,$superset,$subsystem,$scenario,$find_first) = @_;
2758      my $scenario_dir = $fig->model_directory($genome) . "/Scenarios/$superset/$subsystem/$scenario";      my $scenario_dir = $fig->model_directory($genome) . "/Scenarios/$superset/$subsystem/$scenario";
2759    
2760      system("rm", "-rf", $scenario_dir);      system("rm", "-rf", $scenario_dir);
# Line 2738  Line 2762 
2762    
2763      #make sure the arrays are empty to start out      #make sure the arrays are empty to start out
2764      &clear_arrays;      &clear_arrays;
2765      write_scenario(internal_scenario($genome,$subsystem,$scenario,$find_first,$additional_reactions_for_org),$scenario_dir);      write_scenario(internal_scenario($genome,$subsystem,$scenario,$find_first),$scenario_dir);
2766  }  }
2767    
2768  sub compare_scenario  sub compare_scenario
# Line 2763  Line 2787 
2787      }      }
2788      else      else
2789      {      {
2790          my %reactions_for_genome = $subsystem->get_hope_reactions_for_genome($genome);          my %reactions_for_genome = get_reactions_for_genome_subsystem($genome,$ss_name);
2791          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;
2792      }      }
2793    
# Line 3842  Line 3866 
3866    
3867      return \%peg_to_scenario;      return \%peg_to_scenario;
3868  }  }
3869    
3870    sub get_reactions_for_genome_subsystem
3871    {
3872        my ($genome_id, $ss_name) = @_;
3873    
3874        my $ss_txt = "$FIG_Config::global/Models/hope_supersets.txt";
3875        my $ss_name_esc = $ss_name;
3876        $ss_name_esc =~ s/\(/\\(/g;
3877        $ss_name_esc =~ s/\)/\\)/g;
3878    
3879        my $temp = `grep $ss_name_esc $ss_txt`;
3880        my ($superset, $junk) = split "\t", $temp;
3881        my $pathdir_org = $fig->model_directory($genome_id);
3882        my $file_path = "$pathdir_org/Curation/Scenarios/$superset/$ss_name/included_reactions_for_org";
3883        my $subsystem = $fig->get_subsystem($ss_name);
3884    
3885        my %reactions_for_genome = $subsystem->get_hope_reactions_for_genome($genome_id);
3886        if (open (INCLUDEDRXNS, $file_path))
3887        {
3888            my @included_reactions = (<INCLUDEDRXNS>);
3889            close INCLUDEDRXNS;
3890            chomp (@included_reactions);
3891            map { $reactions_for_genome{$_} = 1 } @included_reactions;
3892        }
3893    
3894        return %reactions_for_genome;
3895    }
3896  1;  1;

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3