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

Diff of /FigKernelPackages/FIG.pm

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

revision 1.194, Mon Jan 3 02:23:12 2005 UTC revision 1.195, Wed Jan 5 16:19:44 2005 UTC
# Line 787  Line 787 
787    
788  =head1 get_release_info  =head1 get_release_info
789    
790  Return the current data release information. This will be a tuple or a  Return the current data release information.  It is returned as the list
791  hash or something, but the format is not yet defined so we return  ($name, $id, $inst, $email, $parent_id, $description).
792  undef.  
793    The release info comes from the file FIG/Data/RELEASE. It is formatted as:
794    
795    <release-name>
796    <unique id>
797    <institution>
798    <contact email>
799    <unique id of data release this release derived from>
800    <description>
801    
802    For instance:
803    -----
804    SEED Data Release, 09/15/2004.
805    4148208C-1DF2-11D9-8417-000A95D52EF6
806    ANL/FIG
807    olson@mcs.anl.gov
808    
809    Test release.
810    -----
811    
812    If no RELEASE file exists, this routine will create one with a new unique ID. This
813    lets a peer optimize the data transfer by being able to cache ID translations
814    from this instance.
815    
816  =cut  =cut
817    
818  sub get_release_info  sub get_release_info
819  {  {
820      my($self) = @_;      my($fig) = @_;
821    
822        my $rel_file = "$FIG_Config::data/RELEASE";
823    
824        if (! -f $rel_file)
825        {
826            #
827            # Create a new one.
828            #
829    
830            my $newid = `uuidgen`;
831            if (!$newid)
832            {
833                die "Cannot run uuidgen: $!";
834            }
835    
836            chomp($newid);
837    
838            my $relinfo = "Automatically generated release info " . localtime();
839            my $inst = "Unknown";
840            my $contact = "Unknown";
841            my $parent = "";
842            my( $a, $b, $e, $v, $env ) = $fig->genome_counts;
843            my $description = "Automatically generated release info\n";
844            $description .= "Contains $a archaeal, $b bacterial, $e eukaryal, $v viral and $env environmental genomes.\n";
845    
846            my $fh = new FileHandle(">$rel_file");
847            if (!$fh)
848            {
849                warn "error creating $rel_file: $!";
850                return undef;
851            }
852            print $fh "$relinfo\n";
853            print $fh "$newid\n";
854            print $fh "$inst\n";
855            print $fh "$contact\n";
856            print $fh "$parent\n";
857            print $fh $description;
858            $fh->close();
859            chmod(0444, $rel_file);
860        }
861    
862        if (open(my $fh, $rel_file))
863        {
864            my(@lines) = <$fh>;
865            close($fh);
866    
867            chomp(@lines);
868    
869            my($info, $id, $inst, $contact, $parent, @desc) = @lines;
870    
871            return ($info, $id, $inst, $contact, $parent, join("\n", @desc));
872        }
873    
874      return undef;      return undef;
875  }  }

Legend:
Removed from v.1.194  
changed lines
  Added in v.1.195

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3