-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadAseqsJson.pl
executable file
·67 lines (53 loc) · 1.46 KB
/
loadAseqsJson.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
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
use FindBin '$Bin';
use lib "$Bin";
use Common;
my $usage = <<USAGE;
Usage: $0 <database json>
<database json> should consist of an entire json object per line
Loads into the aseqs collection.
USAGE
my $g_File = shift or die $usage;
my $g_colFlag = "aseqs";
GetOptions("col=s", \$g_colFlag);
my $aseqs = &Common::aseqs($g_colFlag);
#my $fh = &Common::openFileOrGzFile($g_File);
&Common::startTicker(10000);
my $count = 0;
open(FH,"|/usr/bin/tac $g_File");
while (<FH>) {
my $json = $_;
#print("hey");
# my $son = substr($json,23);
# print($son);
# $json = $son;
#my $aseq = from_json(substr($json,23));
my $aseq = from_json(substr($_,23));
#print("$aseq->{_id}\n");
if ($aseqs->find_one({_id => $aseq->{_id}})) {
#print("$aseq->{_id}\n");
#print($count++);
# This assumes that the $aseq->{x}->{gi} is the most recent gi
# list and will overwrite any pre-existing ones.
#my %set = (
# 'x.gi' => $aseq->{x}->{gi}
#);
#$aseqs->update({_id => $aseq->{_id}}, {'$set' => \%set});
&Common::tick();
next;
}
else {
print("$count\t$aseq->{_id}\n________________________\n");
$count++;
#print($aseq);
my $hasUndoneData = index($aseq->{_s}, '-') != -1;
if ($hasUndoneData) { $aseq->{$Common::paddingKey} =
$Common::padding{basic}->{buffer}; }
$aseqs->insert($aseq);
&Common::removePadding($aseqs, $aseq->{_id});
&Common::tick();
}
}