#!/usr/bin/perl

$datadir = "/ddn/gs1/project/ibGroup/wadep2/grimmsa/KrystalOrlando/for_GEO_Oct2024/subset_ATACseq/data";

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

open(IN, "data/bwlist.atac.txt");
while (<IN>) {
  next unless ($_ =~ /^ATAC/);
  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);

