#!/usr/bin/perl

$tool = "/ddn/gs1/home/grimmsa/tools/ucsc/bedToBigBed";
$cs = "/ddn/gs1/shared/fargod/reference_genomes/mm10/mm10ordered.chromSizes";

$peakdir = "/ddn/gs1/home/grimmsa/sylvia/histonemod_Aug2016/ActiveMotif_analysis/peak_calls/BED_orig";
$samplekey = "/ddn/gs1/home/grimmsa/sylvia/histonemod_Aug2016/ActiveMotif_analysis/peak_calls/sample_key.txt";

open(IN, "$samplekey");
while (<IN>) {
  next if ($_ =~ /^\#/);
  chomp $_; ($origID, $newID, @rest) = split/\t/, $_;
  next if ($origID =~ /placeholder/ || $origID =~ /ERa/);
  $bedfile = "$peakdir/$origID.peaks.bed";
  $bbfile = "./$newID.ActiveMotif_peaks.bigBed";
  unless (-e $bbfile) { print "$tool $bedfile $cs $bbfile &\n"; }
}
close(IN);

