Hi - Can any one please suggest a method to convert Bowtie output to BED format? Is there a bioperl script or any software for that?
thanks in advance.
thanks in advance.
You are currently viewing the SEQanswers forums as a guest, which limits your access. Click here to register now, and join the discussion

#!/usr/bin/perl
use strict;
use warnings;
# get file names from the command line
my ($input, $output) = @ARGV;
# exceptions and usage
if (!defined $input or !defined $output) {
die "Usage: bedFromBowtie.pl <input> <output>\n";
}
# open the input/output file
open my $out, ">", "$output" or die "Cannot open $output: $!\n";
open my $in, "<", "$input" or die "Cannot open $input: $!\n";
while ( <$in> ) {
chomp;
my (undef, $strand, $chr, $start, $sequence) = split "\t"; # assumes standard bowtie output
my @sequence = split '', $sequence; # extra work, but allows for variable-length sequences
my $length = @sequence;
my $end;
if ($strand eq '+') {
$end = $start + $length - 1;
}
elsif ($strand eq '-') {
$end = $start;
$start = $end - $length + 1;
}
else {
die "We have a formatting problem: strand is set to $strand\n";
}
print $out "$chr\t$start\t$end\tU0\t0\t$strand\n";
}
print "Done!\n";
close $in; close $out; exit;

| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SEQadmin2, Yesterday, 02:55 AM
|
0 responses
9 views
0 reactions
|
Last Post
by SEQadmin2
Yesterday, 02:55 AM
|
||
|
Started by SEQadmin2, 07-24-2026, 12:17 PM
|
0 responses
12 views
0 reactions
|
Last Post
by SEQadmin2
07-24-2026, 12:17 PM
|
||
|
Started by SEQadmin2, 07-23-2026, 11:41 AM
|
0 responses
12 views
0 reactions
|
Last Post
by SEQadmin2
07-23-2026, 11:41 AM
|
||
|
Started by SEQadmin2, 07-20-2026, 11:10 AM
|
0 responses
24 views
0 reactions
|
Last Post
by SEQadmin2
07-20-2026, 11:10 AM
|
Comment