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

Diff of /FigKernelPackages/P2Pupdate.pm

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

revision 1.36, Mon Aug 9 14:38:55 2004 UTC revision 1.37, Thu Sep 16 15:15:57 2004 UTC
# Line 523  Line 523 
523          {          {
524              &FIG::run("cp $fig_disk/BackupAnnotations/New/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");              &FIG::run("cp $fig_disk/BackupAnnotations/New/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");
525          }          }
526          chmod 02777,"$fig_disk/FIG/Data/Organisms/$genome/annotations";          chmod 0777,"$fig_disk/FIG/Data/Organisms/$genome/annotations";
527      }      }
528      &FIG::run("$FIG_Config::bin/index_annotations");      &FIG::run("$FIG_Config::bin/index_annotations");
529  }  }
# Line 550  Line 550 
550      {      {
551          unlink("$fig_disk/FIG/Data/Organisms/$genome/annotations");          unlink("$fig_disk/FIG/Data/Organisms/$genome/annotations");
552          &FIG::run("cp $fig_disk/BackupAnnotations/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");          &FIG::run("cp $fig_disk/BackupAnnotations/$genome $fig_disk/FIG/Data/Organisms/$genome/annotations");
553          system "chmod 2777 $fig_disk/FIG/Data/Organisms/$genome/annotations";          system "chmod 777 $fig_disk/FIG/Data/Organisms/$genome/annotations";
554      }      }
555      &FIG::run("$FIG_Config::bin/index_annotations");      &FIG::run("$FIG_Config::bin/index_annotations");
556  }  }
# Line 795  Line 795 
795      if (-s "$fig_disk/BackupTranslation_Rules/function.synonyms")      if (-s "$fig_disk/BackupTranslation_Rules/function.synonyms")
796      {      {
797          &FIG::run("cp $fig_disk/BackupTranslation_Rules/function.synonyms $file");          &FIG::run("cp $fig_disk/BackupTranslation_Rules/function.synonyms $file");
798          chmod 02777, $file;          chmod 0777, $file;
799      }      }
800  }  }
801    
# Line 830  Line 830 
830      &FIG::run("$FIG_Config::bin/import_subsystems master last_release < $package");      &FIG::run("$FIG_Config::bin/import_subsystems master last_release < $package");
831  }  }
832    
833    
834    =pod
835    
836    =head2 unpack_packaged_subsystem
837    
838    Unpack a packaged subsystem (from the clearinghouse or a p2p transfer)
839    into a directory; this will create a directory named as the subsystem
840    and formatted like the standard subsystem directories, as well as a
841    file of assignments and a file of sequences in fasta format.
842    
843    Returns the name of the subsystem.
844    
845    =cut
846    
847    sub unpack_packaged_subsystem
848    {
849        my($fig, $file, $target_dir) = @_;
850    
851        my $user = $fig->get_user();
852    
853        &FIG::verify_dir($target_dir);
854    
855        my $fh;
856    
857        if (!open($fh, "<$file"))
858        {
859            warn "unpack_packaged_subsystem: cannot open $file: $!";
860            return undef;
861        }
862    
863        #
864        # We scan the file, breaking it up into sections and writing
865        # to the appropriate places.
866        #
867        # First the header.
868        #
869    
870        local $/ = "\n//\n";
871    
872        my $header = <$fh>;
873        chomp $header;
874    
875        my ($name, $version, $exchangable, $curation) = split(/\n/, $header);
876    
877        print "Importing name=$name version=$version exch=$exchangable curation='$curation'\n";
878    
879        #
880        # Pull in roles, subsets, and spreadsheet. These will be written to the new
881        # spreadsheet file.
882        #
883    
884        my $roles = <$fh>;
885        chomp $roles;
886    
887        my $subsets = <$fh>;
888        chomp $subsets;
889    
890        my $spreadsheet = <$fh>;
891        chomp $spreadsheet;
892    
893    
894        #
895        # Pull the assignments and sequences. These go to their own files.
896        #
897    
898        my $assignments = <$fh>;
899        chomp $assignments;
900    
901        my $sequences = <$fh>;
902        chomp $sequences;
903    
904        #
905        # And the notes; these will be written to the subsystem dir.
906        #
907    
908        my $notes = <$fh>;
909        chomp $notes;
910    
911        close($fh);
912    
913        #
914        # Everything is read. Now to write it all back out again.
915        #
916    
917        #
918        # First the subsystem.
919        #
920    
921        my $ss_path = "$target_dir/subsystem";
922        &FIG::verify_dir($ss_path);
923    
924        open($fh, ">$ss_path/EXCHANGABLE");
925        print $fh "$exchangable\n";
926        close($fh);
927    
928        open($fh, ">$ss_path/VERSION");
929        print $fh "$version\n";
930        close($fh);
931    
932        open($fh, ">$ss_path/curation.log");
933        print $fh "$curation\n";
934        my $now = time;
935        print $fh "$now\t$user\timported\n";
936        close($fh);
937    
938        open($fh, ">$ss_path/notes");
939        print $fh "$notes\n";
940        close($fh);
941    
942        open($fh, ">$ss_path/spreadsheet");
943        print $fh "$roles\n";
944        print $fh "//\n";
945        print $fh "$subsets\n";
946        print $fh "//\n";
947        print $fh "$spreadsheet\n";
948        close($fh);
949    
950        open($fh, ">$target_dir/subsystem_name");
951        print $fh "$name\n";
952        close($fh);
953    
954        open($fh, ">$target_dir/assignments");
955        print $fh "$assignments\n";
956        close($fh);
957    
958        open($fh, ">$target_dir/seqs.fasta");
959        print $fh "$sequences\n";
960        close($fh);
961    
962        return $name;
963    }
964    
965  package SubsystemFile;  package SubsystemFile;
966    
967  use Data::Dumper;  use Data::Dumper;

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3