Index: src/hg/instinct/createDescriptionHTML/generateAllDescriptionHTMLs.pl
===================================================================
RCS file: src/hg/instinct/createDescriptionHTML/generateAllDescriptionHTMLs.pl
diff -N src/hg/instinct/createDescriptionHTML/generateAllDescriptionHTMLs.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/hg/instinct/createDescriptionHTML/generateAllDescriptionHTMLs.pl	9 Sep 2009 18:31:27 -0000	1.1
@@ -0,0 +1,81 @@
+#!/usr/bin/perl -w
+
+#######################################################################
+# cszeto Sept.09; This is a script to run createDescriptionHTML.pl    # 
+# on all the names in the specified datasets.ra this program can read.#
+#######################################################################
+
+my $datasetsFile = "";
+my $whoami = `whoami`;
+chomp($whoami);
+if(!defined($ARGV[0])){
+    print "ERROR: Incorrect usage.\n";
+    printHelp();
+}else{
+    $datasetsFile = shift;
+}
+
+
+my $local_output = $datasetsFile;
+$local_output =~ s/^.+\/(.+)$/local_$1/g;
+open(INFILE, $datasetsFile) || die "Couldn't open $datasetsFile\n";
+open(OUTFILE, ">$local_output") || die "Couldn't open temporary .ra file $local_output.ra\n";
+my @includes  = ();
+my $path = $datasetsFile; 
+$path =~ s/^(.+)\/.+$/$1/g;
+my $local_url = "";
+while(<INFILE>){
+    chomp($_);
+    if($_ =~ m/^#include/){ #if it's an include, at it to the list of files to run this over.
+        my $tmp = $_;
+        $tmp =~ s/^#include (.+)/$path\/$1/g;
+        push(@includes, $tmp);
+    }elsif($_ =~ m/^name /){
+        my $name = $_;
+        $name =~ s/^[^ ]+ (.+)$/$1/g; 
+        $local_url = `perl createSingleDescriptionHTML.pl $name $datasetsFile`;
+        $local_url =~ s/\n/ /g;
+        if($local_url !~ m/Success/){
+            print "ERROR: Something went wrong trying to run createDescriptionHTML.pl on $name dataset.\n";
+            print "Output was $local_url\n";
+            print "Exiting..\n";
+            exit(1);
+        }
+        if($local_url =~ m/ local_url/){
+            $local_url =~ s/.* (local_url .+)$/$1/g;
+        }
+    } 
+    if($_ =~ m/^local_url/ && $local_url eq ""){
+        print OUTFILE "$_\n";
+    }elsif($_ !~ m/^local_url/){
+        if($_ =~ m/^\s*$/){
+            if($local_url ne ""){
+                print OUTFILE "$local_url\n";
+                $local_url = "";
+            }
+            print OUTFILE "$_\n";
+        }else{
+            print OUTFILE "$_\n";
+        }
+    }
+}
+if($local_url ne ""){
+    print OUTFILE "$local_url\n\n";
+}
+close(OUTFILE);
+close(INFILE);
+print "Success!\n";
+`mv $local_output $datasetsFile`;
+
+foreach $include (@includes){
+    print "Running over included file $include\n";
+    my $output = `perl generateAllDescriptionHTMLs.pl $include`;
+    print "$output\n";
+}
+
+sub printHelp {
+    print "Usage:\n\$perl generateAllDescriptionHTMLs.pl [datasets.ra file]\n";
+    print "Generates HTML files for all the entrys in datasets.ra file, and creates a new datasets.ra file to replace\n";
+    print "the one given at command line with called output.ra. Check this file before replacing the original\n";
+    exit(1);
+}

