A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / Build.PL
blobb171d21875e6b9bf9f0c3c1c8f08dfa6d91aaa01
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
24 { eval { require XML::SAX; 1; };
26 unless ($@) {
27 if (grep {$_->{Name} =~ 'XML::SAX::RTF'} @{XML::SAX->parsers()}) {
28 warn <<WARN;
30 ############################# WARNING #############################
32 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
33 XML::SAX parser. If used as the primary parser, modules requiring
34 XML::SAX will NOT work. Please install another XML::SAX-compliant
35 module and modify your local ParserDetails.ini file per XML::SAX
36 docs to remove references to XML::SAX::RTF.
38 ############################# WARNING #############################
40 WARN
41 sleep 2;
47 my %recommends = (
48 # AcePerl support is deprecated, per LDS - cjfields - 5-5-2011
50 #'Ace' => [0,
51 # 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
53 'Algorithm::Munkres' => [0,
54 'Phylogenetic Networks/Bio::PhyloNetwork'],
56 'Array::Compare' => [0,
57 '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' => [0,
68 'NeXML related modules/Bio::AlignIO::nexml,Bio::Nexml::Factory,'.
69 'Bio::SeqIO::nexml,Bio::TreeIO::nexml'],
71 'Clone' => [0,
72 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3'],
74 'Convert::Binary::C' => [0,
75 'Strider functionality/Bio::SeqIO::strider'],
77 'DB_File' => [0,
78 'Database functionality/Bio::Assemby,Bio::DB'],
80 'Error' => [0,
81 'OO-based exception handling (very optional)/Bio::Root::Exception'],
83 'GD' => [0,
84 'Alignment graphic output/Bio::Align::Graphics'],
86 'Graph' => [0.50,
87 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
88 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
89 'Bio::Assembly::Tools::ContigSpectrum'],
91 'GraphViz' => [0,
92 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'],
94 'HTML::Entities' => [0,
95 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
97 'HTML::HeadParser' => [3,
98 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
100 'HTML::TableExtract' => [0,
101 'Parsing HTML tables/Bio::DB::SeqVersion::gi'],
103 'HTTP::Request::Common' => [0,
104 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
105 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
106 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
108 'Inline::C' => [0.67,
109 'Speeding up code like Fasta Bio::DB::Fasta'],
111 'IO::Scalar' => [0,
112 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'],
114 'List::MoreUtils' => [0,
115 'Back- or reverse-translation of sequences/'.
116 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
118 'LWP::UserAgent' => [0,
119 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
121 'PostScript::TextBlock' => [0,
122 'EPS output/Bio::Tree::Draw::Cladogram'],
124 'Set::Scalar' => [0,
125 'Proper operation/Bio::Tree::Compatible'],
127 'SOAP::Lite' => [0,
128 'Bibliographic queries/Bio::DB::Biblio::soap'],
130 'Sort::Naturally' => [0,
131 'Sort lexically, but sort numeral parts numerically/'.
132 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
134 'Spreadsheet::ParseExcel' => [0,
135 'Parsing Excel files/Bio::SeqIO::excel'],
137 'Storable' => [2.05,
138 'Storing sequence objects in local file cache/'.
139 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
140 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'],
142 'SVG' => [2.26,
143 'Creating SVG images/Bio::Draw::Pictogram'],
145 'SVG::Graph' => [0.01,
146 'Creating SVG images/Bio::TreeIO::svggraph'],
148 'Text::ParseWords' => [0,
149 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
151 'XML::DOM' => [0,
152 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro'],
154 'XML::DOM::XPath' => [0,
155 'Parsing XML/Bio::SeqIO::interpro'],
157 'XML::LibXML' => [0,
158 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml'],
160 'XML::Parser' => [0,
161 'Parsing XML/Bio::Biblio::IO::medlinexml'],
163 'XML::Parser::PerlSAX' => [0,
164 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
165 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
167 'XML::SAX' => [0.15,
168 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
170 'XML::SAX::Writer' => [0,
171 'Writing XML/Bio::SeqIO::tigrxml'],
173 'XML::Simple' => [0,
174 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
176 'XML::Twig' => [0,
177 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
178 'Bio::DB::Biblio::eutils'],
180 'XML::Writer' => [0.4,
181 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
182 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
183 'Bio::SearchIO::Writer::BSMLResultWriter'],
185 'YAML' => [0,
186 'GenBank->GFF3/bp_genbank2gff3.pl'],
189 my $mysql_ok = 0;
191 my @drivers = available_drivers();
193 # Set up the Bio::Root::Build object
194 my $build = Bio::Root::Build->new(
195 module_name => 'Bio',
196 dist_name => 'BioPerl',
197 dist_version => '1.006925',
198 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
199 dist_abstract => 'Bioinformatics Toolkit',
200 license => 'perl',
201 requires => {
202 'perl' => '5.6.1',
203 'IO::String' => 0, # why is this required?
204 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
205 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
206 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
209 build_requires => {
210 'CPAN' => 1.81,
211 'Module::Build' => 0.2805,
212 'Test::Harness' => 2.62,
213 'Test::Most' => 0,
214 'URI::Escape' => 0
217 recommends => {
218 # reverted to a simple Module::Build-compatible hash, but we keep
219 # additional data in the %recommends hash above. May be converted to
220 # something simpler if there aren't complaints down the line.
221 map {$_ => $recommends{$_}[0]} sort keys %recommends
224 get_options => {
225 accept => { },
226 network => { } # say 'perl Build.PL --network' to manually request network tests
229 auto_features => {
230 'EntrezGene' => {
231 description => "Presence of Bio::ASN1::EntrezGene",
232 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
235 'DB_File Tests' => {
236 description => "BDB tests for Bio::DB::SeqFeature::Store",
237 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
240 'Bio::DB::GFF Tests' => {
241 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
242 requires => { 'DBI' => 0 },
245 'MySQL Tests' => {
246 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
247 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
250 'Pg Tests' => {
251 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
252 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
255 'SQLite Tests' => {
256 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
257 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
260 'Network Tests' => {
261 description => "Enable tests that need an internet connection",
262 requires => { 'LWP::UserAgent' => 0 },
265 dynamic_config => 1,
266 recursive_test_files => 1,
268 # Extra files needed for BioPerl modules
269 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
271 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
272 #script_files => [] # scripts in scripts directory are installed on-demand
275 my $accept = $build->args('accept');
277 my $proceed = prompt_for_biodb($accept)
278 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
279 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
281 # Handle auto features
282 if ($proceed && $build->feature('DB_File Tests')) {
283 # will return without doing anything if user chose not to run tests during
284 make_bdb_test();
286 if ($proceed && ($build->feature('MySQL Tests') ||
287 $build->feature('Pg Tests') ||
288 $build->feature('SQLite Tests'))) {
289 make_dbi_test();
292 # Ask questions
293 $build->choose_scripts($accept);
295 if ($build->args('network')) {
296 if ($build->feature('Network Tests')) {
297 $build->notes(network => 1);
298 $build->log_info(" - will run internet-requiring tests\n");
300 else {
301 $build->notes(network => 0);
302 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
305 else {
306 $build->prompt_for_network($accept) if $build->feature('Network Tests');
309 # Add additional files here
310 $build->add_build_element('xml');
312 # Create the build script and exit
313 $build->create_build_script;
315 exit;
317 ########################## Helper subs ##########################
319 sub make_bdb_test {
320 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
321 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
322 unlink($path) if (-e $path);
323 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
324 print $F <<END;
325 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
327 close $F;
328 $build->add_to_cleanup($path);
329 #$build->add_to_manifest_skip($path);
332 sub available_drivers {
333 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
334 return if $@;
335 @drivers = DBI->available_drivers;
336 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
337 $mysql_ok = 0;
338 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
340 $mysql_ok = 1;
341 return @drivers;
344 sub make_dbi_test {
345 my $dsn = $build->notes('test_dsn') || return;
346 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
347 my $driver = $build->notes('dbd_driver');
348 my $path = File::Spec->catfile('t', 'LocalDB',
349 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
350 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
351 'SeqFeature_Pg.t');
352 my $test_db = $build->notes('test_db');
353 my $user = $build->notes('test_user');
354 my $pass = $build->notes('test_pass');
355 open my $F, '>', $path or die "Could not write file '$path' for DBI test: $!\n";
356 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
357 $str .= " -user $user" if $user;
358 $str .= " -password $pass" if $pass;
359 print $F <<END;
360 system '$^X $str';
362 close $F;
363 $build->add_to_cleanup($path);
364 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
365 #$build->add_to_manifest_skip($path);
368 sub test_biodbgff {
369 eval {require DBI;}; # if not installed, this sub won't actually be called
370 return if $@;
371 @drivers = DBI->available_drivers;
372 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
373 return "MySQL, Pg nor Oracle DBI drivers are installed";
375 return;
378 sub prompt_for_biodb {
379 my $accept = shift;
380 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
381 "Bio::DB::SeqFeature::Store live database tests? ".
382 "y/n", 'n');
384 if ($proceed) {
385 my @driver_choices;
386 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
387 if (grep {/$poss/i} @drivers) {
388 my $choice = $poss;
389 $choice =~ s/^(.)/[$1]/;
390 push(@driver_choices, $choice);
394 my $driver;
395 if (@driver_choices > 1) {
396 my ($default) = $driver_choices[0] =~ /\[(.)/;
397 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
399 else {
400 ($driver) = $driver_choices[0] =~ /\[(.)/;
402 if ($driver =~ /^[mM]/) {
403 $driver = 'mysql';
405 elsif ($driver =~ /^[pP]/) {
406 $driver = 'Pg';
408 elsif ($driver =~ /^[oO]/) {
409 $driver = 'Oracle';
411 elsif ($driver =~ /^[sS]/) {
412 $driver = 'SQLite';
415 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
416 "This database should already be present but doesn't have to ".
417 "be preloaded for any schema", 'test');
418 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
419 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
420 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
422 my $use_host = 1;
423 if ($test_host eq 'undef' || $test_host eq 'localhost') {
424 $use_host = 0;
427 my $test_dsn;
428 if ($driver eq 'Pg' || $driver eq 'SQLite') {
429 $test_dsn = "dbi:$driver:dbname=$test_db";
430 $mysql_ok = 0;
432 else {
433 $test_dsn = "dbi:$driver:database=$test_db";
434 $mysql_ok = 0;
436 if ($use_host) {
437 $test_dsn .= ";host=$test_host";
440 $build->notes(dbd_driver => $driver);
441 $build->notes(test_db => $test_db);
442 $build->notes(test_host => $test_host);
443 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
444 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
445 $build->notes(test_dsn => $test_dsn);
447 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
448 " Database $test_db\n",
449 " Host $test_host\n",
450 " DSN $test_dsn\n",
451 " User $test_user\n",
452 " Password $test_pass\n");
453 $build->log_info(" - will not run the BioDBSeqFeature live ".
454 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
456 else {
457 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
460 $build->log_info("\n");
461 return $proceed;