#!/bin/env perl

use strict;
use warnings;

my $usage = "Usage: $0 <files.bw>\n";
my @file = @ARGV;
die $usage if scalar(@file) == 0;

#p19_ACG_neg.bw

my $once = 0;
my $main = '';
foreach my $file (@file){
   if ($file !~ /_[posneg]+\.bw$/){
      die "$file does not end in either _neg.bw or _pos.bw\n";
   } else {
      if ($once == 0){
         $main = $file;
         #cage_blood_deeper/c10_ACT
         $main =~ s/.*\/(.*)$/$1/;
         $main =~ s/_[posneg]+\.bw$//;
print <<EOF;
track $main
container multiWig
shortLabel $main
longLabel $main
type bigWig 0 30000
viewLimits 0:100
visibility full
maxHeightPixels 150:20:11
aggregate transparentOverlay
showSubtrackColorOnUi on
windowingFunction mean
priority 1.4
configurable on
autoScale on
EOF
         print "\n";
         $once = 1;
      }
      my $name = $file;
      $name =~ s/.*\/(.*)$/$1/;
      $name =~ s/\.bw$//;
print <<EOF;
track $name
bigDataUrl $file
shortLabel $name
longLabel $name
type bigWig
parent $main
color 136,102,255
EOF
      print "\n";
   }
}
exit(0);
