line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BIE::Data::HDF5::Path; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
1
|
|
|
1
|
|
22759
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::autoclean; |
5
|
|
|
|
|
|
|
use v5.10; |
6
|
|
|
|
|
|
|
use BIE::Data::HDF5 ':all'; |
7
|
|
|
|
|
|
|
use BIE::Data::HDF5::Data; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'id' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'Int', |
12
|
|
|
|
|
|
|
required => 1, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'name' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
default => sub { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
h5name($self->id); |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#only support relative path currently |
26
|
|
|
|
|
|
|
sub mkPath { |
27
|
|
|
|
|
|
|
my ($self, $path) = @_; |
28
|
|
|
|
|
|
|
my @parts = split /\b\/\b/, $path; |
29
|
|
|
|
|
|
|
my $tmp1 = H5Gcreate($self->id, $parts[0]); |
30
|
|
|
|
|
|
|
for my $p (@parts[1..$#parts]) { |
31
|
|
|
|
|
|
|
my $tmp2 = $tmp1; |
32
|
|
|
|
|
|
|
$tmp1 = H5Gcreate($tmp2, $p); |
33
|
|
|
|
|
|
|
H5Gclose($tmp2); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
H5Gclose($tmp1); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub list { |
39
|
|
|
|
|
|
|
my $self = shift; |
40
|
|
|
|
|
|
|
h5ls($self->id); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub cd { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
if (@_) { |
46
|
|
|
|
|
|
|
my $p = shift; |
47
|
|
|
|
|
|
|
BIE::Data::HDF5::Path->new(id => H5Gopen($self->id, $p)); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub openData { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
if (@_) { |
54
|
|
|
|
|
|
|
BIE::Data::HDF5::Data->new( |
55
|
|
|
|
|
|
|
id => H5Dopen($self->id, shift), |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
undef; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub DEMOLISH { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
H5Gclose($self->id); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
BIE::Data::HDF5::Path - Perl extension for walking around in HDF5 files. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use BIE::Data::HDF5::Path; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $h5file = BIE::Data::HDF5::Path->new("data.h5"); |
82
|
|
|
|
|
|
|
#only support creation of relative group name currently |
83
|
|
|
|
|
|
|
$h5file->mkPath("newPath/newSubPath/newSubSubPath"); |
84
|
|
|
|
|
|
|
#both relative and absolute group names work when set new path |
85
|
|
|
|
|
|
|
$h5file->path("newPath"); |
86
|
|
|
|
|
|
|
$h5file->path("/newPath/newSubPath"); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
BIE::Data::HDF5::Path is a module for operation of locations in HDF5 data file. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 ATTRIBUTES AND METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
"id": The ID of the path. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
"mkPath": Create a new location in HDF5 File. Only accept relative path now. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
"list": List all entries under the path. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
"cd": Enter another path. Return a BIE::Data::HDF5::Path object if successfully. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
"openData": Return a BIE::Data::HDF5::Data if successfully. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<BIE::Data::HDF5::File> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<BIE::Data::HDF5::Data> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<BIE::App::PacBio> See this module for a live example. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Xin Zheng, E<lt>zhengxin@mail.nih.govE<gt> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Copyright (C) 2012 by Xin Zheng |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
135
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.14.2 or, |
136
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |