-
Notifications
You must be signed in to change notification settings - Fork 11
/
AddAncestors.pl
46 lines (44 loc) · 922 Bytes
/
AddAncestors.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
#use strict;
#Define all Needed Variables
use List::MoreUtils qw(uniq);
my $path = `pwd`;
my $annotfile=$ARGV[0];
chomp ($path);
#my $annotfile="$path/annotationAxiom.lst";
my $ancestfile= $ARGV[1];
my $ontoclassesfile= $ARGV[2];
my $addoutfile= $ARGV[3];
my @temparray=();
open (FILE, '>>', "$addoutfile");
open (FH,"$annotfile");
#Make class to superclass map
my %supermap=();
open (FILEANC, $ancestfile);
while (my $lineanc=<FILEANC>)
{
if (($lineanc=~/(\S+)\s+SubClassOf\s+(.*)/) || ($lineanc=~/(\S+)\s+EquivalentTo\s+(.*)/))
{
my $child=$1;
my $ances=$2;
$supermap{$child}.=",$ances";
}
}
#Add inferred axioms
while (my $lineassoc=<FH>)
{
if ($lineassoc=~/(\S+)\s+(\S+)/)
{
my $entity=$1;
my $classo=$2;
my @supers=split(/,/,$supermap{$classo});
foreach (@supers)
{
my $supclass= $_;
if (!($supclass eq ""))
{
print FILE "$entity $supclass\n";
}
}
}
}