| 1 |
|
| 2 |
# usage: ./perl GOaddpath.pl (GOterm_file) (GOterm2term_file) < (inputFile) > (outputFile) |
| 3 |
|
| 4 |
use strict; |
| 5 |
|
| 6 |
# load GOfunctions |
| 7 |
require GOfunctions; |
| 8 |
GOfunctions::import($ARGV[0],$ARGV[1]); |
| 9 |
print STDERR "Goterm-file: $ARGV[0] GoTerm2Term-file: $ARGV[1]\n"; |
| 10 |
|
| 11 |
# -- parameter -- |
| 12 |
my $GOseperator = ','; |
| 13 |
|
| 14 |
# -- main loop -- |
| 15 |
while(my $line=<STDIN>) { |
| 16 |
|
| 17 |
if(substr($line,0,1) eq '#') { |
| 18 |
# copy over comments |
| 19 |
print $line; |
| 20 |
} else { |
| 21 |
|
| 22 |
# expected format: |
| 23 |
# (target) \t (GoTerm1),(GoTerm2),... \t (evalue) \t (bitscore) |
| 24 |
|
| 25 |
my @table = split(/\t/,$line,3); |
| 26 |
my @GO = split($GOseperator,$table[1]); |
| 27 |
my $scores = $table[2]; |
| 28 |
|
| 29 |
@GO = GOfunctions::goFilter(@GO); # filter out cellular_components and anything else unusual |
| 30 |
@GO = GOfunctions::goAddPath(@GO); # add all GO terms lying on the path to root |
| 31 |
@GO = GOfunctions::goFilter(@GO); # filter out anything unusual which might have been added |
| 32 |
|
| 33 |
print $table[0] . "\t" . join($GOseperator,@GO) . "\t$scores" unless $#GO == -1; |
| 34 |
} |
| 35 |
} |
| 36 |
|