-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAddAncestors.pl
49 lines (47 loc) · 1016 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
47
48
49
#!/usr/bin/perl
#use strict;
#Define all Needed Variables
use List::MoreUtils qw(uniq);
my $path = `pwd`;
chomp ($path);
my $annotfile="$path/annotationAxiom.lst";
my $ancestfile= "$path/axioms.lst";
my $addoutfile= "$path/annotationAxiomFinal.lst";
my @temparray=();
open (FILE, '>>', "$addoutfile");
open (FH,"$annotfile");
while (my $line =<FH>)
{
chomp ($line);
if ($line =~ /(\S+)\s+hasFunction\s+(\S+)/)
{
chomp ($line);
push @temparray, $line;
my $prot=$1;
my $childGO=$2;
open (FILE1, "$ancestfile" );
while (my $line2 =<FILE1>)
{
chomp ($line2);
if ($line2 =~ /(\S+)\s+SubClassOf\s+(\S+)/)
{
#print ("Found one \n");
my $checkgo=$1;
my $goAnces=$2;
if ($checkgo eq $childGO)
{
my$newline= "$prot hasFunction $goAnces";
push @temparray, $newline;
#print ("Found two \n");
}
}
}
#print ("Done with this line\n");
}
}
my @Finalarray= uniq @temparray;
foreach (@Finalarray)
{
my $final_annotation=$_;
print FILE "$final_annotation\n";
}