Skip to content

Commit

Permalink
add -x ... which adds extra fields... so far just gene name
Browse files Browse the repository at this point in the history
  • Loading branch information
earonesty committed May 1, 2014
1 parent 36b7adc commit 7db86e1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion clipper/gtf2bed
Expand Up @@ -23,6 +23,10 @@
# ALSO, IT WOULD BE NICE IF YOU LET ME KNOW YOU USED IT.

use Data::Dumper;
use Getopt::Long;

my $extended;
GetOptions("x"=>\$extended);

$in = shift @ARGV;

Expand Down Expand Up @@ -105,8 +109,15 @@ for $id (
my $exst = join ",", map {$_->[3]-$beg-1} @ex; # exon start
my $exsz = join ",", map {$_->[4]-$_->[3]+1} @ex; # exon size

my $gene_id;
my $extend = "";
if ($extended) {
($gene_id) = $attr =~ /gene_name "([^"]+)"/;
($gene_id) = $attr =~ /gene_id "([^"]+)"/ unless $gene_id;
$extend="\t$gene_id";
}
# added an extra comma to make it look exactly like ucsc's beds
print "$chr\t$beg\t$end\t$id\t0\t$dir\t$cds\t$cde\t0\t$exn\t$exsz,\t$exst,\n";
print "$chr\t$beg\t$end\t$id\t0\t$dir\t$cds\t$cde\t0\t$exn\t$exsz,\t$exst,$extend\n";
}


Expand Down

0 comments on commit 7db86e1

Please sign in to comment.