5 modules.pl - information about modules in BioPerl core
9 B<modules.pl> [B<-V|--verbose>] [B<-c|--count>] | [B<-l|--list>] |
10 [B<-u|--untested>] | [B<-i|--info> class] | [B<-i|--inherit> |
11 [B<-d|--dir> path ] | [B<-v|--version> | [B<-?|-h|--help>]
15 This script counts, lists and provides other information about bioperl
16 modules. It is mainly meant to be run by bioperl maintainers.
18 The default action is to count modules in the bioperl core
19 distribution. Based on the class name it tries to classify them into
20 categories. The following is a tentative glossary of terms used.
27 Synonyms: Generic class, parameterized class, generic module.
29 A class that you don't instantiate in your scripts, but that it's a
30 template for other classes.
32 Examples: Bio::Tools::Run::WrapperBase - a base object for wrappers
33 around executables. Bio::Tools::Analysis::SimpleAnalysisBase - an
34 abstract superclass for SimpleAnalysis implementations
36 This are counted with C</:Base/ | /Base$/>; They have "Base" in the
37 beginning or end of the name.
41 Synonyms: protocol, feature set.
43 Class that defines a set of features that are common to a group of
46 Example: Bio::Tree::NodeI - interface describing a Tree Node.
48 This are counted with C</[^A-Z]I$/>; They have "I" at the end of the
53 A class that implements a small subset of their superclass. They are in
54 a directory with an identical name of the superclass. There are plenty
55 of them. You need only a small number of methods to be overridden.
57 Example: Bio::SeqIO::fasta.
59 This is counted with C</.*:[a-z]/>; Classes are inside their base directory
64 The rest of them. It is sometimes helpful to divide them into two
69 =item Algorithmic classes
71 Example: Bio::AlignIO - Handler for AlignIO formats
75 Example: Bio::SimpleAlign - Multiple alignments held as a set of
85 # The helper class to store class status;
95 $self->{'name'} = $name;
96 $self->{'tested'} = 0;
106 return $self->{'name'};
112 $self->{'tested'} = 1 if defined $value && $value;
113 return $self->{'tested'} || 0;
119 $self->{'type'} = $value if defined $value;
120 return $self->{'type'};
126 $self->{'path'} = $value if defined $value;
127 return $self->{'path'};
132 my $superclass = shift;
133 return unless $superclass;
134 $self->{'superclasses'}->{$superclass} = 1 ;
137 sub each_superclass
{
139 return keys %{$self->{'superclasses'}};
144 my $used_class = shift;
145 return unless $used_class;
146 $self->{'used_classes'}->{$used_class} = 1 ;
149 sub each_used_class
{
151 return keys %{$self->{'used_classes'}};
162 # declare subroutines
173 # command line options
174 my ($dir, $count,$list, $verbose,$info,$untested, $inherit, $synopsis,
180 'test_BioClass' => \
&_test_BioClass
,
181 'V|verbose' => \
$verbose,
182 'untested' => \
$untested,
184 'inherit' => \
$inherit,
185 'synopsis' => \
$synopsis,
186 'version' => \
$version,
187 'h|help|?' => sub{ exec('perldoc',$0); exit(0) }
191 our %MODULES; # storage structure
195 my $seachdir = "$pwd/../Bio"; #default
196 my %FIND_OPTIONS = ( wanted
=> \
&modules
);
198 $seachdir = "$pwd/$dir" if $dir;
199 find \
%FIND_OPTIONS, $seachdir;
203 if ($list) { list_all
}
204 elsif ($untested) { untested
}
205 elsif ($info) { info
($info) }
206 elsif ($inherit) { inherit
}
207 elsif ($synopsis) { synopsis
}
208 elsif ($version) { version
}
212 ################# end main ####################
220 $a = new BioClass
('Bio::Test');
221 print "Class name: ", $a->name(), "\n";
222 $a->add_superclass('Bio::Super');
223 $a->add_superclass('Bio::Super2');
225 $a->type('instance');
226 print Dumper
[$a->each_superclass] if $a->tested;
232 return unless /\.pm$/ ;
233 #return unless -e $_;
234 #print "file: $_\n" if $verbose;
235 open my $F, '<', $_ or warn "Could not read file '$_': $!\n" && return;
238 if (/^package\s+([\w:]+)\s*;/) {
239 #print $1, "\n" if $verbose;
241 $class = new BioClass
($_);
242 $MODULES{$_} = $class;
244 $class->type('component');
245 } elsif (/:Base/ | /Base$/) {
246 $class->type('base');
247 } elsif (/[^A-Z]I$/) {
248 $class->type('interface');
250 $class->type('instance');
252 $class->path($File::Find
::name
);
254 if (/^\w*use/ && /(Bio[\w:]+)\W*;/ && not /base/) {
256 #print "\t$1\n" if $verbose;
257 $class->add_used_class($1);
259 if ((/\@ISA/ || /use base/) && /Bio/) {
262 while ( $line =~ /(Bio[\w:]+)/g) {
263 #print "\t$1\n" if $verbose;
264 $class->add_superclass($1);
267 if (/\@ISA/ && /Bio/) {
270 while ( $line =~ /(Bio[\w:]+)/g) {
271 #print "\t$1\n" if $verbose;
272 $class->add_superclass($1);
281 Only one option is processed on each run of the script. The --verbose
282 is an exception, it modifies the amount of output.
286 =item B<-V | --verbose>
290 Set this option if you want to see more verbose output. Often that
291 will mean seeing warnings normally going into STDERR.
295 =item B<-d | --dir> path
297 Overides the default directories to check by one directory 'path' and
298 all its subdirectories.
300 =item B<-c | --count>
302 The default action if no other option is given. Gives the count of
303 modules broken to B<instance> ("usable"), B<base> ( (abstract)?
304 superclass) , B<interface> (the "I" files) and B<component> (used from
305 instantiable parent) modules, in addition to total number of modules.
307 Note that abstract superclass in bioperl is not an enforced concept and
308 they are not clearly indicateded in the class name.
313 printf "Instance : %3d\n",
314 scalar (grep $MODULES{$_}->type =~ /instance/ , keys %MODULES);
315 printf "Base : %3d\n",
316 scalar (grep $MODULES{$_}->type =~ /base/ , keys %MODULES);
317 printf "Interface: %3d\n",
318 scalar (grep $MODULES{$_}->type =~ /interface/ , keys %MODULES);
319 printf "Component: %3d\n",
320 scalar (grep $MODULES{$_}->type =~ /component/ , keys %MODULES);
321 print "--------------\n";
322 printf "Total : %3d\n", scalar (keys %MODULES);
328 Prints all the module names in alphabetical order. The output is a tab
329 separated list of category (see above) and module name per line. The
330 output can be processed with standard UNIX command line tools.
335 foreach ( sort keys %MODULES) {
336 print $MODULES{$_}->type. "\t$_\n";
340 =item B<-u | --untested>
342 Prints a list of instance modules which are I<not> explicitly used by
343 test files in the directory. Superclasess or any classes used by others
344 are not reported, either, since their methods are assumed to be tested
350 sub _used_and_super
{
352 # print "-:$name\n" if /Locati/;
353 foreach ($MODULES{$name}->each_superclass) {
354 next unless defined $MODULES{$_};
355 # print "-^$_\n" if /Locati/;
356 # unless (defined $MODULES{$_} or $MODULES{$_}->tested) {
357 if (not $MODULES{$_}->tested) {
358 $MODULES{$_}->tested(1);
362 foreach ($MODULES{$name}->each_used_class) {
363 next unless defined $MODULES{$_};
364 # print "--$_\n" if /Locati/;
365 # unless (defined $MODULES{$_} or $MODULES{$_}->tested) {
366 if (not $MODULES{$_}->tested) {
367 $MODULES{$_}->tested(1);
370 # $MODULES{$_}->tested(1) && _used_and_super($_)
371 # unless defined $MODULES{$_} or $MODULES{$_}->tested;
377 foreach (`find ../t -name "*.t" -print | xargs grep -hs "[ur][se][eq]"`) {
386 next unless $MODULES{$_};
387 $MODULES{$_}->tested(1)
388 unless defined $MODULES{$_} and $MODULES{$_}->tested;
390 next if $MODULES{$name}->name eq "Bio::SeqIO::abi"; # exception: requires bioperl ext package
391 next if $MODULES{$name}->name eq "Bio::SeqIO::ctf"; # exception: requires bioperl ext package
392 next if $MODULES{$name}->name eq "Bio::SeqIO::exp"; # exception: requires bioperl ext package
393 next if $MODULES{$name}->name eq "Bio::SeqIO::pln"; # exception: requires bioperl ext package
394 next if $MODULES{$name}->name eq "Bio::SeqIO::ztr"; # exception: requires bioperl ext package
395 # print $MODULES{$name}->name, "\n";
396 # print Dumper $MODULES{$name};
398 _used_and_super
($name);
402 foreach ( sort keys %MODULES) {
404 # skip some name spaces
405 next if /^Bio::Search/; # Bio::Search and Bio::SearchIO are extensively tested
406 # but classes are used by attribute naming
409 $MODULES{$_}->type eq 'instance' and ($MODULES{$_}->tested == 0) ;
414 =item B<-i | --info> class
416 Dumps information about a class given as an argument.
422 die "" unless $class;
423 #print Dumper $MODULES{$class};
424 my $c = $MODULES{$class};
425 print $c->name, "\n";
426 printf " Type:\n\t%s\n", $c->type;
427 print " Superclasses:\n";
428 foreach (sort $c->each_superclass) {
431 print " Used classes:\n";
432 foreach (sort $c->each_used_class) {
438 =item B<-i | --inherit>
440 Finds interface modules which inherit from an instantiable class.
442 Could be extended to check other bad inheritance patterns.
447 foreach ( sort keys %MODULES) {
449 next unless $c->type =~ /interface/;
450 foreach my $super ($c->each_superclass) {
451 next if $super =~ /I$/;
452 print "Check this inheritance: ", $c->name, " <-- $super\n";
457 =item B<-s | --synopsis>
459 Test SYNOPSIS section of bioperl modules for runnability
464 foreach ( sort keys %MODULES) {
467 next unless $c->type eq "instance";
468 next if $c->name eq 'Bio::Root::Version';
469 next if $c->name eq 'Bio::Tools::HMM';
472 open my $F, '<', $c->path or warn "Could not read file '".$c->name."': $!\n" && return;
476 last if $flag && /^=/;
477 $synopsis .= $_ if $flag;
478 $flag = 1 if /^=head1 +SYNOPSIS/;
482 $synopsis =~ s/[^\$]#[^\n]*//g;
483 # allow linking to an other Bio module, e.g.: See L<Bio::DB::GFF>.
484 $synopsis =~ s/[^\n]*L<Bio[^\n]*//g;
485 # protect single quotes
486 $synopsis =~ s/'/"/g;
488 my $res = `perl -ce '$synopsis' 2>&1 `;
489 next if $res =~ /syntax OK/;
490 print $c->path, "\n";
493 print "-" x
70, "\n";
494 # print "SYNOPSIS not runnable\n";
499 =item B<-v | --version>
501 Test the VERSION of the module against the global one set in
502 Bio::Root::Variation. Print out the different ones.
508 use Bio
::Root
::Version
;
509 my $version = $Bio::Root
::Version
::VERSION
;
511 my %skip = ( # these are defined together with an other module
512 # and can not be use independently
513 'Bio::AnalysisI::JobI' => 1,
514 'Bio::PrimarySeq::Fasta' => 1,
515 'Bio::DB::Fasta::Stream' => 1,
516 'Bio::DB::GFF::ID_Iterator' => 1,
517 'Bio::DB::GFF::Adaptor::dbi::faux_dbh' =>1,
518 'Bio::LiveSeq::IO::SRS' =>1 # tries to call an external module
521 foreach ( sort keys %MODULES) {
522 my $n=$MODULES{$_}->name;
524 my $vv= "\$${n}::VERSION";
525 my $v = `perl -we 'use $n; print $vv;'`;
526 printf "%50s %-3s\n", $n, $v unless $version eq $v;
532 =item B<-? | -h | --help>
542 User feedback is an integral part of the evolution of this and other
543 Bioperl modules. Send your comments and suggestions preferably to
544 the Bioperl mailing list. Your participation is much appreciated.
546 bioperl-l@bioperl.org - General discussion
547 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
549 =head2 Reporting Bugs
551 Report bugs to the Bioperl bug tracking system to help us keep track
552 of the bugs and their resolution. Bug reports can be submitted via the
555 https://github.com/bioperl/bioperl-live/issues
559 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
563 Albert Vilella, avilella-AT-gmail-DOT-com