-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathanalyze-assembly-data2.pl
75 lines (58 loc) · 1.81 KB
/
analyze-assembly-data2.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
use Data::Dumper;
use strict;
use JSON::XS;
use Bio::KBase::AppService::SchedulerDB;
use Bio::P3::Workspace::WorkspaceClientExt;
my $ws = Bio::P3::Workspace::WorkspaceClientExt->new;
#
# Given results from analyze-assembly-data.pl, pull the workspace info again and
# determine assembler used.
#
my $db = Bio::KBase::AppService::SchedulerDB->new;
my @work;
my %data;
while (<>)
{
chomp;
my($id, $owner, $size, $elap, $mem) = split(/\t/);
my($h, $m, $s) = split(/:/, $elap);
my $time = $h * 3600 + $m * 60 + $s;
my $val = [$id, $owner, $size, $elap, $mem, $time];
push(@work, $val);
$data{$id} = $val;
}
while (@work)
{
my @batch = splice(@work, 0, 100);
my $qry = join(", ", );
my $qs = join(", ", map { "?" } @batch);
my $res = $db->dbh->selectall_arrayref(qq(SELECT id, output_path, output_file, params
FROM TaskWithActiveJob
WHERE id in ($qs)), undef, map { $_->[0] } @batch);
for my $e (@$res)
{
my($id, $path, $file, $params) = @$e;
my $path1 = "$path/.$file/details/${file}_run_details.json";
my $path2 = "$path/.$file/${file}_run_details.json";
my $path3 = "$path/.$file/${file}_run_details.txt";
my $txt;
open(my $fh, ">", \$txt) or die $!;
eval { $ws->copy_files_to_handles(1, undef, [[$path1, $fh]], { admin => 1 }); };
if ($@)
{
eval { $ws->copy_files_to_handles(1, undef, [[$path2, $fh]], { admin => 1 }); };
}
if ($@)
{
eval { $ws->copy_files_to_handles(1, undef, [[$path3, $fh]], { admin => 1 }); };
}
warn "$path1: $@ " if $@;
next unless $txt;
my $dat = eval { decode_json($txt); };
next unless $dat;
next if @{$dat->{problem}};
my $asm = $dat->{assembly}->{assembler};
my(undef, $owner, $size, $elap, $mem, $time) = @{$data{$id}};
print join("\t", $id, $owner, $size, $elap, $mem, $asm), "\n";
}
}