[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.19, Wed Oct 15 21:21:33 2008 UTC revision 1.20, Mon Nov 3 18:38:44 2008 UTC
# Line 313  Line 313 
313    
314      foreach my $path (@$assembly_paths)      foreach my $path (@$assembly_paths)
315      {      {
316          my $paths_dir = $fig->model_directory() . "/" . join "/" , @$path;          my $genome = shift @$path;
317            my $paths_dir = get_model_directory($genome) . "/" . join "/" , @$path;
318    
319          my $drxn = "$path->[-3]/$path->[-2]/$path->[-1]_R";          my $drxn = "$path->[-3]/$path->[-2]/$path->[-1]_R";
320    
# Line 2694  Line 2695 
2695      %all_outputs = ();      %all_outputs = ();
2696  }  }
2697    
   
 sub clear_dir_for_genome  
 {  
     my ($genome) = @_;  
     rmtree($fig->model_directory($genome));  
 }  
   
2698  sub load_superset_file  sub load_superset_file
2699  {  {
     my ($filename) = @_;  
   
2700      %superset_to_ss = ();      %superset_to_ss = ();
2701      %ss_to_superset = ();      %ss_to_superset = ();
2702    
2703      open(FILE,"<$filename") or die("Failed to open $filename");      open(FILE,"<$FIG_Config::global/Models/hope_supersets.txt") or die("Failed to open hope_supersets.txt");
2704      while(<FILE>)      while(<FILE>)
2705      {      {
2706          my @line = split(/\t/,$_);          my @line = split(/\t/,$_);
# Line 2755  Line 2747 
2747  sub run_scenario  sub run_scenario
2748  {  {
2749      my($genome,$superset,$subsystem,$scenario,$find_first) = @_;      my($genome,$superset,$subsystem,$scenario,$find_first) = @_;
2750      my $scenario_dir = $fig->model_directory($genome) . "/Scenarios/$superset/$subsystem/$scenario";      my $scenario_dir = get_model_directory($genome) . "/Scenarios/$superset/$subsystem/$scenario";
2751    
2752      system("rm", "-rf", $scenario_dir);      system("rm", "-rf", $scenario_dir);
2753      &FIG::verify_dir($scenario_dir);      &FIG::verify_dir($scenario_dir);
# Line 2769  Line 2761 
2761  {  {
2762      my($genome,$superset,$ss_name,$scenario_name,$dont_copy) = @_;      my($genome,$superset,$ss_name,$scenario_name,$dont_copy) = @_;
2763      my @genome_paths;      my @genome_paths;
2764      my $scenario_dir_all = $fig->model_directory('All') . "/Scenarios/$superset/$ss_name/$scenario_name";      my $scenario_dir_all = get_model_directory('All') . "/Scenarios/$superset/$ss_name/$scenario_name";
2765      my $subsystem = $fig->get_subsystem($ss_name);      my $subsystem = $fig->get_subsystem($ss_name);
2766      my @additional_reactions = $subsystem->get_hope_additional_reactions($scenario_name);      my @additional_reactions = $subsystem->get_hope_additional_reactions($scenario_name);
2767      my %additional_reactions;      my %additional_reactions;
# Line 2828  Line 2820 
2820    
2821      # now check all paths found for this particular organism, and make sure they      # now check all paths found for this particular organism, and make sure they
2822      # are in the appropriate All subdirectory      # are in the appropriate All subdirectory
2823      my $scenario_dir_genome = $fig->model_directory($genome). "/Scenarios/$superset/$ss_name/$scenario_name";      my $scenario_dir_genome = get_model_directory($genome). "/Scenarios/$superset/$ss_name/$scenario_name";
2824    
2825      opendir (DIR_GENOME,$scenario_dir_genome) or return \@genome_paths;      opendir (DIR_GENOME,$scenario_dir_genome) or return \@genome_paths;
2826      @sub_dirs  = readdir DIR_GENOME;      @sub_dirs  = readdir DIR_GENOME;
# Line 3067  Line 3059 
3059    
3060      my @ss_scenarios = $subsystem_obj->get_hope_scenario_names;      my @ss_scenarios = $subsystem_obj->get_hope_scenario_names;
3061    
3062      my $dir = $fig->model_directory($genome) . "/Scenarios/$superset/$subsystem";      my $dir = get_model_directory($genome) . "/Scenarios/$superset/$subsystem";
3063      system("rm", "-rf",  $dir);      system("rm", "-rf",  $dir);
3064      &FIG::verify_dir($dir);      &FIG::verify_dir($dir);
3065    
# Line 3134  Line 3126 
3126      my @subsystems = @{$superset_to_ss{$superset_name}};      my @subsystems = @{$superset_to_ss{$superset_name}};
3127    
3128    
3129      my $dir = $fig->model_directory($genome) . "/Scenarios/$superset_name";      my $dir = get_model_directory($genome) . "/Scenarios/$superset_name";
3130      system("rm", "-rf", $dir);      system("rm", "-rf", $dir);
3131      &FIG::verify_dir($dir);      &FIG::verify_dir($dir);
3132    
# Line 3165  Line 3157 
3157  sub load_supersets  sub load_supersets
3158  {  {
3159      my($genome) = @_;      my($genome) = @_;
3160        &load_superset_file;
3161    
3162      foreach my $superset (keys %superset_to_ss)      foreach my $superset (keys %superset_to_ss)
3163      {      {
3164          load_superset($genome,$superset);          load_superset($genome,$superset);
# Line 3177  Line 3171 
3171  sub run_supersets  sub run_supersets
3172  {  {
3173      my($genome,$find_first) = @_;      my($genome,$find_first) = @_;
3174        &load_superset_file;
3175    
3176        my $dir = get_model_directory($genome) . "/Scenarios/";
3177        system("rm", "-rf", $dir);
3178        &FIG::verify_dir($dir);
3179    
3180      foreach my $superset (keys %superset_to_ss)      foreach my $superset (keys %superset_to_ss)
3181      {      {
# Line 3190  Line 3189 
3189      my($genome, $dont_copy) = @_;      my($genome, $dont_copy) = @_;
3190      my %genome_supersets;      my %genome_supersets;
3191    
3192        &load_superset_file;
3193    
3194      foreach my $superset (keys %superset_to_ss)      foreach my $superset (keys %superset_to_ss)
3195      {      {
3196          $genome_supersets{$superset} = compare_superset($genome,$superset,$dont_copy);          $genome_supersets{$superset} = compare_superset($genome,$superset,$dont_copy);
# Line 3277  Line 3278 
3278          else #This is a assembly path          else #This is a assembly path
3279          {          {
3280              #read in the input/output compounds and mark main's correctly              #read in the input/output compounds and mark main's correctly
3281              my $path = $fig->model_directory() . "/" . join "/" , @$scenario;              my $genome = shift @$scenario;
3282                my $path = get_model_directory($genome) . "/" . join "/" , @$scenario;
3283    
3284              open(M_IN,"$path/inputs_main");              open(M_IN,"$path/inputs_main");
3285              while(<M_IN>)              while(<M_IN>)
# Line 3316  Line 3318 
3318      print STDERR $paths , "\n" , @$paths, "\n";      print STDERR $paths , "\n" , @$paths, "\n";
3319      print STDERR $genome . "\n";      print STDERR $genome . "\n";
3320      print STDERR $write_name . "\n";      print STDERR $write_name . "\n";
3321      my $dir = $fig->model_directory($genome) . "/Assemblies/$write_name";      my $dir = get_model_directory($genome) . "/Assemblies/$write_name";
3322      system("rm", "-rf", $dir);      system("rm", "-rf", $dir);
3323      &FIG::verify_dir($dir);      &FIG::verify_dir($dir);
3324      write_scenario(internal_assembly($paths,[],[],$one_path),$dir);      write_scenario(internal_assembly($paths,[],[],$one_path),$dir);
# Line 3364  Line 3366 
3366      if($count !=0)      if($count !=0)
3367      {      {
3368  #read this path, and pull out all the sub-directories.  #read this path, and pull out all the sub-directories.
3369          my $model_dir = $fig->model_directory() . "/$path/";          my $model_dir = get_model_directory() . "/$path/";
3370    
3371          print STDERR "reading directory $model_dir\n" if $debug;          print STDERR "reading directory $model_dir\n" if $debug;
3372          opendir (DIR, $model_dir) or die("$model_dir");          opendir (DIR, $model_dir) or die("$model_dir");
# Line 3432  Line 3434 
3434    
3435      #setup the filesystem to store the scenario/paths      #setup the filesystem to store the scenario/paths
3436      my $superset = $ss_to_superset{$ssa};      my $superset = $ss_to_superset{$ssa};
3437      my $base_dir = $fig->model_directory($genome) . "/Scenarios/$superset/$ssa/$sc_name/";      my $base_dir = get_model_directory($genome) . "/Scenarios/$superset/$ssa/$sc_name/";
3438      system("rm", "-rf", $base_dir);      system("rm", "-rf", $base_dir);
3439      &FIG::verify_dir($base_dir);      &FIG::verify_dir($base_dir);
3440    
# Line 3506  Line 3508 
3508      chomp $genome;      chomp $genome;
3509      chomp $name;      chomp $name;
3510      #setup the filesystem to store the assembly      #setup the filesystem to store the assembly
3511      my $base_dir = $fig->model_directory($genome). "/Assemblies/$name";      my $base_dir = get_model_directory($genome) . "/Assemblies/$name";
3512      system("rm", "-rf", $base_dir);      system("rm", "-rf", $base_dir);
3513      &FIG::verify_dir($base_dir);      &FIG::verify_dir($base_dir);
3514    
# Line 3711  Line 3713 
3713  sub analyze_scenario_connections  sub analyze_scenario_connections
3714  {  {
3715      my ($genome_id) = @_;      my ($genome_id) = @_;
3716      my $scenario_dir = $fig->model_directory($genome_id)."/Scenarios";      my $model_dir = get_model_directory($genome_id);
3717        my $scenario_dir = $model_dir  . "/Scenarios";
3718    
3719      #      #
3720      # Mac and Linux don't have the same find options for following symlinks.      # Mac and Linux don't have the same find options for following symlinks.
# Line 3770  Line 3773 
3773          close M_OUTPUTS;          close M_OUTPUTS;
3774      }      }
3775    
3776      my $analysis_dir = $fig->model_directory($genome_id) . "/Analysis";      my $analysis_dir = $model_dir . "/Analysis";
3777      #Commented out. was deleting model data from run_model_generation      #Commented out. was deleting model data from run_model_generation
3778      #rmtree $analysis_dir;      #rmtree $analysis_dir;
3779      mkdir $analysis_dir;      mkdir $analysis_dir;
# Line 3799  Line 3802 
3802          return undef;          return undef;
3803      }      }
3804      my %reaction_to_pegs;      my %reaction_to_pegs;
     my $ss_file = "$FIG_Config::global/Models/hope_supersets.txt";  
3805    
3806      my @ss_names;      my @ss_names;
3807      my %superset_to_ss = %{model::load_superset_file($ss_file)};      my %superset_to_ss = %{model::load_superset_file};
3808      foreach (keys %superset_to_ss)      foreach (keys %superset_to_ss)
3809      {      {
3810          foreach my $subsys (@{$superset_to_ss{$_}})          foreach my $subsys (@{$superset_to_ss{$_}})
# Line 3871  Line 3873 
3873  {  {
3874      my ($genome_id, $ss_name) = @_;      my ($genome_id, $ss_name) = @_;
3875    
3876      my $ss_txt = "$FIG_Config::global/Models/hope_supersets.txt";      # assume that the hope_supersets.txt has been loaded
3877      my $ss_name_esc = $ss_name;      # my $ss_txt = "$FIG_Config::global/Models/hope_supersets.txt";
3878      $ss_name_esc =~ s/\(/\\(/g;      # my $ss_name_esc = $ss_name;
3879      $ss_name_esc =~ s/\)/\\)/g;      # $ss_name_esc =~ s/\(/\\(/g;
3880        # $ss_name_esc =~ s/\)/\\)/g;
3881      my $temp = `grep $ss_name_esc $ss_txt`;  
3882      my ($superset, $junk) = split "\t", $temp;      # my $temp = `grep $ss_name_esc $ss_txt`;
3883      my $pathdir_org = $fig->model_directory($genome_id);      my $superset = $ss_to_superset{$ss_name};
3884        my $pathdir_org = get_model_directory($genome_id);
3885      my $file_path = "$pathdir_org/Curation/Scenarios/$superset/$ss_name/included_reactions_for_org";      my $file_path = "$pathdir_org/Curation/Scenarios/$superset/$ss_name/included_reactions_for_org";
3886      my $subsystem = $fig->get_subsystem($ss_name);      my $subsystem = $fig->get_subsystem($ss_name);
3887    
# Line 3893  Line 3896 
3896    
3897      return %reactions_for_genome;      return %reactions_for_genome;
3898  }  }
3899    
3900    sub get_model_directory
3901    {
3902        my ($genome) = @_;
3903        # want to match "All" and "All.bk", etc.
3904        return $genome =~ "^All" ? $FIG_Config::global."/Models/$genome" : $fig->model_directory($genome);
3905    
3906    }
3907    
3908  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3