bp_pairwise_kaks.pl: do not mix space and tabs for indentation.
[bioperl-live.git] / Build.PL
blob3604b82a82bf444c3b09d96ee5cfc67a16985134
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 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
75 'Convert::Binary::C' =>
76 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
78 'DB_File' => [ 0, 'Database functionality/Bio::Assemby,Bio::DB' ],
80 'Error' => [
81 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
84 'HTML::TableExtract' => [
85 0, 'HTML parsing/Bio::DB::SeqVersion::gi'
88 'GD' => [ 0, 'Alignment graphic output/Bio::Align::Graphics' ],
90 'Graph' => [
91 0.50,
92 'Phylogenetic Networks, ontology engine implementation, contig analysis'
93 . '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'
94 . 'Bio::Assembly::Tools::ContigSpectrum'
97 'GraphViz' => [
98 0, 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'
101 'HTML::Entities' =>
102 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
104 'HTML::HeadParser' => [
106 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
109 'HTML::TableExtract' =>
110 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
112 'HTTP::Request::Common' => [
114 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
115 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
116 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
119 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
121 'IO::Scalar' => [
122 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
125 'List::MoreUtils' => [
127 'Back- or reverse-translation of sequences/'
128 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
131 'LWP::UserAgent' => [
133 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
136 'PostScript::TextBlock' => [ 0, 'EPS output/Bio::Tree::Draw::Cladogram' ],
138 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
140 'SOAP::Lite' => [ 0, 'Bibliographic queries/Bio::DB::Biblio::soap' ],
142 'Sort::Naturally' => [
144 'Sort lexically, but sort numeral parts numerically/'
145 . 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'
148 'Spreadsheet::ParseExcel' =>
149 [ 0, 'Parsing Excel files/Bio::SeqIO::excel' ],
151 'Storable' => [
152 2.05,
153 'Storing sequence objects in local file cache/'
154 . 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'
155 . 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'
158 'SVG' => [ 2.26, 'Creating SVG images/Bio::Draw::Pictogram' ],
160 'SVG::Graph' => [ 0.01, 'Creating SVG images/Bio::TreeIO::svggraph' ],
162 'Text::ParseWords' =>
163 [ 0, 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader' ],
165 'XML::DOM' => [ 0, 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro' ],
167 'XML::DOM::XPath' => [ 0, 'Parsing XML/Bio::SeqIO::interpro' ],
169 'XML::LibXML' =>
170 [ 0, 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml' ],
172 'XML::Parser' => [ 0, 'Parsing XML/Bio::Biblio::IO::medlinexml' ],
174 'XML::Parser::PerlSAX' => [
176 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
177 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'
180 'XML::SAX' => [
181 0.15,
182 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'
185 'XML::SAX::Writer' => [ 0, 'Writing XML/Bio::SeqIO::tigrxml' ],
187 'XML::Simple' => [
189 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'
192 'XML::Twig' => [
194 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'
195 . 'Bio::DB::Biblio::eutils'
198 'XML::Writer' => [
199 0.4,
200 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
201 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
202 . 'Bio::SearchIO::Writer::BSMLResultWriter'
205 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
208 my $mysql_ok = 0;
210 my @drivers = available_drivers();
212 # Set up the Bio::Root::Build object
213 my $build = Bio::Root::Build->new(
214 module_name => 'Bio',
215 dist_name => 'BioPerl',
216 dist_version => '1.006925',
217 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
218 dist_abstract => 'Bioinformatics Toolkit',
219 license => 'perl',
220 requires => {
221 'perl' => '5.6.1',
222 'IO::String' => 0, # why is this required?
223 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
224 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
225 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
228 build_requires => {
229 'CPAN' => 1.81,
230 'Module::Build' => 0.2805,
231 'Test::Harness' => 2.62,
232 'Test::Most' => 0,
233 'URI::Escape' => 0
236 recommends => {
237 # reverted to a simple Module::Build-compatible hash, but we keep
238 # additional data in the %recommends hash above. May be converted to
239 # something simpler if there aren't complaints down the line.
240 map { $_ => $recommends{$_}[0] } sort keys %recommends
243 get_options => {
244 accept => {},
245 network => {} # say 'perl Build.PL --network' to manually request network tests
248 auto_features => {
249 'EntrezGene' => {
250 description => "Presence of Bio::ASN1::EntrezGene",
251 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
254 'DB_File Tests' => {
255 description => "BDB tests for Bio::DB::SeqFeature::Store",
256 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
259 'Bio::DB::GFF Tests' => {
260 description =>
261 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
262 requires => { 'DBI' => 0 },
265 'MySQL Tests' => {
266 description =>
267 "MySQL-related tests for Bio::DB::SeqFeature::Store",
268 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
271 'Pg Tests' => {
272 description =>
273 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
274 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
277 'SQLite Tests' => {
278 description =>
279 "SQLite-related tests for Bio::DB::SeqFeature::Store",
280 requires => { 'DBI' => 0, 'DBD::SQLite' => 0 },
283 'Network Tests' => {
284 description => "Enable tests that need an internet connection",
285 requires => { 'LWP::UserAgent' => 0 },
288 dynamic_config => 1,
289 recursive_test_files => 1,
291 # Extra files needed for BioPerl modules
292 xml_files => {
293 './Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'
296 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
297 #script_files => [] # scripts in scripts directory are installed on-demand
300 my $accept = $build->args('accept');
302 my $proceed = prompt_for_biodb($accept)
303 if $build->feature('Bio::DB::GFF')
304 || $build->feature('MySQL Tests')
305 || $build->feature('Pg Tests')
306 || $build->feature('SQLite Tests');
308 # Handle auto features
309 if ( $proceed && $build->feature('DB_File Tests') ) {
311 # will return without doing anything if user chose not to run tests during
312 make_bdb_test();
314 if ($proceed
315 && ( $build->feature('MySQL Tests')
316 || $build->feature('Pg Tests')
317 || $build->feature('SQLite Tests') )
319 make_dbi_test();
322 # Ask questions
323 $build->choose_scripts($accept);
325 if ( $build->args('network') ) {
326 if ( $build->feature('Network Tests') ) {
327 $build->notes( network => 1 );
328 $build->log_info(" - will run internet-requiring tests\n");
329 } else {
330 $build->notes( network => 0 );
331 $build->log_info(
332 " - Missing LWP::UserAgent, can't run network tests\n");
334 } else {
335 $build->prompt_for_network($accept) if $build->feature('Network Tests');
338 # Add additional files here
339 $build->add_build_element('xml');
341 # Create the build script and exit
342 $build->create_build_script;
344 exit;
346 ########################## Helper subs ##########################
348 sub make_bdb_test {
349 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
350 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
351 unlink($path) if ( -e $path );
352 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
353 print $F <<END;
354 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
356 close $F;
357 $build->add_to_cleanup($path);
359 #$build->add_to_manifest_skip($path);
362 sub available_drivers {
363 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
364 return if $@;
365 @drivers = DBI->available_drivers;
366 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
367 $mysql_ok = 0;
368 return
369 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
371 $mysql_ok = 1;
372 return @drivers;
375 sub make_dbi_test {
376 my $dsn = $build->notes('test_dsn') || return;
377 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
378 my $driver = $build->notes('dbd_driver');
379 my $path = File::Spec->catfile( 't', 'LocalDB',
380 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
381 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
382 : 'SeqFeature_Pg.t' );
383 my $test_db = $build->notes('test_db');
384 my $user = $build->notes('test_user');
385 my $pass = $build->notes('test_pass');
386 open my $F, '>', $path
387 or die "Could not write file '$path' for DBI test: $!\n";
388 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
389 $str .= " -user $user" if $user;
390 $str .= " -password $pass" if $pass;
391 print $F <<END;
392 system '$^X $str';
394 close $F;
395 $build->add_to_cleanup($path);
396 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
398 #$build->add_to_manifest_skip($path);
401 sub test_biodbgff {
402 eval { require DBI; }; # if not installed, this sub won't actually be called
403 return if $@;
404 @drivers = DBI->available_drivers;
405 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
406 return "MySQL, Pg nor Oracle DBI drivers are installed";
408 return;
411 sub prompt_for_biodb {
412 my $accept = shift;
413 my $proceed = $accept ? 0 : $build->y_n(
414 "Do you want to run the Bio::DB::GFF or "
415 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
419 if ($proceed) {
420 my @driver_choices;
421 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
422 if ( grep {/$poss/i} @drivers ) {
423 my $choice = $poss;
424 $choice =~ s/^(.)/[$1]/;
425 push( @driver_choices, $choice );
429 my $driver;
430 if ( @driver_choices > 1 ) {
431 my ($default) = $driver_choices[0] =~ /\[(.)/;
432 $driver = $build->prompt(
433 "Which database driver should be used? "
434 . join( " ", @driver_choices ),
435 $default
437 } else {
438 ($driver) = $driver_choices[0] =~ /\[(.)/;
440 if ( $driver =~ /^[mM]/ ) {
441 $driver = 'mysql';
442 } elsif ( $driver =~ /^[pP]/ ) {
443 $driver = 'Pg';
444 } elsif ( $driver =~ /^[oO]/ ) {
445 $driver = 'Oracle';
446 } elsif ( $driver =~ /^[sS]/ ) {
447 $driver = 'SQLite';
450 my $test_db = $build->prompt(
451 "Which database should I use for testing the $driver driver?\n"
452 . "This database should already be present but doesn't have to "
453 . "be preloaded for any schema",
454 'test'
456 my $test_host = $build->prompt(
457 "On which host is database '$test_db' running (hostname, ip address or host:port)",
458 'localhost'
460 my $test_user = $build->prompt(
461 "User name for connecting to database '$test_db'?", 'undef' );
462 my $test_pass = $build->prompt(
463 "Password for connecting to database '$test_db'?", 'undef' );
465 my $use_host = 1;
466 if ( $test_host eq 'undef' || $test_host eq 'localhost' ) {
467 $use_host = 0;
470 my $test_dsn;
471 if ( $driver eq 'Pg' || $driver eq 'SQLite' ) {
472 $test_dsn = "dbi:$driver:dbname=$test_db";
473 $mysql_ok = 0;
474 } else {
475 $test_dsn = "dbi:$driver:database=$test_db";
476 $mysql_ok = 0;
478 if ($use_host) {
479 $test_dsn .= ";host=$test_host";
482 $build->notes( dbd_driver => $driver );
483 $build->notes( test_db => $test_db );
484 $build->notes( test_host => $test_host );
485 $build->notes(
486 test_user => $test_user eq 'undef' ? undef : $test_user );
487 $build->notes(
488 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
489 $build->notes( test_dsn => $test_dsn );
491 $build->log_info(
492 " - will run tests with database driver '$driver' and these settings:\n",
493 " Database $test_db\n",
494 " Host $test_host\n",
495 " DSN $test_dsn\n",
496 " User $test_user\n",
497 " Password $test_pass\n"
499 $build->log_info( " - will not run the BioDBSeqFeature live "
500 . "database tests (requires MySQL or Pg driver)\n" )
501 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
502 } else {
503 $build->log_info(
504 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
508 $build->log_info("\n");
509 return $proceed;