#!/usr/bin/perl

@A_cond = ("lysed", "pellet", "Nuc", "Pel");
@A_cell = ("AD", "AC");
@A_strand = ("forward", "reverse");

foreach $cond (@A_cond) {
	foreach $cell (@A_cell) {

		$txt = qq {track ATAC.$cond.$cell
type bigWig
container multiWig
shortLabel ATAC.$cond.$cell
longLabel ATAC.$cond.$cell
visibility full
aggregate none
autoScale on
showSubtrackColorOnUi on
maxHeightPixels 50:20:10
priority 1
};
		print $txt;

		my @A_files;
		@A_files = </mnt/www/webroot/hg19/atac_seq/v_1/4DN/*$cell*$cond*bw>;
		foreach $file (@A_files) {
			next if ($file !~ /_$cell/);
			next if ($file !~ /_$cond/);

			($sample) = $file =~ /4DN\/(.*)\.bw/;
			$txt = qq {
track $sample
bigDataUrl http://emc.genome.mcgill.ca/hg19/atac_seq/v_1/4DN/$sample.bw
shortLabel $sample
longLabel $sample
parent ATAC.$cond.$cell
type bigWig
autoScale on
color 0,0,255
};
			print "$txt\n";
		}
	}
}


foreach $cell (@A_cell) {
	foreach $strand (@A_strand) {

		if ($strand eq "forward") { $color = "128,0,0"; }
		else                      { $color = "0,100,0"; }

		$txt = qq {track RNAseq.$cell.$strand
type bigWig
container multiWig
shortLabel RNAseq.$cell.$strand
longLabel RNAseq.$cell.$strand
visibility full
aggregate none
autoScale on
showSubtrackColorOnUi on
maxHeightPixels 50:20:10
priority 1
};
                print $txt;

                my @A_files;
                @A_files = </mnt/www/webroot/hg19/rna_seq/v_2/4DN/*bw>;
                foreach $file (@A_files) {
                        next if ($file !~ /_$cell/);
                        next if ($file !~ /$strand/);

                        ($sample) = $file =~ /4DN\/(.*)\.bw/;
                        $txt = qq {
track $sample
bigDataUrl http://emc.genome.mcgill.ca/hg19/rna_seq/v_2/4DN/$sample.bw
shortLabel $sample
longLabel $sample
parent RNAseq.$cell.$strand
type bigWig
autoScale on
color $color
};
                        print "$txt\n";
                }
        }
}



