Added align_to_bed script. Used to turn MACS output into a bed file
authorTim Reddy Tim <treddy@hudsonalpha.org>
Wed, 20 Aug 2008 21:22:26 +0000 (21:22 +0000)
committerTim Reddy Tim <treddy@hudsonalpha.org>
Wed, 20 Aug 2008 21:22:26 +0000 (21:22 +0000)
htswanalysis/scripts/align_to_bed.pm [new file with mode: 0755]

diff --git a/htswanalysis/scripts/align_to_bed.pm b/htswanalysis/scripts/align_to_bed.pm
new file mode 100755 (executable)
index 0000000..e03374f
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+my $len = shift || 25;
+
+while(<>) {
+  my(@a) = split(/ /, $_);
+  if((scalar @a) <= 3) { next; }
+  my($chr,$pos) = split(/:/,$a[3]);
+  my($start,$stop,$strand);
+  if($a[4] eq "F") {
+    $start = $pos; $stop = $pos + $len;
+    $strand = "+";
+  } else {
+    $stop = $pos; $start = $pos - $len;
+    $strand = "-";
+    if($start < 0) { $start = 0; }
+  } 
+
+  print "$chr\t$start\t$stop\t0\t0\t$strand\t$start\t$stop\t0,0,0\n";
+}