ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/btab2gff
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (13 years ago) by gpertea
File size: 1807 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 use Getopt::Std;
4 use FindBin;use lib $FindBin::Bin;
5 #raw translation of btab into gff3 format
6
7 my $usage = q/Usage:
8 btab2gff [-R] <btab_input>
9
10 -R will swap roles between target and reference
11 /;
12 umask 0002;
13 getopts('R') || die($usage."\n");
14 my $rswap=$Getopt::Std::opt_R;
15
16 my %qh;
17
18 while (<>) {
19 chomp;
20 my @t=split("\t");
21 my @hsp=split('~',$t[21]);
22 my $qcov=$rswap ? '' : $t[22]; #not there unless we ran btabflt.pl
23 my @ex;
24 my $strand;
25 my ($gseqid, $qid, $qlen, $qs, $qe) = $rswap ? ($t[0], $t[5], $t[18], $t[8], $t[9]) :
26 ($t[5], $t[0], $t[2], $t[6], $t[7]);
27 my $qn=++$qh{$qid};
28 my $qname=$qid;
29 $qid.=".bt$qn";
30 if ($t[17] eq 'Minus') {
31 $strand='-';
32 if ($rswap) {
33 @ex= map { my @r=(m/([\d\.]+)/g);[$r[0],$r[1],$r[3],$r[2],$r[4]] } @hsp;
34 }
35 else {
36 @ex= map { my @r=(m/([\d\.]+)/g);[$r[3],$r[2],$r[0],$r[1],$r[4]] } @hsp;
37 }
38 }
39 else {
40 $strand='+';
41 if ($rswap) {
42 @ex= map { my @r=(m/([\d\.]+)/g);[$r[0],$r[1],$r[2],$r[3],$r[4]] } @hsp;
43 }
44 else {
45 @ex= map { my @r=(m/([\d\.]+)/g);[$r[2],$r[3],$r[0],$r[1],$r[4]] } @hsp;
46 }
47 }
48 @ex= sort { $main::a->[0] <=> $main::b->[0] } @ex;
49 ($qs, $qe)=($qe, $qs) if $qe<$qs;
50 my $attr="ID=$qid;Name=$qname;qreg=$qs-$qe|$qlen";
51 $attr.=";Cov=$qcov" if $qcov;
52 $attr.=";PID=$t[10];PSIM=$t[11];Score=$t[12]";
53 $attr.=";EValue=$t[19]" if length($t[19])>1;
54 my $descr=$rswap ? '' : $t[15];
55 if (length($descr)>2) {
56 $attr.=';descr="'.$descr.'"';
57 }
58 print join("\t",$gseqid,$t[3],'mRNA', $ex[0]->[0], $ex[-1]->[1],
59 $t[11], $strand, '.', $attr)."\n";
60 foreach my $x (@ex) {
61 print join("\t",$gseqid,$t[3],'exon', $x->[0], $x->[1], $x->[4], $strand, '.',
62 'Parent='.$qid.';qreg='.$x->[2].'-'.$x->[3])."\n";
63 }
64 }

Properties

Name Value
svn:executable *