src/hg/encode/encodeDownloadsPage/encodeDownloadsPage.pl 1.14

1.14 2009/06/18 00:26:10 tdreszer
Moved sub metadataLineToArrays to Encode.pm so that doEncodeValidate.pl can also use it
Index: src/hg/encode/encodeDownloadsPage/encodeDownloadsPage.pl
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/encodeDownloadsPage/encodeDownloadsPage.pl,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -B -U 4 -r1.13 -r1.14
--- src/hg/encode/encodeDownloadsPage/encodeDownloadsPage.pl	13 May 2009 17:29:21 -0000	1.13
+++ src/hg/encode/encodeDownloadsPage/encodeDownloadsPage.pl	18 Jun 2009 00:26:10 -0000	1.14
@@ -158,43 +158,8 @@
     }
     print OUT_FILE "</TR>\n";
 }
 
-sub metadataLineToArrays {
-# Creates pair of arrays that contain the settings in a metadata setting line (retains order)
-    my ($line) = @_;
-
-    my @tags;
-    my @vals;
-    my $tix = 0;
-    while($line && length($line)>0) {
-        my $tag;
-        my $val;
-        ( $tag,$line ) = split(/=/, $line,2);
-        $tag =~ s/\s+//g;
-        my @chars = split(//,$line);
-        if($chars[0] ne "\"") {
-            ( $val,$line ) = split(/\s+/, $line,2);
-        } else {
-            my $ix=1;
-            while($ix < length($line) && ($chars[$ix] ne '"' || $chars[$ix - 1] eq '\\')) {  # Find next " skipping escaped \"
-                $ix++;
-            }
-            if($ix < length($line)) {
-                $val  = substr($line,1,$ix - 1);
-                $line = substr($line,  $ix + 1);
-                $val  =~ s/\\"/\"/g;
-            } else {
-                $val = $line;
-                $line = "";
-            }
-        }
-        $tags[$tix  ] = $tag;
-        $vals[$tix++] = $val;
-    }
-    return ( \@tags, \@vals );
-}
-
 sub metadataArraysRemoveHash {
 # Removes members of hash from metadata Arrays
     my ($tagsRef,$valsRef,$removeRef) = @_;
     my @tags = @{$tagsRef};
@@ -378,9 +343,9 @@
     my $submitDate = "";
     my %metaData;
 
     ### TODO: Developer: set sort order here; sortables must have same number of strings and '~' is lowest val printable
-    my @sortFields = ("cell","dataType","rnaExtract","localization","fragSize","mapAlgorithm","ripAntibody","ripTgtProtein","antibody","lab","type","view","level","annotation","replicate","subId");
+    my @sortFields = ("cell","dataType","rnaExtract","localization","fragSize","mapAlgorithm","ripAntibody","ripTgtProtein","treatment","antibody","lab","type","view","level","annotation","replicate","subId");
     my @sortables = map( "~", (1..scalar(@sortFields))); # just has to have a tilde for each field
     my $typePrefix = "";
     my $results = $db->quickQuery("select type from $database.trackDb where tableName = '$tableName'");
     if($results) {
@@ -425,9 +390,9 @@
                 $metaData{$pair[0]} = $pair[1];
                 @sortables = sortablesSet( \@sortables,\@sortFields,$pair[0],$pair[1] );
             } elsif($pair[0] eq "metadata") {
                 # Use metadata setting with priority
-                my ( $tagRef, $valRef ) = metadataLineToArrays($pair[1]);
+                my ( $tagRef, $valRef ) = Encode::metadataLineToArrays($pair[1]);
                 my @tags = @{$tagRef};
                 my @vals = @{$valRef};
                 my $tix = 0;
                 while($tags[$tix]) {