#!/bin/bash
#

cat trackDb_trackSetRnaseq.txt;

cat sampleGroupInfo.txt | perl -p -e '
$priority = $priority + 1;
chomp;
($sample, $groupName) = split(/\t/);
$_="";
$trackName="$sample\.$groupName";
$bigwigFile=`ls $sample*bw`;
chomp($bigwigFile);
if ($groupName =~ /undiff.*wt/i) {
   $rgb = "52,168,119";
} elsif ($groupName =~ /undiff.*ko/i) {
   $rgb = "146,19,150";
} elsif ($groupName =~ /^diff.*wt/i) {
   $rgb = "255,155,0";
} elsif ($groupName =~ /^diff.*ko/i) {
   $rgb = "174,33,33";
}
open(IN,"trackDb_chunkRnaseq.txt");
while(<IN>){
   $line = $_;
   $_ = "";
   $line =~ s/TRACKNAME/$trackName/g;
   $line =~ s/GROUPNAME/$groupName\_$sample/g;
   $line =~ s/BIGWIG/$bigwigFile/g;
   $line =~ s/RGB/$rgb/g;
   $line =~ s/PRIORITY/$priority/g;
   print "   $line";
}
close(IN);
sub BEGIN {
   $priority = 1000;
}
'
