Skip to main content Skip to navigation

A couple of small scripts

To convert bed to gff in order to add positions of microarray probes to GBrowse. I used this after converting bam (from bowtie) to bed (using bedtools) then realising that GBrowse uses a very strict version of bed that only allowed 4 columns (and no name!), so needed something to quickly turn it into gff. There would be much better ways to write this using Bio::Tools::GFF i'm sure, but this did the job.

use strict;

my $input = $ARGV[0];
my $output = $ARGV[1];

open (INPUT, $input) or die "Cannot open input\n";
my @input = <INPUT>;
close INPUT;
open (OUTPUT, ">", $output) or die "Cannot write to disk\n";
print OUTPUT "##gff-version 3\n";
foreach my $line (@input){
chomp $line;
my @fields = split(/\t/, $line);
$fields[1] = $fields[1] +1;
$fields[3] = "ID=Probe_".$fields[3].";Probe_Name=".$fields[3];
my $gffline = $fields[0]."\tmicroarray\tprobe\t".$fields[1]."\t".$fields[2]."\t".$fields[4]."\t".$fields[5]."\t.\t".$fields[3]."\n";
print OUTPUT $gffline;
}