This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathParser.pl
executable file
·120 lines (96 loc) · 2.67 KB
/
Parser.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/local/bin/perl
# Copyright SRA International
#
# Distributed under the OSI-approved BSD 3-Clause License.
# See http://ncip.github.com/pathway-interaction-database/LICENSE.txt for details.
use DBI;
use FileHandle;
use strict;
BEGIN {
my @path_elems = split("/", $0);
pop @path_elems;
push @INC, join("/", @path_elems);
}
use PWLabel;
use Parser;
my (
$what,
$inpf,
$molmapf,
# $pathway_id_base,
$set_pathway_id,
$atom_id_base,
$organism,
$source_id
) = @ARGV;
if (-d "/app/oracle/product/dbhome/current") {
$ENV{'ORACLE_HOME'} = "/app/oracle/product/dbhome/current";
} elsif (-d "/app/oracle/product/8.1.7") {
$ENV{'ORACLE_HOME'} = "/app/oracle/product/8.1.7";
} elsif (-d "/app/oracle/product/8.1.6") {
$ENV{'ORACLE_HOME'} = "/app/oracle/product/8.1.6";
}
my $db = DBI->connect("DBI:Oracle:" . "lpgdev",
"web", "readonly");
if (not $db or $db->err()) {
print STDERR "#! Cannot connect to " . "web" . "@" .
"lpgdev" . "\n";
exit;
}
my $lv = new PWLabel($db, "cgap");
my $pw = new Pathway($lv);
my $xp = new Parser($pw, $lv, $atom_id_base, $set_pathway_id);
$db->disconnect();
$xp->ReadMolMap($molmapf);
my $fh = new FileHandle;
open($fh, $inpf) or die "Cannot open input file $inpf";
if (! $xp->ReadFile($fh) ) {
print join("", @{ $xp->ListErrors() });
exit();
}
close $fh;
if (! $xp->Parse() ) {
print join("", @{ $xp->ListErrors() });
exit();
}
$pw->BuildMolInstCache();
#print STDERR "return from BuildMolInstCache\n";
$pw->BuildGenericLabelCache();
#print STDERR "return from BuildGenericLabelCache\n";
$pw->PruneDuplicateAtoms();
#print STDERR "return from PruneDuplicateAtoms\n";
$pw->IdentifyMacroProcesses();
#print STDERR "return from IdentifyMacroProcesses\n";
if ($what eq "dot") {
use DOToutput;
my @lines;
my $dot = new DOToutput($pw, $lv, "");
$dot->ShowAtomIds(1);
$dot->ShowSubTypeLines(1);
$dot->DOTGraph();
print join("\n", @lines, @{ $dot->Lines }) . "\n";
} elsif ($what eq "table") {
use TableOutput;
my @lines;
my $pathway_id_map = $xp->PathwayIdMap();
my $atom_id_map = $xp->AtomIdMap();
my $to = new TableOutput($pw, $lv, $organism, $source_id,
$pathway_id_map, $atom_id_map, "");
$to->DoAll();
print join("\n", @lines, @{ $to->Lines }) . "\n";
} elsif ($what eq "lisp") {
use LispOutput;
my @lines;
my $lisp = new LispOutput($pw, $lv);
$lisp->PrPathway();
print join("\n", @lines, @{ $lisp->Lines }) . "\n";
} elsif ($what eq "template") {
use Templates;
my @lines;
my $pwt = new Templates($pw, $lv, "");
$pwt->CollateAtomTypes($pw);
$pwt->PrintTemplates($lv);
return join("\n", @{ $pwt->Lines() }) . "\n";
} else {
print STDERR "do nothing for what = $what\n";
}