-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path04formEntityTable.pl
59 lines (49 loc) · 1.77 KB
/
04formEntityTable.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
#!/usr/bin/perl -w
# Forms the entity table, given a linked XML file
# make sure only one instance of the script is running at a time
use Fcntl 'LOCK_EX', 'LOCK_NB';
exit(0) unless(flock DATA, LOCK_EX|LOCK_NB);
# put your code here instead of sleep
#sleep(60);
use strict;
use lib "./perlmodules/";
use TextpressoSystemTasks;
use TextpressoGeneralTasks;
use WormbaseLinkTasks;
use lib "../../perlmodules/";
use GeneralTasks;
use GeneralGlobals;
# file specs
if (@ARGV < 2) {
die "USAGE: $0 <input linked HTML file> <linked XML dir>\n".
"eg: $0 ../html/110270.html ../linked_xml/\n";
}
my $htmlfile = $ARGV[0];
my $linkedxmldir = $ARGV[1];
# log file
$htmlfile =~ /(\d+)/;
my $file_id = $1;
my $log_file = "../logs/$file_id";
if (-e $log_file) {
die "log file $log_file already exists. Won't run again!\n";
}
# (1) copy HTML file to linked XML dir with .XML extn
my @e = split(/\//, $htmlfile);
my $htmlfilename = pop @e;
(my $xmlfilename = $htmlfilename) =~ s/\.html/\.XML/i;
my $xmlfile = $linkedxmldir . "/" . $xmlfilename;
#my @args = ("cp", $htmlfile, $xmlfile);
#system(@args) == 0 or die "died: could not copy $htmlfile to $xmlfile: $!\n";
#print "copied $htmlfile to $xmlfile\n";
GeneralTasks::create_linked_xml_file($htmlfile, $xmlfile);
# (2) form entity table
print "forming entity table...\n";
my $entity_table_file = "../entity_link_tables/$htmlfilename";
my $wbpaper_id = WormbaseLinkTasks::getWbPaperId($xmlfilename);
undef($/); open (IN, "<$xmlfile") or die $!;
my $linked_xml = <IN>; close (IN); $/ = "\n";
my $xml_format = WormbaseLinkTasks::getXmlFormat($xmlfile);
WormbaseLinkTasks::formEntityTable($linked_xml, $xml_format, $wbpaper_id, $entity_table_file, $log_file, "post QC");
print "Entity table available in $entity_table_file\n";
print "DONE.\n";
__DATA__