Skip to content

Instantly share code, notes, and snippets.

@mjclark
Created July 30, 2011 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjclark/1116086 to your computer and use it in GitHub Desktop.
Save mjclark/1116086 to your computer and use it in GitHub Desktop.
Create a BED file of windows of any size from another BED file.
#Command: cat in.bed | perl windowize-bed.pl <windowsize> > out.bed
$windowsize=shift;
$ctr=0;
print STDERR "$ctr";
while($line=<STDIN>) {
$ctr++;
print STDERR "\r$ctr";
chomp($line);
@line=split(/\t/, $line);
for($i=$line[1]; $i<$line[2]-$windowsize+1; $i+=$windowsize) {
$end=$i+$windowsize;
print STDOUT "$line[0]\t$i\t$end\n";
}
}
print STDERR "\r$ctr\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment