-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgoterm_to_aspect_by_parsing_obo.pl
executable file
·46 lines (39 loc) · 1.54 KB
/
goterm_to_aspect_by_parsing_obo.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl -w
use strict;
my $ver = '1.0';
my $last_modified = 'May 3, 2011';
## -- importing the script 'func.pl' depends on host OS, added on June 23, 2010 --
my $os = $^O;
if($os eq 'darwin'){ ## if mac --
require '/Users/wchen/Dropbox/perl_scripts/gene_ontology/go_lib.pl';
}elsif($os eq 'linux'){ ## -- if linux --
require '/home/wchen/Dropbox/perl_scripts/gene_ontology/go_lib.pl';
}
## --------------------------------------------
## -- version history --
## --------------------------------------------
use Getopt::Long;
my %opts=();
GetOptions(\%opts,"i:s","o:s");
if (!$opts{i} or !$opts{o}){
print "----------------------------------------------------------------------
\t\t\tversion : $ver by Weihua Chen; last modified : $last_modified
----------------------------------------------------------------------
USAGE: perl $0
-i input go.obo file
-o out go term to aspect file
----------------------------------------------------------------------\n";
exit;
}
#### ontology parser
my %hNodesAndRelationship=();
my %hObsoleteTerms=();
my %hPureLeafNodes = ();
my %hAltIDs = (); ## -- hash{master_GO_id}{$alterids} ++;
&obo_parser($opts{i},\%hNodesAndRelationship,\%hObsoleteTerms,\%hPureLeafNodes, \%hAltIDs);
open OUT, ">$opts{o}" or die;
print OUT join("\t", qw(GOTerm Name Aspect isLeaf)),"\n";
while( my ($k, $v) = each %hNodesAndRelationship ){
next if( $k !~ /^GO/ or $$v{'is_root'} > 0 );
print OUT join("\t", $k, $$v{'name'}, $$v{'name_space'}, exists $hPureLeafNodes{ $k } ? "Y" : "N" ), "\n";
}