This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How Do I Convert An Illumina Export File To Bed?

I have some illumina data generated from the latest version of the illumina pipeline (1.6.0) I need to convert my data into BED to view in ucsc genome browser.

This seems like it should be a fairly common task, however, I am unable to find any scripts to convert my data.

bed

We can probably find/write you perl or python scripts that do this, what are you comfortable running?

1 answer

I found a script on another site, Uses perl but I have not checked for correctness:

#!/usr/bin/perl

use strict;
use warnings;
use IO::File;

my $filename = shift @ARGV;
die "Usage\n\tperl sorted2bed.pl s_X_sorted.txt > s_X_sorted.bed\n" unless $filename;
chomp $filename;

my $fh = new IO::File;
$fh->open("< $filename") or die "Can't open file $filename for reading: $!";

my $count = 1;
while(my $line = <$fh>){
   warn "Line $count\n" if $count%1000 == 0;
   $count++;
   my @line = split "\t", $line;
   my $chr = $line[10];
   $chr =~ s/(.+)\.fa/$1/;
   #Illumina is 1-based, BED is 0-based
   my $start = $line[12]-1;
   my $read = $line[8];
   my $end = $start + length $read;
   my $strand = $line[13] eq 'F' ? '+': '-';
   my $score = $line[15];
   my $bedline = "$chr\t$start\t$end\t$read\t$score\t$strand\n";
   print $bedline;
}
$fh->close;

warn "Done";

Log in to answer this question.