| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
################################################################################### |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# DBIx::Recordset - Copyright (c) 1997-2000 Gerald Richter / ECOS |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
|
7
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the Perl README file. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# THIS IS BETA SOFTWARE! |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
|
12
|
|
|
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
|
13
|
|
|
|
|
|
|
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# $Id: FileSeq.pm,v 1.4 2000/06/26 05:16:18 richter Exp $ |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
################################################################################### |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package DBIx::Recordset::FileSeq ; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
713
|
use strict 'vars' ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use Cwd ; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
542
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
|
28
|
|
|
|
|
|
|
## |
|
29
|
|
|
|
|
|
|
## new |
|
30
|
|
|
|
|
|
|
## |
|
31
|
|
|
|
|
|
|
## creates a new DBIx::Recordset::FileSeq object. |
|
32
|
|
|
|
|
|
|
## |
|
33
|
|
|
|
|
|
|
## $dir = Directory which holds the sequences |
|
34
|
|
|
|
|
|
|
## |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
0
|
0
|
|
my ($class, $dummy, $dir, $min, $max) = @_ ; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
|
mkdir $dir, 0755 or die "Cannot create $dir ($!)" if (!-e $dir) ; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
die "$dir is not a directory" if (!-d $dir) ; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
0
|
|
|
|
my $self = { |
|
|
|
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
'*Debug' => $DBIx::Recordset::Debug, |
|
50
|
|
|
|
|
|
|
'*Dir' => Cwd::abs_path ($dir), |
|
51
|
|
|
|
|
|
|
'*DefaultMin' => $min || 1, |
|
52
|
|
|
|
|
|
|
'*DefaultMax' => $max || '', |
|
53
|
|
|
|
|
|
|
} ; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
bless ($self, $class) ; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self -> ReadCounter ; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $self ; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
|
64
|
|
|
|
|
|
|
## |
|
65
|
|
|
|
|
|
|
## ReadCounter |
|
66
|
|
|
|
|
|
|
## |
|
67
|
|
|
|
|
|
|
## read current counters form filesystem |
|
68
|
|
|
|
|
|
|
## |
|
69
|
|
|
|
|
|
|
## |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub ReadCounter |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
{ |
|
75
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my %counter ; |
|
78
|
|
|
|
|
|
|
my %max ; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
opendir DH, $self -> {'*Dir'} or die "Cannot open directory $self->{'*Dir'} ($!)" ; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
while ($_ = readdir DH) |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
0
|
0
|
|
|
|
|
if (/seq\.(.*?)\.(\d*?)\.(\d+)$/) |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
0
|
|
|
|
|
|
$counter{$1}=$3 ; |
|
87
|
0
|
|
|
|
|
|
$max{$1}=$2 ; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
$self -> {'*Counter'} = \%counter ; |
|
92
|
0
|
|
|
|
|
|
$self -> {'*Max'} = \%max ; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
|
97
|
|
|
|
|
|
|
## |
|
98
|
|
|
|
|
|
|
## NextVal |
|
99
|
|
|
|
|
|
|
## |
|
100
|
|
|
|
|
|
|
## get next value from counter |
|
101
|
|
|
|
|
|
|
## |
|
102
|
|
|
|
|
|
|
## in $name = counter name |
|
103
|
|
|
|
|
|
|
## |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub NextVal |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
|
109
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_ ; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $dir = $self -> {'*Dir'} ; |
|
112
|
0
|
|
|
|
|
|
my $lastcnt ; |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
local $^W = 0 ; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
while (1) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
|
|
|
my $cnt = $self -> {'*Counter'}{$name} ; |
|
119
|
0
|
|
|
|
|
|
my $max = $self -> {'*Max'}{$name} ; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if (!defined ($cnt)) |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
|
|
|
$cnt = $self->{'*DefaultMin'} ; |
|
124
|
0
|
|
|
|
|
|
$max = $self->{'*DefaultMax'} ; |
|
125
|
0
|
0
|
|
|
|
|
open FH, ">$dir/seq.$name.$max.$cnt" or die "Cannot create seq.$name..1 ($!)" ; |
|
126
|
0
|
|
|
|
|
|
close FH ; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $cnt1 = $cnt + 1 ; |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
0
|
0
|
|
|
|
die "Max count reached for Sequence $name" if ($max ne '' && $cnt1 > $max) ; |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if (rename ("$dir/seq.$name.$max.$cnt", "$dir/seq.$name.$max.$cnt1")) |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
0
|
|
|
|
|
|
$self -> {'*Counter'}{$name} = $cnt1 ; |
|
136
|
0
|
|
|
|
|
|
return $cnt ; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $lastcnt = $cnt ; |
|
140
|
0
|
|
|
|
|
|
$self -> ReadCounter ; |
|
141
|
0
|
0
|
|
|
|
|
die "Problems updating Sequence $name (File $dir/seq.$name.$max.$cnt)" if ($lastcnt == $self -> {'*Counter'}{$name} ) ; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |