src/hg/encode/encodeLoad/doEncodeLoad.pl 1.72

1.72 2010/03/15 22:21:53 krish
added script to generate changes notes for ENCODE tracks
Index: src/hg/encode/encodeLoad/doEncodeLoad.pl
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/encodeLoad/doEncodeLoad.pl,v
retrieving revision 1.71
retrieving revision 1.72
diff -b -B -U 4 -r1.71 -r1.72
--- src/hg/encode/encodeLoad/doEncodeLoad.pl	6 Oct 2009 00:52:26 -0000	1.71
+++ src/hg/encode/encodeLoad/doEncodeLoad.pl	15 Mar 2010 22:21:53 -0000	1.72
@@ -1,12 +1,11 @@
 #!/usr/bin/env perl
 
-# encodeLoad.pl - load ENCODE data submission generated by the
-#                       automated submission pipeline
-# Reads load.ra for information about what to do
+# encodeLoad.pl - load ENCODE data submission generated by the automated
+# submission pipeline Reads load.ra for information about what to do
 
-# Writes error or log information to STDOUT
-# Returns 0 if load succeeds and sends email to wrangler for lab specified in the DAF
+# Writes error or log information to STDOUT Returns 0 if load succeeds and
+# sends email to wrangler for lab specified in the DAF
 
 # DO NOT EDIT the /cluster/bin/scripts copy of this file --
 # edit the CVS'ed source at:
 # $Header$
@@ -144,12 +143,15 @@
         my $safe = SafePipe->new(CMDS => \@cmds, STDOUT => "/dev/null", STDERR => $stderrFile, DEBUG => $opt_debug);
         if(my $err = $safe->exec()) {
             print STDERR "ERROR: File(s) $fileList failed wiggle load:\n\n";
             dieFile($stderrFile);
-        } elsif (system("rm -f /gbdb/$assembly/wib/$tableName.wib") ||
-                 system("ln -s $submitPath/$tableName.wib /gbdb/$assembly/wib")) {
+        }
+
+        if (system("rm -f /gbdb/$assembly/wib/$tableName.wib") ||
+                 system("ln -s $gbdbDir/$tableName.wib /gbdb/$assembly/wib")) {
             die("ERROR: failed wiggle load ln\n");
-        } else {
+        }
+
             print "$fileList loaded into $tableName\n";
 
             # retrieve lower and upper limits from $stderrFile and fix-up trackDb.ra file to add this to wig type line
             my $lines = Encode::readFile($stderrFile);
@@ -163,9 +165,8 @@
                     !system($cmd) || die "trackDb.ra update failed: $?\n";
                 }
             }
         }
-    }
     push(@{$pushQ->{TABLES}}, $tableName);
     push(@{$pushQ->{FILES}}, "$submitPath/$tableName.wib");
 }
 
@@ -320,8 +321,9 @@
     }
 } else {
     $configPath = "$submitDir/../config"
 }
+print $configPath, "\n";
 
 my $grants = Encode::getGrants($configPath);
 my $fields = Encode::getFields($configPath);
 my $daf = Encode::getDaf($submitDir, $grants, $fields);
@@ -366,9 +368,9 @@
     }
     if(!(-e $unloader)) {
         die "Can't find unloader ($unloader)\n";
     }
-    if(system("$unloader $submitType $submitPath")) {
+    if(system("$unloader -configDir $configPath $submitType $submitPath")) {
         die "unload script failed\n";
     }
 
     #TODO change to : FileUtils.cp $loadRa, $unloadRa
@@ -393,15 +395,15 @@
 HgAutomate::verbose(2, "loadRa ($loadRa) has: " . scalar(keys %ra) . " records\n");
 
 my $compositeTrack = Encode::compositeTrackName($daf);
 my $downloadDir = Encode::downloadDir($daf);
+my $gbdbDir = Encode::gbdbDir($daf);
+
+# make the download dir if it doesn't exist
 if(!$opt_skipDownload and !(-d $downloadDir)) {
-    # Change of plans: simlink to /cluster/data/encode/pipeline/downloads
-    if(!(-d "/cluster/data/encode/pipeline/downloads/$compositeTrack")) {
-        mkdir "/cluster/data/encode/pipeline/downloads/$compositeTrack" || die ("Can't create download directory (error: '$!'); please contact your wrangler at: $email\n");
+    if(!(-d $downloadDir)) {
+        mkdir $downloadDir || die ("Can't create download directory (error: '$!'); please contact your wrangler at: $email\n");
     }
-    !system("/bin/ln -s /cluster/data/encode/pipeline/downloads/$compositeTrack $downloadDir") || die ("Can't link to download directory (error: '$!'); please contact your wrangler at: $email\n");
-    #mkdir $downloadDir || die ("Can't create download directory (error: '$!'); please contact your wrangler at: $email\n");
 }
 
 for my $key (keys %ra) {
     my $h = $ra{$key};
@@ -477,9 +479,9 @@
 	    if (! -d "$downloadDir/raw") {
 		mkdir "$downloadDir/raw" or die "Could not create dir [$downloadDir/raw] error: [$!]\n";
 		}
         }
-        $target =~ s/ //g;  # removes space in ".bed 6.gz" for example
+        $target =~ s/ //g;  # removes space in ".bed 5.gz" for example
         unlink($target);
         HgAutomate::verbose(2, "unlink($target)\n");
 
         if(@files == 1) {
@@ -569,27 +571,27 @@
 UNLOCK TABLES;
 _EOF_
 close(PUSHQ);
 
-if(-e $readmeFile) {
-    open(README, ">>$readmeFile") || die "SYS ERROR: Can't write '$readmeFile' file; error: $!\n";
-    print README "\n";
-} else {
-    open(README, ">$readmeFile") || die "SYS ERROR: Can't write '$readmeFile' file; error: $!\n";
-    print README <<END;
-This directory contains data generated by the $daf->{grant}/$daf->{lab} lab
-as part of the Encode project.
-
-Data is RESTRICTED FROM USE in publication until the restriction date
-noted for the given data file. See the ENCODE
-data release policy at:
-
-http://genome.ucsc.edu/encodeDCC/ENCODE_Consortia_Data_Release_Policy_2008-09-11.doc
-
-Files included in this directory:
-
-END
-}
+#if(-e $readmeFile) {
+#    open(README, ">>$readmeFile") || die "SYS ERROR: Can't write '$readmeFile' file; error: $!\n";
+#    print README "\n";
+#} else {
+#    open(README, ">$readmeFile") || die "SYS ERROR: Can't write '$readmeFile' file; error: $!\n";
+#    print README <<END;
+#This directory contains data generated by the $daf->{grant}/$daf->{lab} lab
+#as part of the Encode project.
+#
+#Data is RESTRICTED FROM USE in publication until the restriction date
+#noted for the given data file. See the ENCODE
+#data release policy at:
+#
+#http://genome.ucsc.edu/encodeDCC/ENCODE_Consortia_Data_Release_Policy_2008-09-11.doc
+#
+#Files included in this directory:
+#
+#END
+#}
 if(! -e $preambleFile ) {
     open(PREAMBLE, ">$preambleFile") || die "SYS ERROR: Can't write '$preambleFile' file; error: $!\n";
 
     # NOTE: can remove the CHANGE-ME comment if we switch to SSI for the hostname