src/hg/encode/encodeValidate/doEncodeValidate.pl 1.221

1.221 2010/04/22 19:56:50 tdreszer
Added defaulting of setType and inputType which are needed for ChIPseq submissions.
Index: src/hg/encode/encodeValidate/doEncodeValidate.pl
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/encodeValidate/doEncodeValidate.pl,v
retrieving revision 1.220
retrieving revision 1.221
diff -b -B -U 4 -r1.220 -r1.221
--- src/hg/encode/encodeValidate/doEncodeValidate.pl	21 Apr 2010 19:28:07 -0000	1.220
+++ src/hg/encode/encodeValidate/doEncodeValidate.pl	22 Apr 2010 19:56:50 -0000	1.221
@@ -159,14 +159,14 @@
 our %validators = (
     files => \&validateFiles,
     view => \&validateDatasetName,
     labVersion => \&validateNoValidation,
-    setType => \&validateNoValidation,
     inputType => \&validateNoValidation,
     softwareVersion => \&validateNoValidation,
     accession => \&validateNoValidation,
     replicate => \&validateNoValidation,
     fragLength => \&validateNoValidation,
+    setType => \&validateSetType,
     cell => \&validateControlledVocabOrControl,
     antibody => \&validateControlledVocabOrControl,
     ripAntibody => \&validateControlledVocabOrControl,
     treatment => \&validateControlledVocabOrControl,
@@ -240,8 +240,16 @@
 # No validation
     return ();
 }
 
+sub validateSetType {
+    my ($val, $type) = @_;
+    if($val ne 'exp' && $val ne 'input') {
+        return ("Controlled Vocabulary \'$type\' value \'$val\' must be either \'exp\' or \'input\'");
+    }
+    return ();
+}
+
 # project-specific validators
 
 sub validateControlledVocabOrControl {
     my ($val, $type) = @_;
@@ -1705,8 +1713,33 @@
         && $key ne 'softwareVersion') {
             $metadata .= " $key=$value"; # and the rest
         }
     }
+    if($daf->{dataType} =~/ChIPseq/i) {
+        if(!$ddfLine->{setType}) {
+            if($ddfLine->{antibody} =~/Input/i ) {
+                $metadata .= " setType=input";
+            } else {
+                $metadata .= " setType=exp";
+            }
+        }
+        if(!$ddfLine->{inputType}) {
+            my $inputType = $ddfLine->{cell};
+            $inputType .= "/" . $ddfLine->{treatment} if $ddfLine->{treatment};
+            $inputType .= "/Input"; # default inputType for ChIPseq is "Input" instead of antibody
+            $inputType .= "/" . $ddfLine->{protocol} if $ddfLine->{protocol};
+            $inputType .= "/" . $ddfLine->{control} if $ddfLine->{control};
+            $metadata .= " inputType=$inputType";
+        }
+    }
+    if(!$ddfLine->{inputType} && $daf->{dataType} =~/ChIPseq/i) {
+        my $inputType = $ddfLine->{cell};
+        $inputType .= "/" . $ddfLine->{treatment} if $ddfLine->{treatment};
+        $inputType .= "/Input"; # default inputType for ChIPseq is "Input" instead of antibody
+        $inputType .= "/" . $ddfLine->{protocol} if $ddfLine->{protocol};
+        $inputType .= "/" . $ddfLine->{control} if $ddfLine->{control};
+        $metadata .= " inputType=$inputType";
+    }
     $metadata .= " view=$view";
     $metadata .= " replicate=$ddfLine->{replicate}" if $ddfLine->{replicate} && $daf->{TRACKS}{$view}{hasReplicates};
     $metadata .= " labVersion=$ddfLine->{labVersion}" if $ddfLine->{labVersion};
     $metadata .= " softwareVersion=$ddfLine->{softwareVersion}" if $ddfLine->{softwareVersion};
@@ -1729,8 +1762,9 @@
         }
     }
     # Construct table name from track name and variables
     my $tableName = "$compositeTrack";
+    my %shortViewMap = (Peaks => 'Pk', Signal => 'Sig', RawSignal => 'Raw', PlusRawSignal => 'PlusRaw', MinusRawSignal => 'MinusRaw');
 
     if(!defined($daf->{TRACKS}{$view}{shortLabelPrefix})) {
         $daf->{TRACKS}{$view}{shortLabelPrefix} = "";
     }
@@ -1766,9 +1800,8 @@
         }
 
         my $shortSuffix = "";
         my $longSuffix;
-        my %shortViewMap = (Peaks => 'Pk', Signal => 'Sig', RawSignal => 'Raw', PlusRawSignal => 'PlusRaw', MinusRawSignal => 'MinusRaw');
         if($hash{'antibody'} && $hash{'cell'}) {
             $pushQDescription = "$hash{'antibody'} in $hash{'cell'}";
             $shortSuffix = "$hash{'cell'} $hash{'antibody'}";
             $longSuffix = "$hash{'antibody'} in $hash{'cell'} cells";
@@ -1838,9 +1871,13 @@
         }
     }
 
     # Add view and replicate to tablename
+    if(defined($shortViewMap{$view})) {
+        $tableName .= $shortViewMap{$view};
+    } else {
     $tableName .= $view;
+    }
     if(defined($replicate)) {
         $tableName .= "Rep$replicate";
     }