forked from cmungall/obo-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbl2obo_altid.pl
executable file
·49 lines (44 loc) · 924 Bytes
/
tbl2obo_altid.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
47
48
49
#!/usr/bin/perl
my $rel;
if ($ARGV[0] =~ /^\-/) {
my $opt = shift @ARGV;
if ($opt eq '--rel') {
$rel = shift;
}
if ($opt eq '--is_a') {
$rel = 'is_a';
}
}
my %linkh = ();
while (<>) {
chomp;
s/\!.*//;
s/^\s+//;
s/\s+$//;
next unless $_;
my @cols = split(/\t/);
@cols = map {s/(\d+)\-(\S+)/$1 ! $2/;$_} @cols;
if (!$rel) {
$rel = shift @cols;
}
push(@{$linkh{$cols[0]}->{$rel}},$cols[1]);
}
foreach my $id (keys %linkh) {
print "[Term]\nid: $id\n";
my $relh = $linkh{$id};
foreach my $rel (keys %$relh) {
if ($rel eq 'xref') {
print "xref: $_\n" foreach @{$relh->{$rel}};
}
else {
print "alt_id: $_\n" foreach @{$relh->{$rel}};
}
}
print "\n";
}
exit 0;
sub print_term {
my $id = shift;
my $n = shift;
print "[Term]\nid: $id\nalt_id: $n\n\n"
}