#!/usr/bin/perl

$datadir = "/ddn/gs1/project/ibGroup/wadep2/grimmsa/KrystalOrlando/data_hub_prep/RNAseq/tracks";

foreach $f (split/\n/, `grep ^RNA data/bwlist.rna.txt | cut -f1 | sort | uniq`) {
  $ff = "data/$f";
  unless (-d $ff) { system "mkdir $ff"; }
}

open(IN, "data/bwlist.rna.txt");
while (<IN>) {
  next unless ($_ =~ /^RNA/);
  chomp $_; ($f, $bwfile) = split/\t/, $_;
  $newfile = "data/$f/$bwfile";
  $oldfile = "$datadir/$bwfile";
  next unless (-e $oldfile);
  next if (-e $newfile);
  print "cp $oldfile $newfile &\n";
}
close(IN);

