Merge pull request #169 from bioperl/fix-seqversion-test
[bioperl-live.git] / Build.PL
blobaad61d05bae47c1275551cbcb05af5efbedb92c9
1 #!/usr/bin/perl
3 # This is a Module::Build script for Bioperl installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
6 # Uses a custom subclass of Module::Build called Bio::Root::Build
8 # In the future developers may need to alter the requires and recommends
9 # sections of Bio::Root::Build->new() below, but otherwise nothing else here is
10 # likely to need changing.
12 use strict;
13 use lib '.';
14 use Bio::Root::Build;
16 # XML::SAX::RTF doesn't work with BioPerl, at all, nada, zilch.
18 # Since we're running into this now on CPAN Testers, catch it up front and
19 # deal with it.
21 # See: https://rt.cpan.org/Ticket/Display.html?id=5943
22 # https://redmine.open-bio.org/issues/2975
25 eval { require XML::SAX; 1; };
27 unless ($@) {
28 if ( grep { $_->{Name} =~ 'XML::SAX::RTF' } @{ XML::SAX->parsers() } )
30 warn <<WARN;
32 ############################# WARNING #############################
34 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
35 XML::SAX parser. If used as the primary parser, modules requiring
36 XML::SAX will NOT work. Please install another XML::SAX-compliant
37 module and modify your local ParserDetails.ini file per XML::SAX
38 docs to remove references to XML::SAX::RTF.
40 ############################# WARNING #############################
42 WARN
43 sleep 2;
48 my %recommends = (
50 # AcePerl support is deprecated, per LDS - cjfields - 5-5-2011
52 #'Ace' => [0,
53 # 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
55 'Algorithm::Munkres' => [ 0, 'Phylogenetic Networks/Bio::PhyloNetwork' ],
57 'Array::Compare' => [ 0, 'Phylogenetic Networks/Bio::PhyloNetwork' ],
59 # this won't actually install due to circular dep, but we have no way of
60 # doing a post-install the [circular dependency!] specifies it is only
61 # installed on explicit request for this specific module, not when simply
62 # choosing to install 'all' modules
64 #'Bio::ASN1::EntrezGene' => [0,
65 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
67 'Bio::Phylo' => [
69 'NeXML related modules/Bio::AlignIO::nexml,Bio::Nexml::Factory,'
70 . 'Bio::SeqIO::nexml,Bio::TreeIO::nexml'
73 'CGI' => [ 0, 'CGI-y things/Bio::DB::Query::HIVQuery' ],
75 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
77 'Convert::Binary::C' =>
78 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
80 'DB_File' => [ 0, 'Database functionality/Bio::Assemby,Bio::DB' ],
82 'Error' => [
83 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
86 'GD' => [ 0, 'Alignment graphic output/Bio::Align::Graphics' ],
88 'Graph' => [
89 0.50,
90 'Phylogenetic Networks, ontology engine implementation, contig analysis'
91 . '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'
92 . 'Bio::Assembly::Tools::ContigSpectrum'
95 'GraphViz' => [
96 0, 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'
99 'HTML::Entities' =>
100 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
102 'HTML::HeadParser' => [
104 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
107 'HTML::TableExtract' =>
108 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
110 'HTTP::Request::Common' => [
112 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
113 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
114 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
117 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
119 'IO::Scalar' => [
120 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
123 'List::MoreUtils' => [
125 'Back- or reverse-translation of sequences/'
126 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
129 'LWP::UserAgent' => [
131 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
134 'PostScript::TextBlock' => [ 0, 'EPS output/Bio::Tree::Draw::Cladogram' ],
136 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
138 'SOAP::Lite' => [ 0, 'Bibliographic queries/Bio::DB::Biblio::soap' ],
140 'Sort::Naturally' => [
142 'Sort lexically, but sort numeral parts numerically/'
143 . 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'
146 'Spreadsheet::ParseExcel' =>
147 [ 0, 'Parsing Excel files/Bio::SeqIO::excel' ],
149 'Storable' => [
150 2.05,
151 'Storing sequence objects in local file cache/'
152 . 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'
153 . 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'
156 'SVG' => [ 2.26, 'Creating SVG images/Bio::Draw::Pictogram' ],
158 'SVG::Graph' => [ 0.01, 'Creating SVG images/Bio::TreeIO::svggraph' ],
160 'Text::ParseWords' =>
161 [ 0, 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader' ],
163 'XML::DOM' => [ 0, 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro' ],
165 'XML::DOM::XPath' => [ 0, 'Parsing XML/Bio::SeqIO::interpro' ],
167 'XML::LibXML' =>
168 [ 0, 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml' ],
170 'XML::Parser' => [ 0, 'Parsing XML/Bio::Biblio::IO::medlinexml' ],
172 'XML::Parser::PerlSAX' => [
174 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
175 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'
178 'XML::SAX' => [
179 0.15,
180 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'
183 'XML::SAX::Writer' => [ 0, 'Writing XML/Bio::SeqIO::tigrxml' ],
185 'XML::Simple' => [
187 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'
190 'XML::Twig' => [
192 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'
193 . 'Bio::DB::Biblio::eutils'
196 'XML::Writer' => [
197 0.4,
198 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
199 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
200 . 'Bio::SearchIO::Writer::BSMLResultWriter'
203 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
206 my $mysql_ok = 0;
208 my @drivers = available_drivers();
210 # Set up the Bio::Root::Build object
211 my $build = Bio::Root::Build->new(
212 module_name => 'Bio',
213 dist_name => 'BioPerl',
214 dist_version => $Bio::Root::Version::VERSION,
215 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
216 dist_abstract => 'Bioinformatics Toolkit',
217 license => 'perl',
218 requires => {
219 'perl' => '5.6.1',
220 'IO::String' => 0, # why is this required?
221 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
222 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
223 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
226 build_requires => {
227 'CPAN' => 1.81,
228 'Module::Build' => 0.2805,
229 'Test::Harness' => 2.62,
230 'Test::Most' => 0,
231 'URI::Escape' => 0
234 recommends => {
235 # reverted to a simple Module::Build-compatible hash, but we keep
236 # additional data in the %recommends hash above. May be converted to
237 # something simpler if there aren't complaints down the line.
238 map { $_ => $recommends{$_}[0] } sort keys %recommends
241 get_options => {
242 accept => {},
243 network => {} # say 'perl Build.PL --network' to manually request network tests
246 auto_features => {
247 'EntrezGene' => {
248 description => "Presence of Bio::ASN1::EntrezGene",
249 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
252 'DB_File Tests' => {
253 description => "BDB tests for Bio::DB::SeqFeature::Store",
254 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
257 'Bio::DB::GFF Tests' => {
258 description =>
259 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
260 requires => { 'DBI' => 0 },
263 'MySQL Tests' => {
264 description =>
265 "MySQL-related tests for Bio::DB::SeqFeature::Store",
266 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
269 'Pg Tests' => {
270 description =>
271 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
272 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
275 'SQLite Tests' => {
276 description =>
277 "SQLite-related tests for Bio::DB::SeqFeature::Store",
278 requires => { 'DBI' => 0, 'DBD::SQLite' => 0 },
281 'Network Tests' => {
282 description => "Enable tests that need an internet connection",
283 requires => { 'LWP::UserAgent' => 0 },
286 dynamic_config => 1,
287 recursive_test_files => 1,
289 # Extra files needed for BioPerl modules
290 xml_files => {
291 './Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'
294 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
295 #script_files => [] # scripts in scripts directory are installed on-demand
298 my $accept = $build->args('accept');
300 my $proceed = prompt_for_biodb($accept)
301 if $build->feature('Bio::DB::GFF')
302 || $build->feature('MySQL Tests')
303 || $build->feature('Pg Tests')
304 || $build->feature('SQLite Tests');
306 # Handle auto features
307 if ( $proceed && $build->feature('DB_File Tests') ) {
309 # will return without doing anything if user chose not to run tests during
310 make_bdb_test();
312 if ($proceed
313 && ( $build->feature('MySQL Tests')
314 || $build->feature('Pg Tests')
315 || $build->feature('SQLite Tests') )
317 make_dbi_test();
320 # Ask questions
321 $build->choose_scripts($accept);
323 if ( $build->args('network') ) {
324 if ( $build->feature('Network Tests') ) {
325 $build->notes( network => 1 );
326 $build->log_info(" - will run internet-requiring tests\n");
327 } else {
328 $build->notes( network => 0 );
329 $build->log_info(
330 " - Missing LWP::UserAgent, can't run network tests\n");
332 } else {
333 $build->prompt_for_network($accept) if $build->feature('Network Tests');
336 # Add additional files here
337 $build->add_build_element('xml');
339 # Create the build script and exit
340 $build->create_build_script;
342 exit;
344 ########################## Helper subs ##########################
346 sub make_bdb_test {
347 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
348 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
349 unlink($path) if ( -e $path );
350 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
351 print $F <<END;
352 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
354 close $F;
355 $build->add_to_cleanup($path);
357 #$build->add_to_manifest_skip($path);
360 sub available_drivers {
361 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
362 return if $@;
363 @drivers = DBI->available_drivers;
364 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
365 $mysql_ok = 0;
366 return
367 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
369 $mysql_ok = 1;
370 return @drivers;
373 sub make_dbi_test {
374 my $dsn = $build->notes('test_dsn') || return;
375 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
376 my $driver = $build->notes('dbd_driver');
377 my $path = File::Spec->catfile( 't', 'LocalDB',
378 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
379 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
380 : 'SeqFeature_Pg.t' );
381 my $test_db = $build->notes('test_db');
382 my $user = $build->notes('test_user');
383 my $pass = $build->notes('test_pass');
384 open my $F, '>', $path
385 or die "Could not write file '$path' for DBI test: $!\n";
386 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
387 $str .= " -user $user" if $user;
388 $str .= " -password $pass" if $pass;
389 print $F <<END;
390 system '$^X $str';
392 close $F;
393 $build->add_to_cleanup($path);
394 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
396 #$build->add_to_manifest_skip($path);
399 sub test_biodbgff {
400 eval { require DBI; }; # if not installed, this sub won't actually be called
401 return if $@;
402 @drivers = DBI->available_drivers;
403 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
404 return "MySQL, Pg nor Oracle DBI drivers are installed";
406 return;
409 sub prompt_for_biodb {
410 my $accept = shift;
411 my $proceed = $accept ? 0 : $build->y_n(
412 "Do you want to run the Bio::DB::GFF or "
413 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
417 if ($proceed) {
418 my @driver_choices;
419 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
420 if ( grep {/$poss/i} @drivers ) {
421 my $choice = $poss;
422 $choice =~ s/^(.)/[$1]/;
423 push( @driver_choices, $choice );
427 my $driver;
428 if ( @driver_choices > 1 ) {
429 my ($default) = $driver_choices[0] =~ /\[(.)/;
430 $driver = $build->prompt(
431 "Which database driver should be used? "
432 . join( " ", @driver_choices ),
433 $default
435 } else {
436 ($driver) = $driver_choices[0] =~ /\[(.)/;
438 if ( $driver =~ /^[mM]/ ) {
439 $driver = 'mysql';
440 } elsif ( $driver =~ /^[pP]/ ) {
441 $driver = 'Pg';
442 } elsif ( $driver =~ /^[oO]/ ) {
443 $driver = 'Oracle';
444 } elsif ( $driver =~ /^[sS]/ ) {
445 $driver = 'SQLite';
448 my $test_db = $build->prompt(
449 "Which database should I use for testing the $driver driver?\n"
450 . "This database should already be present but doesn't have to "
451 . "be preloaded for any schema",
452 'test'
454 my $test_host = $build->prompt(
455 "On which host is database '$test_db' running (hostname, ip address or host:port)",
456 'localhost'
458 my $test_user = $build->prompt(
459 "User name for connecting to database '$test_db'?", 'undef' );
460 my $test_pass = $build->prompt(
461 "Password for connecting to database '$test_db'?", 'undef' );
463 my $use_host = 1;
464 if ( $test_host eq 'undef' || $test_host eq 'localhost' ) {
465 $use_host = 0;
468 my $test_dsn;
469 if ( $driver eq 'Pg' || $driver eq 'SQLite' ) {
470 $test_dsn = "dbi:$driver:dbname=$test_db";
471 $mysql_ok = 0;
472 } else {
473 $test_dsn = "dbi:$driver:database=$test_db";
474 $mysql_ok = 0;
476 if ($use_host) {
477 $test_dsn .= ";host=$test_host";
480 $build->notes( dbd_driver => $driver );
481 $build->notes( test_db => $test_db );
482 $build->notes( test_host => $test_host );
483 $build->notes(
484 test_user => $test_user eq 'undef' ? undef : $test_user );
485 $build->notes(
486 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
487 $build->notes( test_dsn => $test_dsn );
489 $build->log_info(
490 " - will run tests with database driver '$driver' and these settings:\n",
491 " Database $test_db\n",
492 " Host $test_host\n",
493 " DSN $test_dsn\n",
494 " User $test_user\n",
495 " Password $test_pass\n"
497 $build->log_info( " - will not run the BioDBSeqFeature live "
498 . "database tests (requires MySQL or Pg driver)\n" )
499 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
500 } else {
501 $build->log_info(
502 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
506 $build->log_info("\n");
507 return $proceed;