Skip to content

Instantly share code, notes, and snippets.

@alexpreynolds
Last active December 1, 2015 18:37
Show Gist options
  • Save alexpreynolds/54464b5184f8cfce866e to your computer and use it in GitHub Desktop.
Save alexpreynolds/54464b5184f8cfce866e to your computer and use it in GitHub Desktop.
Split BED intervals into per-base elements
#!/usr/bin/env perl
use strict;
use warnings;
my $cnt = 0;
while (<STDIN>) {
chomp;
my ($chr, $start, $stop, $id, $score, $strand) = split("\t", $_);
for (my $meltIdx = $start; $meltIdx < $stop; $meltIdx += 1) {
print STDOUT join("\t", ($chr, $meltIdx, $meltIdx + 1, $id."!$cnt", $score, $strand))."\n";
}
$cnt++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment