#!/usr/bin/perl

$refGenome = $ARGV[0];
$idColumns = $ARGV[1];  # number of period-separated text chunks from bigwig file name to use as identifier
$string = $ARGV[2];     # files to collect (like 'bw' or 'bigWig')

#$refGenome = "mm9";

$path = `pwd`; $path =~ s/\s//g;
$path =~ s/\/data\/wade\///;

$ls = `ls -1 *.$string`;
foreach $bwfile (split/\n/, $ls) {
  @ar = split/\./, $bwfile;
  @arX = splice(@ar, 0, $idColumns);
  $id = join(" ", @arX);
  print "track type=bigWig name=\"$id\" db=$refGenome visibility=full alwaysZero=on maxHeightPixels=40 color=0,0,153 bigDataUrl=http://snpinfo.niehs.nih.gov/ucscview/$path/$bwfile\n";
}

