44
44
Bioperl modules. Send your comments and suggestions preferably to one
45
45
of the Bioperl mailing lists. Your participation is much appreciated.
47
bioperl-l@bioperl.org - General discussion
48
http://bioperl.org/MailList.shtml - About the mailing lists
47
bioperl-l@bioperl.org - General discussion
48
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
50
50
=head2 Reporting Bugs
52
52
Report bugs to the Bioperl bug tracking system to help us keep track
53
the bugs and their resolution. Bug reports can be submitted via
53
the bugs and their resolution. Bug reports can be submitted via the
56
bioperl-bugs@bio.perl.org
57
http://bugzilla.bioperl.org/
56
http://bugzilla.open-bio.org/
59
58
=head1 AUTHOR - Lincoln Stein
135
131
my $self = $class->SUPER::new(@_);
137
133
# first we initialize ourselves
138
my ($flat_directory,$dbname) = $self->_rearrange([qw(DIRECTORY DBNAME)],@_);
134
my ($flat_directory,$dbname,$format) =
135
$self->_rearrange([qw(DIRECTORY DBNAME FORMAT)],@_);
140
137
defined $flat_directory
141
138
or $self->throw('Please supply a -directory argument');
166
163
# now we figure out what subclass to instantiate
167
164
my $index_type = $self->indexing_scheme eq 'BerkeleyDB/1' ? 'BDB'
168
165
:$self->indexing_scheme eq 'flat/1' ? 'Binary'
169
:$self->throw("unknown indexing scheme: ".$self->indexing_scheme);
170
my $format = $self->file_format;
166
:$self->throw("unknown indexing scheme: " .
167
$self->indexing_scheme);
168
$format = $self->file_format;
172
170
# because Michele and Lincoln did it differently
173
171
# Michele's way is via a standalone concrete class
246
245
sub new_from_registry {
247
246
my ($self,%config) = @_;
248
my $location = $config{'location'} or $self->throw('location tag must be specified.');
249
my $dbname = $config{'dbname'} or $self->throw('dbname tag must be specified.');
250
#my $index = $self->new(-directory => $location,
251
# -dbname => $dbname,
253
# my $index = $config{'protocol'} or $self->throw('index or protocol tag must be specified.');
247
my $location = $config{'location'} or
248
$self->throw('location tag must be specified.');
249
my $dbname = $config{'dbname'} or
250
$self->throw('dbname tag must be specified.');
254
252
my $db = $self->new(-directory => $location,
255
253
-dbname => $dbname,
256
# -index => $index LS: PROTOCOL DOES NOT SPECIFY INDEXING SCHEME
378
375
$self->write_flag or $self->throw("cannot write configuration file because write_flag is not set");
379
376
my $path = $self->_config_path;
381
open (F,">$path") or $self->throw("open error on $path: $!");
378
open (my $F,">$path") or $self->throw("open error on $path: $!");
383
380
my $index_type = $self->indexing_scheme;
384
print F "index\t$index_type\n";
381
print $F "index\t$index_type\n";
386
383
my $format = $self->file_format;
387
384
my $alphabet = $self->alphabet;
388
385
my $alpha = $alphabet ? "/$alphabet" : '';
389
print F "format\tURN:LSID:open-bio.org:${format}${alpha}\n";
386
print $F "format\tURN:LSID:open-bio.org:${format}${alpha}\n";
391
388
my @filenos = $self->_filenos or $self->throw("cannot write config file because no flat files defined");
392
389
for my $nf (@filenos) {
393
390
my $path = $self->{flat_flat_file_path}{$nf};
394
391
my $size = -s $path;
395
print F join("\t","fileid_$nf",$path,$size),"\n";
392
print $F join("\t","fileid_$nf",$path,$size),"\n";
398
395
# write primary namespace
399
396
my $primary_ns = $self->primary_namespace
400
397
or $self->throw('cannot write config file because no primary namespace defined');
402
print F join("\t",'primary_namespace',$primary_ns),"\n";
399
print $F join("\t",'primary_namespace',$primary_ns),"\n";
404
401
# write secondary namespaces
405
402
my @secondary = $self->secondary_namespaces;
406
print F join("\t",'secondary_namespaces',@secondary),"\n";
403
print $F join("\t",'secondary_namespaces',@secondary),"\n";
408
close F or $self->throw("close error on $path: $!");
405
close $F or $self->throw("close error on $path: $!");
457
454
my $path = $self->_config_path;
458
455
return unless -e $path;
460
open (F,$path) or $self->throw("open error on $path: $!");
457
open (my $F,$path) or $self->throw("open error on $path: $!");
464
461
my ($tag,@values) = split "\t";
465
462
$config{$tag} = \@values;
467
CORE::close F or $self->throw("close error on $path: $!");
464
CORE::close $F or $self->throw("close error on $path: $!");
469
466
$config{index}[0] =~ m~(flat/1|BerkeleyDB/1)~
470
467
or $self->throw("invalid configuration file $path: no index line");